Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bind-x

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bind-x

Creates a new function with a bound sequence of arguments.

  • 4.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

bind-x

Creates a new function with a bound sequence of arguments.

module.exportsfunction

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.

Kind: Exported member
Returns: function - The bound function.
Throws:

  • TypeError If target is not a function.
ParamTypeDescription
targetfunctionThe target function.
thisArg*The value to be passed as the this parameter to the target function when the bound function is called. The value is ignored if the bound function is constructed using the new operator.
[args]...*Arguments to prepend to arguments provided to the bound function when invoking the target function.

Example

import bind from 'bind-x';

this.x = 9; // this refers to global "window" object here in the browser
const module = {
  x: 81,
  getX: function() {
    return this.x;
  },
};

console.log(module.getX()); // 81

const retrieveX = module.getX;
console.log(retrieveX());
// returns 9 - The function gets invoked at the global scope

// Create a new function with 'this' bound to module
// New programmers might confuse the
// global var x with module's property x
const boundGetX = bind(retrieveX, module);
console.log(boundGetX()); // 81

Keywords

FAQs

Package last updated on 28 Aug 2019

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