diff options
author | dustinnewman98 <dustinnewman98@gmail.com> | 2018-03-01 22:11:55 -0800 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2018-03-22 15:54:52 +0100 |
commit | 49b2969ef4731ad4a3b63476d80ce31075526613 (patch) | |
tree | 98ebe9eb18fc2ca8ec0ac6cd5d4bc791bcae0a63 /lib/vm.js | |
parent | 4e1f0907dae9916215985a9f81bf3dec1eeaeaef (diff) | |
download | android-node-v8-49b2969ef4731ad4a3b63476d80ce31075526613.tar.gz android-node-v8-49b2969ef4731ad4a3b63476d80ce31075526613.tar.bz2 android-node-v8-49b2969ef4731ad4a3b63476d80ce31075526613.zip |
vm: migrate isContext to internal/errors
PR-URL: https://github.com/nodejs/node/pull/19268
Refs: https://github.com/nodejs/node/issues/18106
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/vm.js')
-rw-r--r-- | lib/vm.js | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -26,10 +26,13 @@ const { kParsingContext, makeContext, - isContext, + isContext: _isContext, } = process.binding('contextify'); -const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; +const { + ERR_INVALID_ARG_TYPE, + ERR_MISSING_ARGS +} = require('internal/errors').codes; // The binding provides a few useful primitives: // - Script(code, { filename = "evalmachine.anonymous", @@ -119,6 +122,19 @@ function getContextOptions(options) { return {}; } +function isContext(sandbox) { + if (arguments.length < 1) { + throw new ERR_MISSING_ARGS('sandbox'); + } + + if (typeof sandbox !== 'object' && typeof sandbox !== 'function' || + sandbox === null) { + throw new ERR_INVALID_ARG_TYPE('sandbox', 'object', sandbox); + } + + return _isContext(sandbox); +} + let defaultContextNameIndex = 1; function createContext(sandbox, options) { if (sandbox === undefined) { |