Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
new alias added to use the goja JS VM transform function (#335)
Browse files Browse the repository at this point in the history
fixes #322
  • Loading branch information
jipperinbham authored Mar 24, 2017
1 parent 4242b9b commit d009340
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v0.3.1 [UNRELEASED]

### Features
- added `js` alias for `goja` transform function [#335](https://github.com/compose/transporter/pull/335)

### Bugfixes
- fixed mongodb, rabbitmq, and rethinkdb adaptors from not trying to read from a file when provided in the `ca_certs` field [#334](https://github.com/compose/transporter/pull/334)
Expand Down
2 changes: 2 additions & 0 deletions function/gojajs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

```javascript
goja({"filename": "/path/to/transform.js"})
// js() is aliased to goja
// js({"filename": "/path/to/transform.js"})
```

### example
Expand Down
6 changes: 6 additions & 0 deletions function/gojajs/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func init() {
return &Goja{}
},
)
function.Add(
"js",
func() function.Function {
return &Goja{}
},
)
}

type Goja struct {
Expand Down
14 changes: 12 additions & 2 deletions function/gojajs/goja_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ import (
)

var initTests = []struct {
fnName string
in map[string]interface{}
expect *Goja
}{
{map[string]interface{}{"filename": "testdata/transformer.js"}, &Goja{Filename: "testdata/transformer.js"}},
{
"goja",
map[string]interface{}{"filename": "testdata/transformer.js"},
&Goja{Filename: "testdata/transformer.js"},
},
{
"js",
map[string]interface{}{"filename": "testdata/transformer.js"},
&Goja{Filename: "testdata/transformer.js"},
},
}

func TestInit(t *testing.T) {
for _, it := range initTests {
a, err := function.GetFunction("goja", it.in)
a, err := function.GetFunction(it.fnName, it.in)
if err != nil {
t.Fatalf("unexpected GetFunction() error, %s", err)
}
Expand Down

0 comments on commit d009340

Please sign in to comment.