Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@dlmanning/bind
Advanced tools
BoundFunction
bind a function to the provided context
function
Kind: global interface
Properties
Name | Type |
---|---|
partial | function |
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
Param | Type | Description |
---|---|---|
[...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
BoundFunction
bind a function to the provided context
Kind: global function
Returns: BoundFunction
- a bound function
Param | Type | Description |
---|---|---|
self | Object | context to which the function will be bound |
fn | function | function to be bound |
Example
var boundMethod = bind(this, this.aMethod)
boundMethod() // boundMethod is bound to this
Object.<string, BoundFunction>
bind a collection of functions to the provided context.
Kind: static method of bind
Param | Type | Description |
---|---|---|
self | Object | context to which the function will be bound |
methods | Array.<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
Bind and partially apply with memoization
The npm package @dlmanning/bind receives a total of 1 weekly downloads. As such, @dlmanning/bind popularity was classified as not popular.
We found that @dlmanning/bind 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.