Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Nov 14, 2023
1 parent b00e780 commit faf9eff
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 129 deletions.
4 changes: 2 additions & 2 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ graph LR;
glob-->minimatch;
glob-->minipass;
glob-->path-scurry;
has-->function-bind;
hasown-->function-bind;
hosted-git-info-->lru-cache;
http-proxy-agent-->agent-base;
http-proxy-agent-->debug;
Expand All @@ -334,7 +334,7 @@ graph LR;
init-package-json-->validate-npm-package-license;
init-package-json-->validate-npm-package-name;
is-cidr-->cidr-regex;
is-core-module-->has;
is-core-module-->hasown;
isaacs-cliui-->string-width-cjs;
isaacs-cliui-->string-width;
isaacs-cliui-->strip-ansi-cjs;
Expand Down
2 changes: 1 addition & 1 deletion node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
!/glob
!/graceful-fs
!/has-unicode
!/has
!/hasown
!/hosted-git-info
!/http-cache-semantics
!/http-proxy-agent
Expand Down
56 changes: 44 additions & 12 deletions node_modules/function-bind/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,75 @@
/* eslint no-invalid-this: 1 */

var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
var slice = Array.prototype.slice;
var toStr = Object.prototype.toString;
var max = Math.max;
var funcType = '[object Function]';

var concatty = function concatty(a, b) {
var arr = [];

for (var i = 0; i < a.length; i += 1) {
arr[i] = a[i];
}
for (var j = 0; j < b.length; j += 1) {
arr[j + a.length] = b[j];
}

return arr;
};

var slicy = function slicy(arrLike, offset) {
var arr = [];
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
arr[j] = arrLike[i];
}
return arr;
};

var joiny = function (arr, joiner) {
var str = '';
for (var i = 0; i < arr.length; i += 1) {
str += arr[i];
if (i + 1 < arr.length) {
str += joiner;
}
}
return str;
};

module.exports = function bind(that) {
var target = this;
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
if (typeof target !== 'function' || toStr.apply(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slice.call(arguments, 1);
var args = slicy(arguments, 1);

var bound;
var binder = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
concatty(args, arguments)
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
return target.apply(
that,
concatty(args, arguments)
);

};

var boundLength = Math.max(0, target.length - args.length);
var boundLength = max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push('$' + i);
boundArgs[i] = '$' + i;
}

bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);

if (target.prototype) {
var Empty = function Empty() {};
Expand Down
52 changes: 38 additions & 14 deletions node_modules/function-bind/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "function-bind",
"version": "1.1.1",
"version": "1.1.2",
"description": "Implementation of Function.prototype.bind",
"keywords": [
"function",
Expand All @@ -9,7 +9,13 @@
"es5"
],
"author": "Raynos <[email protected]>",
"repository": "git://github.com/Raynos/function-bind.git",
"repository": {
"type": "git",
"url": "https://github.com/Raynos/function-bind.git"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"main": "index",
"homepage": "https://github.com/Raynos/function-bind",
"contributors": [
Expand All @@ -25,24 +31,29 @@
"url": "https://github.com/Raynos/function-bind/issues",
"email": "[email protected]"
},
"dependencies": {},
"devDependencies": {
"@ljharb/eslint-config": "^12.2.1",
"covert": "^1.1.0",
"eslint": "^4.5.0",
"jscs": "^3.0.7",
"tape": "^4.8.0"
"@ljharb/eslint-config": "^21.1.0",
"aud": "^2.0.3",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.7.1"
},
"license": "MIT",
"scripts": {
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepack": "npmignore --auto --commentLines=autogenerated",
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "npm run coverage -- --quiet",
"tests-only": "node test",
"coverage": "covert test/*.js",
"lint": "npm run jscs && npm run eslint",
"jscs": "jscs *.js */*.js",
"eslint": "eslint *.js */*.js"
"posttest": "aud --production",
"tests-only": "nyc tape 'test/**/*.js'",
"lint": "eslint --ext=js,mjs .",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"testling": {
"files": "test/index.js",
Expand All @@ -59,5 +70,18 @@
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}
22 changes: 0 additions & 22 deletions node_modules/has/LICENSE-MIT

This file was deleted.

48 changes: 0 additions & 48 deletions node_modules/has/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions node_modules/has/src/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions node_modules/has/test/index.js

This file was deleted.

21 changes: 21 additions & 0 deletions node_modules/hasown/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Jordan Harband and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions node_modules/hasown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var call = Function.prototype.call;
var $hasOwn = Object.prototype.hasOwnProperty;
var bind = require('function-bind');

/** @type {(o: {}, p: PropertyKey) => p is keyof o} */
module.exports = bind.call(call, $hasOwn);
Loading

0 comments on commit faf9eff

Please sign in to comment.