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.
setprototypeof
Advanced tools
The setprototypeof package is a simple module that allows you to set the prototype of an object, which can be useful for creating a chain of prototypes (i.e., inheritance) or for changing an object's prototype on-the-fly. It is a polyfill for the official ECMAScript 2015 (ES6) Object.setPrototypeOf method.
Setting the prototype of an object
This feature allows you to set the prototype of an object to another object. After setting the prototype, the object will have access to the properties and methods of the new prototype.
{"object": {"prop": "value"}, "prototype": {"newProp": "newValue"}}
The object-assign package is used to copy the values of all enumerable own properties from one or more source objects to a target object. It is similar to setprototypeof in that it is used for manipulating objects, but it does not change the prototype chain.
Lodash's assign function is similar to object-assign and is used to assign own enumerable properties of source objects to the destination object. Like object-assign, it does not deal with the prototype chain but rather with copying properties.
The util package is a collection of utilities originally for the Node.js standard library. It includes util.inherits, which is a method that allows you to set the prototype of a constructor to an object, creating a prototype chain similar to what setprototypeof does, but specifically for constructor functions.
Object.setPrototypeOf
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
$ npm install --save setprototypeof
var setPrototypeOf = require('setprototypeof')
var obj = {}
setPrototypeOf(obj, {
foo: function () {
return 'bar'
}
})
obj.foo() // bar
TypeScript is also supported:
import setPrototypeOf from 'setprototypeof'
FAQs
A small polyfill for Object.setprototypeof
The npm package setprototypeof receives a total of 38,608,142 weekly downloads. As such, setprototypeof popularity was classified as popular.
We found that setprototypeof demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.