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.1 to 1.0.2

.eslintignore

28

index.js

@@ -190,2 +190,3 @@ 'use strict';

var $replace = bind.call(Function.call, String.prototype.replace);
var $strSlice = bind.call(Function.call, String.prototype.slice);

@@ -196,2 +197,9 @@ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */

var stringToPath = function stringToPath(string) {
var first = $strSlice(string, 0, 1);
var last = $strSlice(string, -1);
if (first === '%' && last !== '%') {
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
} else if (last === '%' && first !== '%') {
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
}
var result = [];

@@ -253,2 +261,13 @@ $replace(string, rePropName, function (match, number, quote, subString) {

var part = parts[i];
var first = $strSlice(part, 0, 1);
var last = $strSlice(part, -1);
if (
(
(first === '"' || first === "'" || first === '`')
|| (last === '"' || last === "'" || last === '`')
)
&& first !== last
) {
throw new $SyntaxError('property names with quotes must have matching quotes');
}
if (part === 'constructor' || !isOwn) {

@@ -264,2 +283,8 @@ skipFurtherCaching = true;

} else if (value != null) {
if (!(part in value)) {
if (!allowMissing) {
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
}
return void undefined;
}
if ($gOPD && (i + 1) >= parts.length) {

@@ -269,5 +294,2 @@ var desc = $gOPD(value, part);

if (!allowMissing && !(part in value)) {
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
}
// By convention, when a data property is converted to an accessor

@@ -274,0 +296,0 @@ // property to emulate a data property that does not suffer from

12

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

@@ -46,10 +46,10 @@ "main": "index.js",

"devDependencies": {
"@ljharb/eslint-config": "^17.2.0",
"aud": "^1.1.2",
"@ljharb/eslint-config": "^17.3.0",
"aud": "^1.1.3",
"auto-changelog": "^2.2.1",
"es-abstract": "^1.18.0-next.1",
"es-value-fixtures": "^1.0.0",
"eslint": "^7.12.1",
"eslint": "^7.15.0",
"foreach": "^2.0.5",
"has-bigints": "^1.0.0",
"has-bigints": "^1.0.1",
"make-async-function": "^1.0.0",

@@ -59,3 +59,3 @@ "make-async-generator-function": "^1.0.0",

"nyc": "^10.3.2",
"object-inspect": "^1.8.0",
"object-inspect": "^1.9.0",
"tape": "^5.0.1"

@@ -62,0 +62,0 @@ },

@@ -45,2 +45,26 @@ 'use strict';

t['throws'](
function () { GetIntrinsic('%String'); },
SyntaxError,
'Leading % without trailing % throws a syntax error'
);
t['throws'](
function () { GetIntrinsic('String%'); },
SyntaxError,
'Trailing % without leading % throws a syntax error'
);
t['throws'](
function () { GetIntrinsic("String['prototype]"); },
SyntaxError,
'Dynamic property access is disallowed for intrinsics (unterminated string)'
);
t['throws'](
function () { GetIntrinsic('%Proxy.prototype.undefined%'); },
TypeError,
"Throws when middle part doesn't exist (%Proxy.prototype.undefined%)"
);
forEach(v.nonStrings, function (nonString) {

@@ -47,0 +71,0 @@ t['throws'](

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