Skip to content

Commit 1845ccf

Browse files
committed
[readme] flesh out content
1 parent 23bd718 commit 1845ccf

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# call-bind
1+
# call-bind <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+
212
Robustly `.call.bind()` a function.
13+
14+
## Getting started
15+
16+
```sh
17+
npm install --save call-bind
18+
```
19+
20+
## Usage/Examples
21+
22+
```js
23+
const assert = require('assert');
24+
const callBind = require('call-bind');
25+
const callBound = require('call-bind/callBound');
26+
27+
function f(a, b) {
28+
assert.equal(this, 1);
29+
assert.equal(a, 2);
30+
assert.equal(b, 3);
31+
assert.equal(arguments.length, 2);
32+
}
33+
34+
const fBound = callBind(f);
35+
36+
const slice = callBound('Array.prototype.slice');
37+
38+
delete Function.prototype.call;
39+
delete Function.prototype.bind;
40+
41+
fBound(1, 2, 3);
42+
43+
assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]);
44+
```
45+
46+
## Tests
47+
48+
Clone the repo, `npm install`, and run `npm test`
49+
50+
[package-url]: https://npmjs.org/package/call-bind
51+
[npm-version-svg]: https://versionbadg.es/ljharb/call-bind.svg
52+
[deps-svg]: https://david-dm.org/ljharb/call-bind.svg
53+
[deps-url]: https://david-dm.org/ljharb/call-bind
54+
[dev-deps-svg]: https://david-dm.org/ljharb/call-bind/dev-status.svg
55+
[dev-deps-url]: https://david-dm.org/ljharb/call-bind#info=devDependencies
56+
[npm-badge-png]: https://nodei.co/npm/call-bind.png?downloads=true&stars=true
57+
[license-image]: https://img.shields.io/npm/l/call-bind.svg
58+
[license-url]: LICENSE
59+
[downloads-image]: https://img.shields.io/npm/dm/call-bind.svg
60+
[downloads-url]: https://npm-stat.com/charts.html?package=call-bind
61+
[codecov-image]: https://codecov.io/gh/ljharb/call-bind/branch/main/graphs/badge.svg
62+
[codecov-url]: https://app.codecov.io/gh/ljharb/call-bind/
63+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bind
64+
[actions-url]: https://github.com/ljharb/call-bind/actions

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"prepublish": "not-in-publish || npm run prepublishOnly",
2323
"prepublishOnly": "safe-publish-latest",
2424
"lint": "eslint --ext=.js,.mjs .",
25+
"postlint": "evalmd README.md",
2526
"pretest": "npm run lint",
2627
"tests-only": "nyc tape 'test/*'",
2728
"test": "npm run tests-only",
@@ -62,6 +63,7 @@
6263
"aud": "^1.1.5",
6364
"auto-changelog": "^2.3.0",
6465
"eslint": "^7.32.0",
66+
"evalmd": "^0.0.19",
6567
"nyc": "^10.3.2",
6668
"safe-publish-latest": "^1.1.5",
6769
"tape": "^5.3.1"

0 commit comments

Comments
 (0)