isolated-function 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -91,10 +91,10 @@ If you exceed your limit, an error will occur. Any of the following interaction
91
91
  The hosted code is parsed for detecting `require`/`import` calls and install these dependencies:
92
92
 
93
93
  ```js
94
- const [isEmoji, teardown] = isolatedFunction(emoji => {
94
+ const [isEmoji, teardown] = isolatedFunction(input => {
95
95
  /* this dependency only exists inside the isolated function */
96
96
  const isEmoji = require('is-standard-emoji@1.0.0') // default is latest
97
- return isEmoji(emoji)
97
+ return isEmoji(input)
98
98
  })
99
99
 
100
100
  await isEmoji('🙌') // => true
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "isolated-function",
3
3
  "description": "Runs untrusted code in a Node.js v8 sandbox.",
4
4
  "homepage": "https://github.com/Kikobeats/isolated-function",
5
- "version": "0.1.10",
5
+ "version": "0.1.11",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js"
@@ -39,6 +39,7 @@
39
39
  "ensure-error": "~3.0.1",
40
40
  "esbuild": "~0.23.1",
41
41
  "serialize-error": "8",
42
+ "serialize-javascript": "~6.0.2",
42
43
  "tinyspawn": "~1.3.2"
43
44
  },
44
45
  "devDependencies": {
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const { deserializeError } = require('serialize-error')
4
+ const serialize = require('serialize-javascript')
4
5
  const timeSpan = require('@kikobeats/time-span')()
5
6
  const $ = require('tinyspawn')
6
7
  const path = require('path')
@@ -36,7 +37,7 @@ module.exports = (snippet, { tmpdir, timeout, memory, throwError = true } = {})
36
37
  const cwd = path.dirname(filepath)
37
38
  const filename = path.basename(filepath)
38
39
  duration = timeSpan()
39
- const { stdout } = await $('node', [filename, JSON.stringify(args)], {
40
+ const { stdout } = await $('node', [filename, serialize(args)], {
40
41
  cwd,
41
42
  env: {
42
43
  ...process.env,
@@ -3,8 +3,7 @@
3
3
  const SERIALIZE_ERROR = require('./serialize-error')
4
4
 
5
5
  module.exports = snippet => `
6
- const args = JSON.parse(process.argv[2])
7
-
6
+ const args = eval(\`(\${process.argv[2]})\`);
8
7
  const logging = Object.create(null)
9
8
 
10
9
  for (const method of ['log', 'info', 'debug', 'warn', 'error']) {