Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Bind an object to this
in all methods in a function or object. Simple, dependency-free alternative to deep-bind.
$ npm install bind-deep
# Create package.json for your own module if you haven't already
$ npm init
# Install bind-deep and add to dependencies
$ npm install bind-deep --save
$ git clone https://github.com/evelynhathaway/bind-deep
$ cd bind-deep/
$ npm install
bindDeep(object [Function, Object, Array], thisArg [Object], ...args)
// => bound [Function, Object, Array]
// Require bind-deep
const bindDeep = require("bind-deep");
// Original object and function
// Could also be an actual object
const func = function() {
// Use `this`
};
func.method = function() {
// Use `this` again
};
const obj = {
method() {
// Use `this`
}
};
// Deeply bound object and function
// `thisArg` will be what every function and method will see as `this`
const boundObj = bindDeep(obj, thisArg);
// => {method: [Function: bound]}
const boundFunc = bindDeep(func, thisArg);
// => {[Function: bound] method: [Function: bound]}
Copyright Evelyn Hathaway, MIT License
FAQs
Lightweight module for binding a function or object deeply.
The npm package bind-deep receives a total of 68 weekly downloads. As such, bind-deep popularity was classified as not popular.
We found that bind-deep 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.