Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.
The call-bound npm package is a utility that allows you to get a bound function for a method of an object, ensuring that the method is called with the correct 'this' context. This is particularly useful for methods that are often used in a standalone manner, such as array or string methods.
Binding a method to its object
This feature allows you to bind a method to its object, ensuring that the method is always called with the correct 'this' context. In this example, Array.prototype.slice is bound to an array, allowing it to be used as a standalone function.
const callBound = require('call-bound');
const arraySlice = callBound('Array.prototype.slice');
const result = arraySlice([1, 2, 3, 4], 1, 3); // [2, 3]
The function-bind package provides a polyfill for Function.prototype.bind, which is a native JavaScript method that allows you to create a new function with a specific 'this' value. While call-bound focuses on binding methods to their objects, function-bind is more general-purpose, allowing any function to be bound to a specific context.
Lodash is a utility library that provides a wide range of functions for manipulating arrays, objects, and other data types. It includes a _.bind method that is similar to call-bound in that it allows you to bind a function to a specific context. However, lodash offers a much broader set of utilities beyond just function binding.
Robust call-bound JavaScript intrinsics, using call-bind
and get-intrinsic
.
npm install --save call-bound
const assert = require('assert');
const callBound = require('call-bind/callBound');
const slice = callBound('Array.prototype.slice');
delete Function.prototype.call;
delete Function.prototype.bind;
delete Array.prototype.slice;
assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]);
Clone the repo, npm install
, and run npm test
FAQs
Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.
The npm package call-bound receives a total of 13,095,204 weekly downloads. As such, call-bound popularity was classified as popular.
We found that call-bound demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.