File manager - Edit - /home2/zetasolve/speedfood.zetasolve.agency/wp-admin/call-bound.tar
Back
tsconfig.json 0000644 00000000211 15225771527 0007262 0 ustar 00 { "extends": "@ljharb/tsconfig", "compilerOptions": { "target": "ESNext", "lib": ["es2024"], }, "exclude": [ "coverage", ], } .github/FUNDING.yml 0000644 00000001105 15225771527 0007733 0 ustar 00 # These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/call-bound community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] README.md 0000644 00000003551 15225771527 0006044 0 ustar 00 # call-bound <sup>[![Version Badge][npm-version-svg]][package-url]</sup> [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][package-url] Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`. ## Getting started ```sh npm install --save call-bound ``` ## Usage/Examples ```js const assert = require('assert'); const callBound = require('call-bound'); const slice = callBound('Array.prototype.slice'); delete Function.prototype.call; delete Function.prototype.bind; delete Array.prototype.slice; assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]); ``` ## Tests Clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/call-bound [npm-version-svg]: https://versionbadg.es/ljharb/call-bound.svg [deps-svg]: https://david-dm.org/ljharb/call-bound.svg [deps-url]: https://david-dm.org/ljharb/call-bound [dev-deps-svg]: https://david-dm.org/ljharb/call-bound/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/call-bound#info=devDependencies [npm-badge-png]: https://nodei.co/npm/call-bound.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/call-bound.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/call-bound.svg [downloads-url]: https://npm-stat.com/charts.html?package=call-bound [codecov-image]: https://codecov.io/gh/ljharb/call-bound/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/ljharb/call-bound/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bound [actions-url]: https://github.com/ljharb/call-bound/actions .eslintrc 0000644 00000000212 15225771527 0006400 0 ustar 00 { "root": true, "extends": "@ljharb", "rules": { "new-cap": [2, { "capIsNewExceptions": [ "GetIntrinsic", ], }], }, } index.d.ts 0000644 00000011053 15225771527 0006462 0 ustar 00 type Intrinsic = typeof globalThis; type IntrinsicName = keyof Intrinsic | `%${keyof Intrinsic}%`; type IntrinsicPath = IntrinsicName | `${StripPercents<IntrinsicName>}.${string}` | `%${StripPercents<IntrinsicName>}.${string}%`; type AllowMissing = boolean; type StripPercents<T extends string> = T extends `%${infer U}%` ? U : T; type BindMethodPrecise<F> = F extends (this: infer This, ...args: infer Args) => infer R ? (obj: This, ...args: Args) => R : F extends { (this: infer This1, ...args: infer Args1): infer R1; (this: infer This2, ...args: infer Args2): infer R2 } ? { (obj: This1, ...args: Args1): R1; (obj: This2, ...args: Args2): R2 } : never // Extract method type from a prototype type GetPrototypeMethod<T extends keyof typeof globalThis, M extends string> = (typeof globalThis)[T] extends { prototype: any } ? M extends keyof (typeof globalThis)[T]['prototype'] ? (typeof globalThis)[T]['prototype'][M] : never : never // Get static property/method type GetStaticMember<T extends keyof typeof globalThis, P extends string> = P extends keyof (typeof globalThis)[T] ? (typeof globalThis)[T][P] : never // Type that maps string path to actual bound function or value with better precision type BoundIntrinsic<S extends string> = S extends `${infer Obj}.prototype.${infer Method}` ? Obj extends keyof typeof globalThis ? BindMethodPrecise<GetPrototypeMethod<Obj, Method & string>> : unknown : S extends `${infer Obj}.${infer Prop}` ? Obj extends keyof typeof globalThis ? GetStaticMember<Obj, Prop & string> : unknown : unknown declare function arraySlice<T>(array: readonly T[], start?: number, end?: number): T[]; declare function arraySlice<T>(array: ArrayLike<T>, start?: number, end?: number): T[]; declare function arraySlice<T>(array: IArguments, start?: number, end?: number): T[]; // Special cases for methods that need explicit typing interface SpecialCases { '%Object.prototype.isPrototypeOf%': (thisArg: {}, obj: unknown) => boolean; '%String.prototype.replace%': { (str: string, searchValue: string | RegExp, replaceValue: string): string; (str: string, searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string }; '%Object.prototype.toString%': (obj: {}) => string; '%Object.prototype.hasOwnProperty%': (obj: {}, v: PropertyKey) => boolean; '%Array.prototype.slice%': typeof arraySlice; '%Array.prototype.map%': <T, U>(array: readonly T[], callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any) => U[]; '%Array.prototype.filter%': <T>(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any) => T[]; '%Array.prototype.indexOf%': <T>(array: readonly T[], searchElement: T, fromIndex?: number) => number; '%Function.prototype.apply%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, args: A) => R; '%Function.prototype.call%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, ...args: A) => R; '%Function.prototype.bind%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, ...args: A) => (...remainingArgs: A) => R; '%Promise.prototype.then%': { <T, R>(promise: Promise<T>, onfulfilled: (value: T) => R | PromiseLike<R>): Promise<R>; <T, R>(promise: Promise<T>, onfulfilled: ((value: T) => R | PromiseLike<R>) | undefined | null, onrejected: (reason: any) => R | PromiseLike<R>): Promise<R>; }; '%RegExp.prototype.test%': (regexp: RegExp, str: string) => boolean; '%RegExp.prototype.exec%': (regexp: RegExp, str: string) => RegExpExecArray | null; '%Error.prototype.toString%': (error: Error) => string; '%TypeError.prototype.toString%': (error: TypeError) => string; '%String.prototype.split%': ( obj: unknown, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number | undefined ) => string[]; } /** * Returns a bound function for a prototype method, or a value for a static property. * * @param name - The name of the intrinsic (e.g. 'Array.prototype.slice') * @param {AllowMissing} [allowMissing] - Whether to allow missing intrinsics (default: false) */ declare function callBound<K extends keyof SpecialCases | StripPercents<keyof SpecialCases>, S extends IntrinsicPath>(name: K, allowMissing?: AllowMissing): SpecialCases[`%${StripPercents<K>}%`]; declare function callBound<K extends keyof SpecialCases | StripPercents<keyof SpecialCases>, S extends IntrinsicPath>(name: S, allowMissing?: AllowMissing): BoundIntrinsic<S>; export = callBound; .nycrc 0000644 00000000213 15225771527 0005674 0 ustar 00 { "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "exclude": [ "coverage", "test" ] } CHANGELOG.md 0000644 00000005500 15225771527 0006372 0 ustar 00 # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [v1.0.4](https://github.com/ljharb/call-bound/compare/v1.0.3...v1.0.4) - 2025-03-03 ### Commits - [types] improve types [`e648922`](https://github.com/ljharb/call-bound/commit/e6489222a9e54f350fbf952ceabe51fd8b6027ff) - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `@types/tape`, `es-value-fixtures`, `for-each`, `has-strict-mode`, `object-inspect` [`a42a5eb`](https://github.com/ljharb/call-bound/commit/a42a5ebe6c1b54fcdc7997c7dc64fdca9e936719) - [Deps] update `call-bind-apply-helpers`, `get-intrinsic` [`f529eac`](https://github.com/ljharb/call-bound/commit/f529eac132404c17156bbc23ab2297a25d0f20b8) ## [v1.0.3](https://github.com/ljharb/call-bound/compare/v1.0.2...v1.0.3) - 2024-12-15 ### Commits - [Refactor] use `call-bind-apply-helpers` instead of `call-bind` [`5e0b134`](https://github.com/ljharb/call-bound/commit/5e0b13496df14fb7d05dae9412f088da8d3f75be) - [Deps] update `get-intrinsic` [`41fc967`](https://github.com/ljharb/call-bound/commit/41fc96732a22c7b7e8f381f93ccc54bb6293be2e) - [readme] fix example [`79a0137`](https://github.com/ljharb/call-bound/commit/79a0137723f7c6d09c9c05452bbf8d5efb5d6e49) - [meta] add `sideEffects` flag [`08b07be`](https://github.com/ljharb/call-bound/commit/08b07be7f1c03f67dc6f3cdaf0906259771859f7) ## [v1.0.2](https://github.com/ljharb/call-bound/compare/v1.0.1...v1.0.2) - 2024-12-10 ### Commits - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `gopd` [`e6a5ffe`](https://github.com/ljharb/call-bound/commit/e6a5ffe849368fe4f74dfd6cdeca1b9baa39e8d5) - [Deps] update `call-bind`, `get-intrinsic` [`2aeb5b5`](https://github.com/ljharb/call-bound/commit/2aeb5b521dc2b2683d1345c753ea1161de2d1c14) - [types] improve return type [`1a0c9fe`](https://github.com/ljharb/call-bound/commit/1a0c9fe3114471e7ca1f57d104e2efe713bb4871) ## v1.0.1 - 2024-12-05 ### Commits - Initial implementation, tests, readme, types [`6d94121`](https://github.com/ljharb/call-bound/commit/6d94121a9243602e506334069f7a03189fe3363d) - Initial commit [`0eae867`](https://github.com/ljharb/call-bound/commit/0eae867334ea025c33e6e91cdecfc9df96680cf9) - npm init [`71b2479`](https://github.com/ljharb/call-bound/commit/71b2479c6723e0b7d91a6b663613067e98b7b275) - Only apps should have lockfiles [`c3754a9`](https://github.com/ljharb/call-bound/commit/c3754a949b7f9132b47e2d18c1729889736741eb) - [actions] skip `npm ls` in node < 10 [`74275a5`](https://github.com/ljharb/call-bound/commit/74275a5186b8caf6309b6b97472bdcb0df4683a8) - [Dev Deps] add missing peer dep [`1354de8`](https://github.com/ljharb/call-bound/commit/1354de8679413e4ae9c523d85f76fa7a5e032d97) test/index.js 0000644 00000004562 15225771527 0007214 0 ustar 00 'use strict'; var test = require('tape'); var callBound = require('../'); /** @template {true} T @template U @typedef {T extends U ? T : never} AssertType */ test('callBound', function (t) { // static primitive t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself'); t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself'); // static non-function object t.equal(callBound('Array.prototype'), Array.prototype, 'Array.prototype yields itself'); t.equal(callBound('%Array.prototype%'), Array.prototype, '%Array.prototype% yields itself'); t.equal(callBound('Array.constructor'), Array.constructor, 'Array.constructor yields itself'); t.equal(callBound('%Array.constructor%'), Array.constructor, '%Array.constructor% yields itself'); // static function t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself'); t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself'); // prototype primitive t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself'); t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself'); var x = callBound('Object.prototype.toString'); var y = callBound('%Object.prototype.toString%'); // prototype function t.notEqual(x, Object.prototype.toString, 'Object.prototype.toString does not yield itself'); t.notEqual(y, Object.prototype.toString, '%Object.prototype.toString% does not yield itself'); t.equal(x(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original'); t.equal(y(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original'); t['throws']( // @ts-expect-error function () { callBound('does not exist'); }, SyntaxError, 'nonexistent intrinsic throws' ); t['throws']( // @ts-expect-error function () { callBound('does not exist', true); }, SyntaxError, 'allowMissing arg still throws for unknown intrinsic' ); t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) { st['throws']( function () { callBound('WeakRef'); }, TypeError, 'real but absent intrinsic throws' ); st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception'); st.end(); }); t.end(); }); package.json 0000644 00000004713 15225771527 0007054 0 ustar 00 { "name": "call-bound", "version": "1.0.4", "description": "Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "sideEffects": false, "scripts": { "prepack": "npmignore --auto --commentLines=auto", "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "prelint": "evalmd README.md", "lint": "eslint --ext=.js,.mjs .", "postlint": "tsc -p . && attw -P", "pretest": "npm run lint", "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "npx npm@'>=10.2' audit --production", "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)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/ljharb/call-bound.git" }, "keywords": [ "javascript", "ecmascript", "es", "js", "callbind", "callbound", "call", "bind", "bound", "call-bind", "call-bound", "function", "es-abstract" ], "author": "Jordan Harband <ljharb@gmail.com>", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/ljharb/call-bound/issues" }, "homepage": "https://github.com/ljharb/call-bound#readme", "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" }, "devDependencies": { "@arethetypeswrong/cli": "^0.17.4", "@ljharb/eslint-config": "^21.1.1", "@ljharb/tsconfig": "^0.3.0", "@types/call-bind": "^1.0.5", "@types/get-intrinsic": "^1.2.3", "@types/tape": "^5.8.1", "auto-changelog": "^2.5.0", "encoding": "^0.1.13", "es-value-fixtures": "^1.7.1", "eslint": "=8.8.0", "evalmd": "^0.0.19", "for-each": "^0.3.5", "gopd": "^1.2.0", "has-strict-mode": "^1.1.0", "in-publish": "^2.0.1", "npmignore": "^0.3.1", "nyc": "^10.3.2", "object-inspect": "^1.13.4", "safe-publish-latest": "^2.0.0", "tape": "^5.9.0", "typescript": "next" }, "testling": { "files": "test/index.js" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] }, "engines": { "node": ">= 0.4" } } LICENSE 0000644 00000002057 15225771527 0005572 0 ustar 00 MIT License Copyright (c) 2024 Jordan Harband 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. index.js 0000644 00000001257 15225771527 0006233 0 ustar 00 'use strict'; var GetIntrinsic = require('get-intrinsic'); var callBindBasic = require('call-bind-apply-helpers'); /** @type {(thisArg: string, searchString: string, position?: number) => number} */ var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]); /** @type {import('.')} */ module.exports = function callBoundIntrinsic(name, allowMissing) { /* eslint no-extra-parens: 0 */ var intrinsic = /** @type {(this: unknown, ...args: unknown[]) => unknown} */ (GetIntrinsic(name, !!allowMissing)); if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { return callBindBasic(/** @type {const} */ ([intrinsic])); } return intrinsic; };
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings