[79a0317] | 1 | # call-bind-apply-helpers <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
| 2 |
|
---|
| 3 | [![github actions][actions-image]][actions-url]
|
---|
| 4 | [![coverage][codecov-image]][codecov-url]
|
---|
| 5 | [![dependency status][deps-svg]][deps-url]
|
---|
| 6 | [![dev dependency status][dev-deps-svg]][dev-deps-url]
|
---|
| 7 | [![License][license-image]][license-url]
|
---|
| 8 | [![Downloads][downloads-image]][downloads-url]
|
---|
| 9 |
|
---|
| 10 | [![npm badge][npm-badge-png]][package-url]
|
---|
| 11 |
|
---|
| 12 | Helper functions around Function call/apply/bind, for use in `call-bind`.
|
---|
| 13 |
|
---|
| 14 | The only packages that should likely ever use this package directly are `call-bind` and `get-intrinsic`.
|
---|
| 15 | Please use `call-bind` unless you have a very good reason not to.
|
---|
| 16 |
|
---|
| 17 | ## Getting started
|
---|
| 18 |
|
---|
| 19 | ```sh
|
---|
| 20 | npm install --save call-bind-apply-helpers
|
---|
| 21 | ```
|
---|
| 22 |
|
---|
| 23 | ## Usage/Examples
|
---|
| 24 |
|
---|
| 25 | ```js
|
---|
| 26 | const assert = require('assert');
|
---|
| 27 | const callBindBasic = require('call-bind-apply-helpers');
|
---|
| 28 |
|
---|
| 29 | function f(a, b) {
|
---|
| 30 | assert.equal(this, 1);
|
---|
| 31 | assert.equal(a, 2);
|
---|
| 32 | assert.equal(b, 3);
|
---|
| 33 | assert.equal(arguments.length, 2);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | const fBound = callBindBasic([f, 1]);
|
---|
| 37 |
|
---|
| 38 | delete Function.prototype.call;
|
---|
| 39 | delete Function.prototype.bind;
|
---|
| 40 |
|
---|
| 41 | fBound(2, 3);
|
---|
| 42 | ```
|
---|
| 43 |
|
---|
| 44 | ## Tests
|
---|
| 45 |
|
---|
| 46 | Clone the repo, `npm install`, and run `npm test`
|
---|
| 47 |
|
---|
| 48 | [package-url]: https://npmjs.org/package/call-bind-apply-helpers
|
---|
| 49 | [npm-version-svg]: https://versionbadg.es/ljharb/call-bind-apply-helpers.svg
|
---|
| 50 | [deps-svg]: https://david-dm.org/ljharb/call-bind-apply-helpers.svg
|
---|
| 51 | [deps-url]: https://david-dm.org/ljharb/call-bind-apply-helpers
|
---|
| 52 | [dev-deps-svg]: https://david-dm.org/ljharb/call-bind-apply-helpers/dev-status.svg
|
---|
| 53 | [dev-deps-url]: https://david-dm.org/ljharb/call-bind-apply-helpers#info=devDependencies
|
---|
| 54 | [npm-badge-png]: https://nodei.co/npm/call-bind-apply-helpers.png?downloads=true&stars=true
|
---|
| 55 | [license-image]: https://img.shields.io/npm/l/call-bind-apply-helpers.svg
|
---|
| 56 | [license-url]: LICENSE
|
---|
| 57 | [downloads-image]: https://img.shields.io/npm/dm/call-bind-apply-helpers.svg
|
---|
| 58 | [downloads-url]: https://npm-stat.com/charts.html?package=call-bind-apply-helpers
|
---|
| 59 | [codecov-image]: https://codecov.io/gh/ljharb/call-bind-apply-helpers/branch/main/graphs/badge.svg
|
---|
| 60 | [codecov-url]: https://app.codecov.io/gh/ljharb/call-bind-apply-helpers/
|
---|
| 61 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bind-apply-helpers
|
---|
| 62 | [actions-url]: https://github.com/ljharb/call-bind-apply-helpers/actions
|
---|