Skip to content

Commit

Permalink
Refresh PR based on the latest state of master
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Aug 1, 2024
1 parent c606d95 commit f47ea37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions js/modules/k6/experimental/csv/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"io"
"sync/atomic"

"github.com/grafana/sobek"

"gopkg.in/guregu/null.v3"

"go.k6.io/k6/js/promises"

"go.k6.io/k6/js/modules/k6/experimental/fs"

"github.com/dop251/goja"
"go.k6.io/k6/js/common"
"go.k6.io/k6/js/modules"
)
Expand Down Expand Up @@ -76,21 +77,21 @@ type Parser struct {
}

// NewParser creates a new CSV parser instance.
func (mi *ModuleInstance) NewParser(call goja.ConstructorCall) *goja.Object {
func (mi *ModuleInstance) NewParser(call sobek.ConstructorCall) *sobek.Object {
rt := mi.vu.Runtime()

if len(call.Arguments) < 1 || goja.IsUndefined(call.Argument(0)) {
if len(call.Arguments) < 1 || sobek.IsUndefined(call.Argument(0)) {
common.Throw(rt, fmt.Errorf("parser constructor takes at least one non-nil source argument"))
}

// 1. Make sure the Goja object is a fs.File (goja operation)
// 1. Make sure the Goja object is a fs.File (sobek operation)
var file fs.File
if err := mi.vu.Runtime().ExportTo(call.Argument(0), &file); err != nil {
common.Throw(mi.vu.Runtime(), fmt.Errorf("first arg doesn't appear to be a *file.File instance"))
}

var options parserOptions
if len(call.Arguments) == 2 && !goja.IsUndefined(call.Argument(1)) {
if len(call.Arguments) == 2 && !sobek.IsUndefined(call.Argument(1)) {
var err error
options, err = newParserOptionsFrom(call.Argument(1).ToObject(rt))
if err != nil {
Expand Down Expand Up @@ -138,7 +139,7 @@ func (mi *ModuleInstance) NewParser(call goja.ConstructorCall) *goja.Object {
}

// Next returns the next row in the CSV file.
func (p *Parser) Next() *goja.Promise {
func (p *Parser) Next() *sobek.Promise {
promise, resolve, reject := promises.New(p.vu)

go func() {
Expand Down Expand Up @@ -196,7 +197,7 @@ type parserOptions struct {
}

// newParserOptions creates a new parserOptions instance from the given Goja object.
func newParserOptionsFrom(obj *goja.Object) (parserOptions, error) {
func newParserOptionsFrom(obj *sobek.Object) (parserOptions, error) {
// Initialize default options
options := parserOptions{
Delimiter: ',',
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/experimental/fs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"io"
"reflect"

"go.k6.io/k6/lib/fsext"

"github.com/grafana/sobek"
"go.k6.io/k6/js/common"
"go.k6.io/k6/js/modules"
Expand Down

0 comments on commit f47ea37

Please sign in to comment.