JSPM

pull-sandbox

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q28483F
  • License MIT

A through stream that runs a user-provided, untrusted mapper function in a quickjs sandbox in a worker thread.

Package Exports

  • pull-sandbox

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-sandbox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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 for details.

License: MIT