New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dlmanning/bind

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dlmanning/bind

Bind and partially apply with memoization

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Functions

bind(self, fn)BoundFunction

bind a function to the provided context

BoundFunction : function

Kind: global interface
Properties

NameType
partialfunction

boundFunction.partial ⇒ BoundFunction

Perform a partial application of the provided parameters. The returned function is memoized for a given set of parameters, so that repeated applications will always return the same function object.

Kind: instance property of BoundFunction
Returns: BoundFunction - another BoundFunction with the provided params applied

ParamTypeDescription
[...params]*zero or more items to partially apply

Example

const applied = boundMethod.partial('Hello', 'World')
// applied is a BoundFunction which will always be called with "Hello" and
// "World" as its first two params

bind(self, fn) ⇒ BoundFunction

bind a function to the provided context

Kind: global function
Returns: BoundFunction - a bound function

ParamTypeDescription
selfObjectcontext to which the function will be bound
fnfunctionfunction to be bound

Example

var boundMethod = bind(this, this.aMethod)
boundMethod() // boundMethod is bound to this

bind.all(self, methods) ⇒ Object.<string, BoundFunction>

bind a collection of functions to the provided context.

Kind: static method of bind

ParamTypeDescription
selfObjectcontext to which the function will be bound
methodsArray.<string> | Object.<string, function()>If an array is given, it must be an array of strings whose names are methods on the provided context object. If an object is provided, the returned object will key the bound functions according to those provided.

Example

// assumes hear, see and speak are methods on this
bind.all(this, ['hear', 'see', 'speak'])
// or you can pass an object with function values, which will be bound to this
bind.all(this, { hear: function1, see: function2, speak: function3 })

FAQs

Package last updated on 04 Apr 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc