Skip to content

Commit 7419c66

Browse files
committed
fix(readme): correct usage examples
1 parent a5c97fb commit 7419c66

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ whitelist. If no whitelist is specified, we default to an empty whitelist.
1717
## Usage
1818

1919
````javascript
20-
var sandbox = require('sandbox.js'),
21-
whitelist = ['console'],
22-
context = {require: require},
23-
theAnswerFun = function() { return 42; },
24-
consoleFun = function() { require('console').log('Hello World!'); },
25-
httpFun = function() { return require('http').STATUS_CODES['200']; };
20+
const sandbox = require('sandbox.js'),
21+
context = {require: require},
22+
theAnswerFun = function() { return 42; },
23+
consoleFun = function() { require('console').log('Hello World!'); },
24+
httpFun = function() { return require('http').STATUS_CODES['200']; };
2625

2726
sandbox.runInSandbox(theAnswerFun); // => 42
2827

2928
sandbox.runInSandbox(consoleFun); // => ReferenceError: require is not defined
3029
sandbox.runInSandbox(consoleFun, context); // => Error: 'console' is not whitelisted
31-
sandbox.runInSandbox(consoleFun, context, whitelist); // => Hello World!
30+
sandbox.runInSandbox(consoleFun, context, ['http']); // => Error: 'console' is not whitelisted
31+
sandbox.runInSandbox(consoleFun, context, ['console']); // => Hello World!
3232

33-
sandbox.runInSandbox(httpFun, context); // => 'OK'
34-
sandbox.runInSandbox(httpFun, context, whitelist); // => Error: 'http' is not whitelisted
33+
sandbox.runInSandbox(httpFun); // => ReferenceError: require is not defined
34+
sandbox.runInSandbox(httpFun, context); // => Error: 'http' is not whitelisted
35+
sandbox.runInSandbox(httpFun, context, ['console']); // => Error: 'http' is not whitelisted
36+
sandbox.runInSandbox(httpFun, context, ['http']); // => 'OK'
3537
````
3638

3739
## LICENSE

0 commit comments

Comments
 (0)