https://github.com/regular/pull-sandbox
https://github.com/regular/pull-sandbox
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/regular/pull-sandbox
- Owner: regular
- Created: 2020-05-22T20:10:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-08T16:43:45.000Z (almost 6 years ago)
- Last Synced: 2025-05-31T22:09:49.551Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
pull-sandbox
---
A through stream that runs a mapper function in a quickjs sandbox in a worker thread.
```
const test = require('tape')
const sandbox = require('pull-sandbox')
const pull = require('pull-stream')
test('pull some numbers through the sandbox', t=>{
pull(
pull.values([1,2,3,4]),
sandbox(`
module.exports = function(a) {
return {n: a * 10}
}
`),
pull.collect( (err, values) =>{
t.error(err)
t.deepEqual(values, [{n:10},{n:20},{n:30},{n:40}])
t.end()
})
)
})
````
## API
### `sandbox(code)`
- code: source code of a commonJS module that exports a map function.
See [sandbox-worker](https://github.com/regular/sandbox-worker) for details.
License: MIT