Socket
Socket
Sign inDemoInstall

get-intrinsic

Package Overview
Dependencies
3
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

48

index.js

@@ -5,6 +5,3 @@ 'use strict';

AggregateError,
Atomics,
FinalizationRegistry,
SharedArrayBuffer,
WeakRef,
*/

@@ -21,4 +18,3 @@

try {
// eslint-disable-next-line no-new-func
return Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
} catch (e) {}

@@ -60,5 +56,3 @@ };

var asyncGenFunction = getEvalledConstructor('async function* () {}');
var asyncGenFunctionPrototype = asyncGenFunction ? asyncGenFunction.prototype : undefined;
var asyncGenPrototype = asyncGenFunctionPrototype ? asyncGenFunctionPrototype.prototype : undefined;
var needsEval = {};

@@ -73,6 +67,6 @@ var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);

'%AsyncFromSyncIteratorPrototype%': undefined,
'%AsyncFunction%': getEvalledConstructor('async function () {}'),
'%AsyncGenerator%': asyncGenFunctionPrototype,
'%AsyncGeneratorFunction%': asyncGenFunction,
'%AsyncIteratorPrototype%': asyncGenPrototype ? getProto(asyncGenPrototype) : undefined,
'%AsyncFunction%': needsEval,
'%AsyncGenerator%': needsEval,
'%AsyncGeneratorFunction%': needsEval,
'%AsyncIteratorPrototype%': needsEval,
'%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,

@@ -94,3 +88,3 @@ '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,

'%Function%': $Function,
'%GeneratorFunction%': getEvalledConstructor('function* () {}'),
'%GeneratorFunction%': needsEval,
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,

@@ -136,2 +130,27 @@ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,

var doEval = function doEval(name) {
var value;
if (name === '%AsyncFunction%') {
value = getEvalledConstructor('async function () {}');
} else if (name === '%GeneratorFunction%') {
value = getEvalledConstructor('function* () {}');
} else if (name === '%AsyncGeneratorFunction%') {
value = getEvalledConstructor('async function* () {}');
} else if (name === '%AsyncGenerator%') {
var fn = doEval('%AsyncGeneratorFunction%');
if (fn) {
value = fn.prototype;
}
} else if (name === '%AsyncIteratorPrototype%') {
var gen = doEval('%AsyncGenerator%');
if (gen) {
value = getProto(gen.prototype);
}
}
INTRINSICS[name] = value;
return value;
};
var LEGACY_ALIASES = {

@@ -227,2 +246,5 @@ '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],

var value = INTRINSICS[intrinsicName];
if (value === needsEval) {
value = doEval(intrinsicName);
}
if (typeof value === 'undefined' && !allowMissing) {

@@ -229,0 +251,0 @@ throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');

{
"name": "get-intrinsic",
"version": "1.0.2",
"version": "1.1.0",
"description": "Get and robustly cache all JS language-level intrinsics at first require time",

@@ -17,3 +17,3 @@ "main": "index.js",

"pretest": "npm run lint",
"tests-only": "nyc tape 'test/*'",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",

@@ -47,8 +47,9 @@ "posttest": "aud --production",

"devDependencies": {
"@ljharb/eslint-config": "^17.3.0",
"@ljharb/eslint-config": "^17.5.0",
"aud": "^1.1.3",
"auto-changelog": "^2.2.1",
"es-abstract": "^1.18.0-next.1",
"call-bind": "^1.0.2",
"es-abstract": "^1.18.0-next.2",
"es-value-fixtures": "^1.0.0",
"eslint": "^7.15.0",
"eslint": "^7.18.0",
"foreach": "^2.0.5",

@@ -61,3 +62,3 @@ "has-bigints": "^1.0.1",

"object-inspect": "^1.9.0",
"tape": "^5.0.1"
"tape": "^5.1.1"
},

@@ -64,0 +65,0 @@ "auto-changelog": {

@@ -12,3 +12,3 @@ 'use strict';

var callBound = require('es-abstract/helpers/callBound');
var callBound = require('call-bind/callBound');
var v = require('es-value-fixtures');

@@ -217,3 +217,3 @@ var $gOPD = require('es-abstract/helpers/getOwnPropertyDescriptor');

test('async generator functions', { skip: !asyncGenFns.length }, function (t) {
test('async generator functions', { skip: asyncGenFns.length === 0 }, function (t) {
var $AsyncGeneratorFunction = GetIntrinsic('%AsyncGeneratorFunction%');

@@ -234,1 +234,30 @@ var $AsyncGeneratorFunctionPrototype = GetIntrinsic('%AsyncGenerator%');

});
test('%ThrowTypeError%', function (t) {
var $ThrowTypeError = GetIntrinsic('%ThrowTypeError%');
t.equal(typeof $ThrowTypeError, 'function', 'is a function');
t['throws'](
$ThrowTypeError,
TypeError,
'%ThrowTypeError% throws a TypeError'
);
t.end();
});
test('allowMissing', { skip: asyncGenFns.length > 0 }, function (t) {
t['throws'](
function () { GetIntrinsic('%AsyncGeneratorPrototype%'); },
TypeError,
'throws when missing'
);
t.equal(
GetIntrinsic('%AsyncGeneratorPrototype%', true),
undefined,
'does not throw when allowMissing'
);
t.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc