step-node-agent 3.26.4 → 3.26.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/call-bind/CHANGELOG.md +13 -0
- package/node_modules/call-bind/index.js +6 -17
- package/node_modules/call-bind/package.json +14 -16
- package/node_modules/call-bind/test/index.js +4 -10
- package/node_modules/call-bind-apply-helpers/.eslintrc +16 -0
- package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/node_modules/call-bind-apply-helpers/CHANGELOG.md +23 -0
- package/node_modules/{has-proto → call-bind-apply-helpers}/LICENSE +1 -1
- package/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/node_modules/call-bind-apply-helpers/index.d.ts +46 -0
- package/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/node_modules/{has-proto → dunder-proto}/.github/FUNDING.yml +1 -1
- package/node_modules/dunder-proto/.nycrc +13 -0
- package/node_modules/dunder-proto/CHANGELOG.md +15 -0
- package/node_modules/dunder-proto/LICENSE +21 -0
- package/node_modules/dunder-proto/README.md +54 -0
- package/node_modules/dunder-proto/get.d.ts +5 -0
- package/node_modules/dunder-proto/get.js +23 -0
- package/node_modules/{has-proto → dunder-proto}/package.json +34 -36
- package/node_modules/dunder-proto/set.d.ts +5 -0
- package/node_modules/dunder-proto/set.js +29 -0
- package/node_modules/dunder-proto/test/get.js +34 -0
- package/node_modules/dunder-proto/test/index.js +4 -0
- package/node_modules/dunder-proto/test/set.js +41 -0
- package/node_modules/dunder-proto/tsconfig.json +9 -0
- package/node_modules/es-define-property/CHANGELOG.md +14 -0
- package/node_modules/es-define-property/index.js +1 -3
- package/node_modules/es-define-property/package.json +12 -12
- package/node_modules/es-define-property/test/index.js +1 -0
- package/node_modules/es-define-property/tsconfig.json +2 -42
- package/node_modules/express/History.md +10 -1
- package/node_modules/express/package.json +6 -2
- package/node_modules/get-intrinsic/CHANGELOG.md +18 -0
- package/node_modules/get-intrinsic/index.js +20 -20
- package/node_modules/get-intrinsic/package.json +21 -19
- package/node_modules/get-intrinsic/test/GetIntrinsic.js +2 -2
- package/node_modules/gopd/CHANGELOG.md +20 -0
- package/node_modules/gopd/gOPD.d.ts +1 -0
- package/node_modules/gopd/gOPD.js +4 -0
- package/node_modules/gopd/index.d.ts +5 -0
- package/node_modules/gopd/index.js +2 -3
- package/node_modules/gopd/package.json +16 -10
- package/node_modules/gopd/test/index.js +2 -1
- package/node_modules/gopd/tsconfig.json +9 -0
- package/node_modules/has-symbols/CHANGELOG.md +16 -0
- package/node_modules/has-symbols/index.d.ts +3 -0
- package/node_modules/has-symbols/index.js +1 -0
- package/node_modules/has-symbols/package.json +19 -9
- package/node_modules/has-symbols/shams.d.ts +3 -0
- package/node_modules/has-symbols/shams.js +5 -2
- package/node_modules/has-symbols/test/shams/core-js.js +1 -0
- package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +1 -0
- package/node_modules/has-symbols/test/tests.js +4 -2
- package/node_modules/has-symbols/tsconfig.json +10 -0
- package/node_modules/path-to-regexp/index.js +13 -3
- package/node_modules/path-to-regexp/package.json +1 -1
- package/node_modules/psl/README.md +7 -14
- package/node_modules/psl/SECURITY.md +13 -0
- package/node_modules/psl/data/rules.js +536 -529
- package/node_modules/psl/dist/psl.cjs +1 -1
- package/node_modules/psl/dist/psl.mjs +726 -715
- package/node_modules/psl/dist/psl.umd.cjs +1 -1
- package/node_modules/psl/index.js +52 -74
- package/node_modules/psl/package.json +10 -7
- package/package.json +1 -1
- package/node_modules/has-proto/CHANGELOG.md +0 -38
- package/node_modules/has-proto/README.md +0 -38
- package/node_modules/has-proto/index.d.ts +0 -3
- package/node_modules/has-proto/index.js +0 -15
- package/node_modules/has-proto/test/index.js +0 -19
- package/node_modules/has-proto/tsconfig.json +0 -49
- /package/node_modules/{has-proto → dunder-proto}/.eslintrc +0 -0
|
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v1.0.8](https://github.com/ljharb/call-bind/compare/v1.0.7...v1.0.8) - 2024-12-05
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [Refactor] extract out some helpers and avoid get-intrinsic usage [`407fd5e`](https://github.com/ljharb/call-bind/commit/407fd5eec34ec58394522a6ce3badfa4788fd5ae)
|
|
13
|
+
- [Refactor] replace code with extracted `call-bind-apply-helpers` [`81018fb`](https://github.com/ljharb/call-bind/commit/81018fb78902ff5acbc6c09300780e97f0db6a34)
|
|
14
|
+
- [Tests] use `set-function-length/env` [`0fc311d`](https://github.com/ljharb/call-bind/commit/0fc311de0e115cfa6b02969b23a42ad45aadf224)
|
|
15
|
+
- [actions] split out node 10-20, and 20+ [`77a0cad`](https://github.com/ljharb/call-bind/commit/77a0cad75f83f5b8050dc13baef4fa2cff537fa3)
|
|
16
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `es-value-fixtures`, `gopd`, `object-inspect`, `tape` [`a145d10`](https://github.com/ljharb/call-bind/commit/a145d10fe847f350e11094f8541848b028ee8c91)
|
|
17
|
+
- [Tests] replace `aud` with `npm audit` [`30ca3dd`](https://github.com/ljharb/call-bind/commit/30ca3dd7234648eb029947477d06b17879e10727)
|
|
18
|
+
- [Deps] update `set-function-length` [`57c79a3`](https://github.com/ljharb/call-bind/commit/57c79a3666022ea797cc2a4a3b43fe089bc97d1b)
|
|
19
|
+
- [Dev Deps] add missing peer dep [`601cfa5`](https://github.com/ljharb/call-bind/commit/601cfa5540066b6206039ceb9496cecbd134ff7b)
|
|
20
|
+
|
|
8
21
|
## [v1.0.7](https://github.com/ljharb/call-bind/compare/v1.0.6...v1.0.7) - 2024-02-12
|
|
9
22
|
|
|
10
23
|
### Commits
|
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var bind = require('function-bind');
|
|
4
|
-
var GetIntrinsic = require('get-intrinsic');
|
|
5
3
|
var setFunctionLength = require('set-function-length');
|
|
6
4
|
|
|
7
|
-
var $TypeError = require('es-errors/type');
|
|
8
|
-
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
9
|
-
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
10
|
-
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
|
11
|
-
|
|
12
5
|
var $defineProperty = require('es-define-property');
|
|
13
|
-
|
|
6
|
+
|
|
7
|
+
var callBindBasic = require('call-bind-apply-helpers');
|
|
8
|
+
var applyBind = require('call-bind-apply-helpers/applyBind');
|
|
14
9
|
|
|
15
10
|
module.exports = function callBind(originalFunction) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
var func = $reflectApply(bind, $call, arguments);
|
|
11
|
+
var func = callBindBasic(arguments);
|
|
12
|
+
var adjustedLength = originalFunction.length - (arguments.length - 1);
|
|
20
13
|
return setFunctionLength(
|
|
21
14
|
func,
|
|
22
|
-
1 +
|
|
15
|
+
1 + (adjustedLength > 0 ? adjustedLength : 0),
|
|
23
16
|
true
|
|
24
17
|
);
|
|
25
18
|
};
|
|
26
19
|
|
|
27
|
-
var applyBind = function applyBind() {
|
|
28
|
-
return $reflectApply(bind, $apply, arguments);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
20
|
if ($defineProperty) {
|
|
32
21
|
$defineProperty(module.exports, 'apply', { value: applyBind });
|
|
33
22
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "call-bind",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Robustly `.call.bind()` a function",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"pretest": "npm run lint",
|
|
18
18
|
"tests-only": "nyc tape 'test/**/*.js'",
|
|
19
19
|
"test": "npm run tests-only",
|
|
20
|
-
"posttest": "
|
|
20
|
+
"posttest": "npx npm@'>=10.2' audit --production",
|
|
21
21
|
"version": "auto-changelog && git add CHANGELOG.md",
|
|
22
22
|
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
23
23
|
},
|
|
@@ -49,29 +49,27 @@
|
|
|
49
49
|
"url": "https://github.com/ljharb/call-bind/issues"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/ljharb/call-bind#readme",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"call-bind-apply-helpers": "^1.0.0",
|
|
54
|
+
"es-define-property": "^1.0.0",
|
|
55
|
+
"get-intrinsic": "^1.2.4",
|
|
56
|
+
"set-function-length": "^1.2.2"
|
|
57
|
+
},
|
|
52
58
|
"devDependencies": {
|
|
53
|
-
"@ljharb/eslint-config": "^21.1.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"es-value-fixtures": "^1.
|
|
59
|
+
"@ljharb/eslint-config": "^21.1.1",
|
|
60
|
+
"auto-changelog": "^2.5.0",
|
|
61
|
+
"encoding": "^0.1.13",
|
|
62
|
+
"es-value-fixtures": "^1.5.0",
|
|
57
63
|
"eslint": "=8.8.0",
|
|
58
64
|
"evalmd": "^0.0.19",
|
|
59
65
|
"for-each": "^0.3.3",
|
|
60
|
-
"gopd": "^1.0.1",
|
|
61
66
|
"has-strict-mode": "^1.0.1",
|
|
62
67
|
"in-publish": "^2.0.1",
|
|
63
68
|
"npmignore": "^0.3.1",
|
|
64
69
|
"nyc": "^10.3.2",
|
|
65
|
-
"object-inspect": "^1.13.
|
|
70
|
+
"object-inspect": "^1.13.3",
|
|
66
71
|
"safe-publish-latest": "^2.0.0",
|
|
67
|
-
"tape": "^5.
|
|
68
|
-
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"es-define-property": "^1.0.0",
|
|
71
|
-
"es-errors": "^1.3.0",
|
|
72
|
-
"function-bind": "^1.1.2",
|
|
73
|
-
"get-intrinsic": "^1.2.4",
|
|
74
|
-
"set-function-length": "^1.2.1"
|
|
72
|
+
"tape": "^5.9.0"
|
|
75
73
|
},
|
|
76
74
|
"testling": {
|
|
77
75
|
"files": "test/index.js"
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var callBind = require('../');
|
|
4
|
-
var bind = require('function-bind');
|
|
5
|
-
var gOPD = require('gopd');
|
|
6
4
|
var hasStrictMode = require('has-strict-mode')();
|
|
7
5
|
var forEach = require('for-each');
|
|
8
6
|
var inspect = require('object-inspect');
|
|
@@ -14,11 +12,7 @@ var test = require('tape');
|
|
|
14
12
|
* older engines have length nonconfigurable
|
|
15
13
|
* in io.js v3, it is configurable except on bound functions, hence the .bind()
|
|
16
14
|
*/
|
|
17
|
-
var
|
|
18
|
-
gOPD
|
|
19
|
-
&& Object.getOwnPropertyDescriptor
|
|
20
|
-
&& Object.getOwnPropertyDescriptor(bind.call(function () {}), 'length').configurable
|
|
21
|
-
);
|
|
15
|
+
var boundFnsHaveConfigurableLengths = require('set-function-length/env').boundFnsHaveConfigurableLengths;
|
|
22
16
|
|
|
23
17
|
test('callBind', function (t) {
|
|
24
18
|
forEach(v.nonFunctions, function (nonFunction) {
|
|
@@ -40,19 +34,19 @@ test('callBind', function (t) {
|
|
|
40
34
|
t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args');
|
|
41
35
|
|
|
42
36
|
var bound = callBind(func);
|
|
43
|
-
t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !
|
|
37
|
+
t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !boundFnsHaveConfigurableLengths });
|
|
44
38
|
t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with too few args');
|
|
45
39
|
t.deepEqual(bound(1, 2), [hasStrictMode ? 1 : Object(1), 2, undefined], 'bound func with right args');
|
|
46
40
|
t.deepEqual(bound(1, 2, 3), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with too many args');
|
|
47
41
|
|
|
48
42
|
var boundR = callBind(func, sentinel);
|
|
49
|
-
t.equal(boundR.length, func.length, 'function length is preserved', { skip: !
|
|
43
|
+
t.equal(boundR.length, func.length, 'function length is preserved', { skip: !boundFnsHaveConfigurableLengths });
|
|
50
44
|
t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args');
|
|
51
45
|
t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args');
|
|
52
46
|
t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args');
|
|
53
47
|
|
|
54
48
|
var boundArg = callBind(func, sentinel, 1);
|
|
55
|
-
t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !
|
|
49
|
+
t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !boundFnsHaveConfigurableLengths });
|
|
56
50
|
t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args');
|
|
57
51
|
t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg');
|
|
58
52
|
t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: [ljharb]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: npm/call-bind-apply-helpers
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [v1.0.1](https://github.com/ljharb/call-bind-apply-helpers/compare/v1.0.0...v1.0.1) - 2024-12-08
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [types] `reflectApply`: fix types [`4efc396`](https://github.com/ljharb/call-bind-apply-helpers/commit/4efc3965351a4f02cc55e836fa391d3d11ef2ef8)
|
|
13
|
+
- [Fix] `reflectApply`: oops, Reflect is not a function [`83cc739`](https://github.com/ljharb/call-bind-apply-helpers/commit/83cc7395de6b79b7730bdf092f1436f0b1263c75)
|
|
14
|
+
- [Dev Deps] update `@arethetypeswrong/cli` [`80bd5d3`](https://github.com/ljharb/call-bind-apply-helpers/commit/80bd5d3ae58b4f6b6995ce439dd5a1bcb178a940)
|
|
15
|
+
|
|
16
|
+
## v1.0.0 - 2024-12-05
|
|
17
|
+
|
|
18
|
+
### Commits
|
|
19
|
+
|
|
20
|
+
- Initial implementation, tests, readme [`7879629`](https://github.com/ljharb/call-bind-apply-helpers/commit/78796290f9b7430c9934d6f33d94ae9bc89fce04)
|
|
21
|
+
- Initial commit [`3f1dc16`](https://github.com/ljharb/call-bind-apply-helpers/commit/3f1dc164afc43285631b114a5f9dd9137b2b952f)
|
|
22
|
+
- npm init [`081df04`](https://github.com/ljharb/call-bind-apply-helpers/commit/081df048c312fcee400922026f6e97281200a603)
|
|
23
|
+
- Only apps should have lockfiles [`5b9ca0f`](https://github.com/ljharb/call-bind-apply-helpers/commit/5b9ca0fe8101ebfaf309c549caac4e0a017ed930)
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export = Reflect.apply;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bind = require('function-bind');
|
|
4
|
+
|
|
5
|
+
var $apply = require('./functionApply');
|
|
6
|
+
var $call = require('./functionCall');
|
|
7
|
+
var $reflectApply = require('./reflectApply');
|
|
8
|
+
|
|
9
|
+
/** @type {import('./actualApply')} */
|
|
10
|
+
module.exports = $reflectApply || bind.call($call, $apply);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import actualApply from './actualApply';
|
|
2
|
+
|
|
3
|
+
type TupleSplitHead<T extends any[], N extends number> = T['length'] extends N
|
|
4
|
+
? T
|
|
5
|
+
: T extends [...infer R, any]
|
|
6
|
+
? TupleSplitHead<R, N>
|
|
7
|
+
: never
|
|
8
|
+
|
|
9
|
+
type TupleSplitTail<T, N extends number, O extends any[] = []> = O['length'] extends N
|
|
10
|
+
? T
|
|
11
|
+
: T extends [infer F, ...infer R]
|
|
12
|
+
? TupleSplitTail<[...R], N, [...O, F]>
|
|
13
|
+
: never
|
|
14
|
+
|
|
15
|
+
type TupleSplit<T extends any[], N extends number> = [TupleSplitHead<T, N>, TupleSplitTail<T, N>]
|
|
16
|
+
|
|
17
|
+
declare function applyBind(...args: TupleSplit<Parameters<typeof actualApply>, 2>[1]): ReturnType<typeof actualApply>;
|
|
18
|
+
|
|
19
|
+
export = applyBind;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bind = require('function-bind');
|
|
4
|
+
var $apply = require('./functionApply');
|
|
5
|
+
var actualApply = require('./actualApply');
|
|
6
|
+
|
|
7
|
+
/** @type {import('./applyBind')} */
|
|
8
|
+
module.exports = function applyBind() {
|
|
9
|
+
return actualApply(bind, $apply, arguments);
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export = Function.prototype.apply;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export = Function.prototype.call;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type RemoveFromTuple<
|
|
2
|
+
Tuple extends unknown[],
|
|
3
|
+
RemoveCount extends number,
|
|
4
|
+
Index extends 1[] = []
|
|
5
|
+
> = Index["length"] extends RemoveCount
|
|
6
|
+
? Tuple
|
|
7
|
+
: Tuple extends [first: unknown, ...infer Rest]
|
|
8
|
+
? RemoveFromTuple<Rest, RemoveCount, [...Index, 1]>
|
|
9
|
+
: Tuple;
|
|
10
|
+
|
|
11
|
+
type ConcatTuples<
|
|
12
|
+
Prefix extends unknown[],
|
|
13
|
+
Suffix extends unknown[]
|
|
14
|
+
> = [...Prefix, ...Suffix];
|
|
15
|
+
|
|
16
|
+
type ReplaceThis<T, NewThis> = T extends (this: infer OldThis, ...args: infer A) => infer R
|
|
17
|
+
? (this: NewThis, ...args: A) => R
|
|
18
|
+
: never;
|
|
19
|
+
|
|
20
|
+
type BindFunction<
|
|
21
|
+
TThis,
|
|
22
|
+
T extends (this: TThis, ...args: any[]) => any, // Allow specific types to propagate
|
|
23
|
+
TBoundArgs extends unknown[],
|
|
24
|
+
ReceiverBound extends boolean
|
|
25
|
+
> = ReceiverBound extends true
|
|
26
|
+
? (...args: RemoveFromTuple<Parameters<T>, TBoundArgs["length"] & number>) => ReturnType<ReplaceThis<T, TThis>>
|
|
27
|
+
: (...args: ConcatTuples<[TThis], RemoveFromTuple<Parameters<T>, TBoundArgs["length"] & number>>) => ReturnType<T>;
|
|
28
|
+
|
|
29
|
+
declare function callBind<
|
|
30
|
+
TThis,
|
|
31
|
+
T extends (this: TThis, ...args: any[]) => any,
|
|
32
|
+
TBoundArgs extends Partial<Parameters<T>>
|
|
33
|
+
>(
|
|
34
|
+
args: [fn: T, thisArg: TThis, ...boundArgs: TBoundArgs]
|
|
35
|
+
): BindFunction<TThis, T, TBoundArgs, true>;
|
|
36
|
+
|
|
37
|
+
declare function callBind<
|
|
38
|
+
TThis,
|
|
39
|
+
T extends (this: TThis, ...args: any[]) => any,
|
|
40
|
+
TBoundArgs extends Partial<Parameters<T>>
|
|
41
|
+
>(
|
|
42
|
+
args: [fn: T, ...boundArgs: TBoundArgs]
|
|
43
|
+
): BindFunction<TThis, T, TBoundArgs, false>;
|
|
44
|
+
|
|
45
|
+
export as namespace callBind;
|
|
46
|
+
export = callBind;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bind = require('function-bind');
|
|
4
|
+
var $TypeError = require('es-errors/type');
|
|
5
|
+
|
|
6
|
+
var $call = require('./functionCall');
|
|
7
|
+
var $actualApply = require('./actualApply');
|
|
8
|
+
|
|
9
|
+
/** @type {import('.')} */
|
|
10
|
+
module.exports = function callBindBasic(args) {
|
|
11
|
+
if (args.length < 1 || typeof args[0] !== 'function') {
|
|
12
|
+
throw new $TypeError('a function is required');
|
|
13
|
+
}
|
|
14
|
+
return $actualApply(bind, $call, args);
|
|
15
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "call-bind-apply-helpers",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Helper functions around Function call/apply/bind, for use in `call-bind`",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./actualApply": "./actualApply.js",
|
|
9
|
+
"./applyBind": "./applyBind.js",
|
|
10
|
+
"./functionApply": "./functionApply.js",
|
|
11
|
+
"./functionCall": "./functionCall.js",
|
|
12
|
+
"./reflectApply": "./reflectApply.js",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prepack": "npmignore --auto --commentLines=auto",
|
|
17
|
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
|
18
|
+
"prepublishOnly": "safe-publish-latest",
|
|
19
|
+
"prelint": "evalmd README.md",
|
|
20
|
+
"lint": "eslint --ext=.js,.mjs .",
|
|
21
|
+
"postlint": "tsc -p . && attw -P",
|
|
22
|
+
"pretest": "npm run lint",
|
|
23
|
+
"tests-only": "nyc tape 'test/**/*.js'",
|
|
24
|
+
"test": "npm run tests-only",
|
|
25
|
+
"posttest": "npx npm@'>=10.2' audit --production",
|
|
26
|
+
"version": "auto-changelog && git add CHANGELOG.md",
|
|
27
|
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/ljharb/call-bind-apply-helpers.git"
|
|
32
|
+
},
|
|
33
|
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/ljharb/call-bind-apply-helpers/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/ljharb/call-bind-apply-helpers#readme",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"es-errors": "^1.3.0",
|
|
41
|
+
"function-bind": "^1.1.2"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@arethetypeswrong/cli": "^0.17.1",
|
|
45
|
+
"@ljharb/eslint-config": "^21.1.1",
|
|
46
|
+
"@ljharb/tsconfig": "^0.2.2",
|
|
47
|
+
"@types/for-each": "^0.3.3",
|
|
48
|
+
"@types/function-bind": "^1.1.10",
|
|
49
|
+
"@types/object-inspect": "^1.13.0",
|
|
50
|
+
"@types/tape": "^5.6.5",
|
|
51
|
+
"auto-changelog": "^2.5.0",
|
|
52
|
+
"encoding": "^0.1.13",
|
|
53
|
+
"es-value-fixtures": "^1.5.0",
|
|
54
|
+
"eslint": "=8.8.0",
|
|
55
|
+
"evalmd": "^0.0.19",
|
|
56
|
+
"for-each": "^0.3.3",
|
|
57
|
+
"has-strict-mode": "^1.0.1",
|
|
58
|
+
"in-publish": "^2.0.1",
|
|
59
|
+
"npmignore": "^0.3.1",
|
|
60
|
+
"nyc": "^10.3.2",
|
|
61
|
+
"object-inspect": "^1.13.3",
|
|
62
|
+
"safe-publish-latest": "^2.0.0",
|
|
63
|
+
"tape": "^5.9.0",
|
|
64
|
+
"typescript": "next"
|
|
65
|
+
},
|
|
66
|
+
"testling": {
|
|
67
|
+
"files": "test/index.js"
|
|
68
|
+
},
|
|
69
|
+
"auto-changelog": {
|
|
70
|
+
"output": "CHANGELOG.md",
|
|
71
|
+
"template": "keepachangelog",
|
|
72
|
+
"unreleased": false,
|
|
73
|
+
"commitLimit": false,
|
|
74
|
+
"backfillLimit": false,
|
|
75
|
+
"hideCredit": true
|
|
76
|
+
},
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"ignore": [
|
|
79
|
+
".github/workflows"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">= 0.4"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var callBind = require('../');
|
|
4
|
+
var hasStrictMode = require('has-strict-mode')();
|
|
5
|
+
var forEach = require('for-each');
|
|
6
|
+
var inspect = require('object-inspect');
|
|
7
|
+
var v = require('es-value-fixtures');
|
|
8
|
+
|
|
9
|
+
var test = require('tape');
|
|
10
|
+
|
|
11
|
+
test('callBindBasic', function (t) {
|
|
12
|
+
forEach(v.nonFunctions, function (nonFunction) {
|
|
13
|
+
t['throws'](
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
function () { callBind([nonFunction]); },
|
|
16
|
+
TypeError,
|
|
17
|
+
inspect(nonFunction) + ' is not a function'
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var sentinel = { sentinel: true };
|
|
22
|
+
/** @type {<T>(this: T, a: number, b: number) => [T | undefined, number, number]} */
|
|
23
|
+
var func = function (a, b) {
|
|
24
|
+
// eslint-disable-next-line no-invalid-this
|
|
25
|
+
return [!hasStrictMode && this === global ? undefined : this, a, b];
|
|
26
|
+
};
|
|
27
|
+
t.equal(func.length, 2, 'original function length is 2');
|
|
28
|
+
|
|
29
|
+
/** type {(thisArg: unknown, a: number, b: number) => [unknown, number, number]} */
|
|
30
|
+
var bound = callBind([func]);
|
|
31
|
+
/** type {((a: number, b: number) => [sentinel, typeof a, typeof b])} */
|
|
32
|
+
var boundR = callBind([func, sentinel]);
|
|
33
|
+
/** type {((b: number) => [sentinel, number, typeof b])} */
|
|
34
|
+
var boundArg = callBind([func, sentinel, 1]);
|
|
35
|
+
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with no args');
|
|
38
|
+
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args');
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
t.deepEqual(bound(1, 2), [hasStrictMode ? 1 : Object(1), 2, undefined], 'bound func too few args');
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args');
|
|
45
|
+
// @ts-expect-error
|
|
46
|
+
t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args');
|
|
47
|
+
|
|
48
|
+
t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args');
|
|
49
|
+
t.deepEqual(bound(1, 2, 3), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with right args');
|
|
50
|
+
t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args');
|
|
51
|
+
t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg');
|
|
52
|
+
|
|
53
|
+
// @ts-expect-error
|
|
54
|
+
t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args');
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
t.deepEqual(bound(1, 2, 3, 4), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with too many args');
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args');
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args');
|
|
61
|
+
|
|
62
|
+
t.end();
|
|
63
|
+
});
|
|
@@ -4,7 +4,7 @@ github: [ljharb]
|
|
|
4
4
|
patreon: # Replace with a single Patreon username
|
|
5
5
|
open_collective: # Replace with a single Open Collective username
|
|
6
6
|
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
-
tidelift: npm/
|
|
7
|
+
tidelift: npm/dunder-proto
|
|
8
8
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
9
|
liberapay: # Replace with a single Liberapay username
|
|
10
10
|
issuehunt: # Replace with a single IssueHunt username
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## v1.0.0 - 2024-12-06
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- Initial implementation, tests, readme, types [`a5b74b0`](https://github.com/es-shims/dunder-proto/commit/a5b74b0082f5270cb0905cd9a2e533cee7498373)
|
|
13
|
+
- Initial commit [`73fb5a3`](https://github.com/es-shims/dunder-proto/commit/73fb5a353b51ac2ab00c9fdeb0114daffd4c07a8)
|
|
14
|
+
- npm init [`80152dc`](https://github.com/es-shims/dunder-proto/commit/80152dc98155da4eb046d9f67a87ed96e8280a1d)
|
|
15
|
+
- Only apps should have lockfiles [`03e6660`](https://github.com/es-shims/dunder-proto/commit/03e6660a1d70dc401f3e217a031475ec537243dd)
|