Skip to content

Commit 9b47285

Browse files
committed
Auto whitespace cleanup
1 parent f9c3c1a commit 9b47285

File tree

8 files changed

+269
-269
lines changed

8 files changed

+269
-269
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ VM is a simple sandbox, without `require` feature, to synchronously run an untru
7070

7171
**Options:**
7272

73-
* `timeout` - Script timeout in milliseconds.
73+
* `timeout` - Script timeout in milliseconds.
7474
* `sandbox` - VM's global object.
7575
* `compiler` - `javascript` (default) or `coffeescript` or custom compiler function.
7676

bin/vm2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
22

3-
require(__dirname +'/../lib/cli.js');
3+
require(__dirname +'/../lib/cli.js');

lib/cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ const {NodeVM, VMError} = require('../');
55

66
if (process.argv[2]) {
77
let path = pa.resolve(process.argv[2]);
8-
8+
99
console.log(`\x1B[90m[vm] creating VM for ${path}\x1B[39m`);
1010
let started = Date.now();
11-
11+
1212
try {
1313
NodeVM.file(path, {
1414
verbose: true,
1515
require: {
1616
external: true
1717
}
1818
});
19-
19+
2020
console.log(`\x1B[90m[vm] VM completed in ${Date.now() - started}ms\x1B[39m`);
2121
} catch (ex) {
2222
if (ex instanceof VMError) {
2323
console.error(`\x1B[31m[vm:error] ${ex.message}\x1B[39m`);
2424
} else {
2525
let {stack} = ex;
26-
26+
2727
if (stack) {
2828
console.error(`\x1B[31m[vm:error] ${stack}\x1B[39m`);
2929
} else {

lib/contextify.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ const Decontextified = new host.WeakMap();
2828
global.VMError = class VMError extends Error {
2929
constructor(message, code) {
3030
super(message);
31-
31+
3232
this.name = 'VMError';
3333
this.code = code;
34-
34+
3535
ERROR_CST(this, this.constructor);
3636
}
3737
}
@@ -42,10 +42,10 @@ global.VMError = class VMError extends Error {
4242

4343
const Decontextify = {
4444
proxies: new host.WeakMap(),
45-
45+
4646
arguments: function(args) {
4747
if (!host.Array.isArray(args)) return new host.Array();
48-
48+
4949
let arr = new host.Array();
5050
for (let i = 0, l = args.length; i < l; i++) arr[i] = Decontextify.value(args[i]);
5151
return arr;
@@ -57,7 +57,7 @@ const Decontextify = {
5757
if (key === 'isVMProxy') return true;
5858
if (key === 'constructor') return klass;
5959
if (key === '__proto__') return klass.prototype;
60-
60+
6161
try {
6262
return Decontextify.value(instance[key]);
6363
} catch (e) {
@@ -74,7 +74,7 @@ const Decontextify = {
7474
apply: (target, context, args) => {
7575
try {
7676
context = Contextify.value(context);
77-
77+
7878
// Set context of all arguments to vm's context.
7979
return Decontextify.value(fnc.apply(context, Contextify.arguments(args)));
8080
} catch (e) {
@@ -94,7 +94,7 @@ const Decontextify = {
9494
if (mock && key in mock) return mock[key];
9595
if (key === 'constructor') return host.Function;
9696
if (key === '__proto__') return host.Function.prototype;
97-
97+
9898
try {
9999
return Decontextify.value(fnc[key], deepTraps);
100100
} catch (e) {
@@ -105,7 +105,7 @@ const Decontextify = {
105105
return host.Function.prototype;
106106
}
107107
}, traps), deepTraps);
108-
108+
109109
return self;
110110
},
111111
object: function(object, traps, deepTraps, mock) {
@@ -116,7 +116,7 @@ const Decontextify = {
116116
if (mock && key in mock) return mock[key];
117117
if (key === 'constructor') return host.Object;
118118
if (key === '__proto__') return host.Object.prototype;
119-
119+
120120
try {
121121
return Decontextify.value(object[key], deepTraps);
122122
} catch (e) {
@@ -137,10 +137,10 @@ const Decontextify = {
137137
} catch (e) {
138138
throw Decontextify.value(e);
139139
}
140-
140+
141141
// Following code prevents V8 to throw
142142
// TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '<prop>' which is either non-existant or configurable in the proxy target
143-
143+
144144
if (!def) {
145145
return undefined;
146146
} else if (def.get || def.set) {
@@ -187,7 +187,7 @@ const Decontextify = {
187187
throw new host.Error(OPNA);
188188
}
189189
}, traps));
190-
190+
191191
Decontextify.proxies.set(object, proxy);
192192
Decontextified.set(proxy, object);
193193
return proxy;
@@ -200,7 +200,7 @@ const Decontextify = {
200200
// Decontextified proxy already exists, reuse
201201
return Decontextify.proxies.get(value);
202202
}
203-
203+
204204
switch (typeof value) {
205205
case 'object':
206206
if (value === null) {
@@ -227,10 +227,10 @@ const Decontextify = {
227227
}
228228
case 'function':
229229
return Decontextify.function(value, traps, deepTraps, mock);
230-
230+
231231
case 'undefined':
232232
return undefined;
233-
233+
234234
default: // string, number, boolean, symbol
235235
return value;
236236
}
@@ -243,10 +243,10 @@ const Decontextify = {
243243

244244
const Contextify = {
245245
proxies: new host.WeakMap(),
246-
246+
247247
arguments: function(args) {
248248
if (!host.Array.isArray(args)) return new Array();
249-
249+
250250
let arr = new Array();
251251
for (let i = 0, l = args.length; i < l; i++) arr[i] = Contextify.value(args[i]);
252252
return arr;
@@ -306,7 +306,7 @@ const Contextify = {
306306
return Function.prototype;
307307
}
308308
}, traps), deepTraps);
309-
309+
310310
return self;
311311
},
312312
object: function(object, traps, deepTraps, mock) {
@@ -338,7 +338,7 @@ const Contextify = {
338338
} catch (e) {
339339
throw Contextify.value(e);
340340
}
341-
341+
342342
// Following code prevents V8 to throw
343343
// TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '<prop>' which is either non-existant or configurable in the proxy target
344344

@@ -401,7 +401,7 @@ const Contextify = {
401401
// Contextified proxy already exists, reuse
402402
return Contextify.proxies.get(value);
403403
}
404-
404+
405405
switch (typeof value) {
406406
case 'object':
407407
if (value === null) {
@@ -429,10 +429,10 @@ const Contextify = {
429429
}
430430
case 'function':
431431
return Contextify.function(value, traps, deepTraps, mock);
432-
432+
433433
case 'undefined':
434434
return undefined;
435-
435+
436436
default: // string, number, boolean, symbol
437437
return value;
438438
}

0 commit comments

Comments
 (0)