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

    get-intrinsic

Get and robustly cache all JS language-level intrinsics at first require time


Version published
Weekly downloads
51M
decreased by-1.39%
Maintainers
1
Install size
74.9 kB
Created
Weekly downloads
 

Package description

What is get-intrinsic?

The get-intrinsic package is a utility that allows you to safely obtain references to ECMAScript language intrinsics without relying on the global namespace, which can be altered by other code. It helps in writing robust code that doesn't get affected by modifications to the global objects or functions.

What are get-intrinsic's main functionalities?

Getting intrinsic values

This feature allows you to get the original intrinsic value of Array.prototype.push, which can then be used to push elements to arrays without relying on Array.prototype.push being unmodified.

var getIntrinsic = require('get-intrinsic');
var ArrayPrototypePush = getIntrinsic('%Array.prototype.push%');
var anArray = [1, 2, 3];
ArrayPrototypePush(anArray, 4); // anArray becomes [1, 2, 3, 4]

Accessing deep intrinsics

This feature allows you to access deep intrinsic properties like Object.prototype.hasOwnProperty, which can be used to check for properties without relying on the original method being unaltered.

var getIntrinsic = require('get-intrinsic');
var hasOwn = getIntrinsic('%Object.prototype.hasOwnProperty%');
var hasDuck = hasOwn.call({ duck: 'quack' }, 'duck'); // hasDuck is true

Ensuring unmodified constructors

This feature allows you to use the original Array constructor to create new arrays, ensuring that the constructor has not been modified in the global scope.

var getIntrinsic = require('get-intrinsic');
var ArrayConstructor = getIntrinsic('%Array%');
var myArray = new ArrayConstructor(1, 2, 3); // myArray is [1, 2, 3]

Other packages similar to get-intrinsic

Changelog

Source

v1.1.0 - 2021-01-25

Fixed

  • [Refactor] delay Function eval until syntax-derived values are requested #3

Commits

  • [Tests] migrate tests to Github Actions 2ab762b
  • [meta] do not publish github action workflow files 5e7108e
  • [Tests] add some coverage 01ac7a8
  • [Dev Deps] update eslint, @ljharb/eslint-config, call-bind, es-abstract, tape; add call-bind 911b672
  • [Refactor] rearrange evalled constructors a bit 7e7e4bf
  • [meta] add Automatic Rebase and Require Allow Edits workflows 0199968

Readme

Source

get-intrinsic

Get and robustly cache all JS language-level intrinsics at first require time.

Keywords

FAQs

Last updated on 25 Jan 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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