pax_global_header 0000666 0000000 0000000 00000000064 14761365700 0014523 g ustar 00root root 0000000 0000000 52 comment=75d922c1f92a3de1ff9ab94453f45b5f64b50041
ljharb-call-bound-a9e667e/ 0000775 0000000 0000000 00000000000 14761365700 0015433 5 ustar 00root root 0000000 0000000 ljharb-call-bound-a9e667e/.eslintrc 0000664 0000000 0000000 00000000212 14761365700 0017252 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"rules": {
"new-cap": [2, {
"capIsNewExceptions": [
"GetIntrinsic",
],
}],
},
}
ljharb-call-bound-a9e667e/.github/ 0000775 0000000 0000000 00000000000 14761365700 0016773 5 ustar 00root root 0000000 0000000 ljharb-call-bound-a9e667e/.github/FUNDING.yml 0000664 0000000 0000000 00000001105 14761365700 0020605 0 ustar 00root root 0000000 0000000 # 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']
ljharb-call-bound-a9e667e/.github/workflows/ 0000775 0000000 0000000 00000000000 14761365700 0021030 5 ustar 00root root 0000000 0000000 ljharb-call-bound-a9e667e/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000526 14761365700 0023611 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '< 10'
type: minors
command: npm run tests-only
skip-ls-check: true
node:
name: 'node < 10'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
ljharb-call-bound-a9e667e/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000206 14761365700 0024162 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
ljharb-call-bound-a9e667e/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000372 14761365700 0023451 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js 10 - 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10 < 20'
type: minors
command: npm run tests-only
ljharb-call-bound-a9e667e/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000363 14761365700 0024342 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 20'
type: minors
command: npm run tests-only
ljharb-call-bound-a9e667e/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14761365700 0023020 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
uses: ljharb/actions/.github/workflows/rebase.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
ljharb-call-bound-a9e667e/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 14761365700 0025445 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
ljharb-call-bound-a9e667e/.gitignore 0000664 0000000 0000000 00000003251 14761365700 0017424 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
.npmignore
ljharb-call-bound-a9e667e/.npmrc 0000664 0000000 0000000 00000000067 14761365700 0016556 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
ljharb-call-bound-a9e667e/.nycrc 0000664 0000000 0000000 00000000213 14761365700 0016546 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}
ljharb-call-bound-a9e667e/CHANGELOG.md 0000664 0000000 0000000 00000005500 14761365700 0017244 0 ustar 00root root 0000000 0000000 # 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)
ljharb-call-bound-a9e667e/LICENSE 0000664 0000000 0000000 00000002057 14761365700 0016444 0 ustar 00root root 0000000 0000000 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.
ljharb-call-bound-a9e667e/README.md 0000664 0000000 0000000 00000003551 14761365700 0016716 0 ustar 00root root 0000000 0000000 # call-bound [![Version Badge][npm-version-svg]][package-url]
[![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
ljharb-call-bound-a9e667e/index.d.ts 0000664 0000000 0000000 00000011053 14761365700 0017334 0 ustar 00root root 0000000 0000000 type Intrinsic = typeof globalThis;
type IntrinsicName = keyof Intrinsic | `%${keyof Intrinsic}%`;
type IntrinsicPath = IntrinsicName | `${StripPercents}.${string}` | `%${StripPercents}.${string}%`;
type AllowMissing = boolean;
type StripPercents = T extends `%${infer U}%` ? U : T;
type BindMethodPrecise =
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 =
(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 =
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 `${infer Obj}.prototype.${infer Method}`
? Obj extends keyof typeof globalThis
? BindMethodPrecise>
: unknown
: S extends `${infer Obj}.${infer Prop}`
? Obj extends keyof typeof globalThis
? GetStaticMember
: unknown
: unknown
declare function arraySlice(array: readonly T[], start?: number, end?: number): T[];
declare function arraySlice(array: ArrayLike, start?: number, end?: number): T[];
declare function arraySlice(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%': (array: readonly T[], callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any) => U[];
'%Array.prototype.filter%': (array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any) => T[];
'%Array.prototype.indexOf%': (array: readonly T[], searchElement: T, fromIndex?: number) => number;
'%Function.prototype.apply%': (fn: (...args: A) => R, thisArg: any, args: A) => R;
'%Function.prototype.call%': (fn: (...args: A) => R, thisArg: any, ...args: A) => R;
'%Function.prototype.bind%': (fn: (...args: A) => R, thisArg: any, ...args: A) => (...remainingArgs: A) => R;
'%Promise.prototype.then%': {
(promise: Promise, onfulfilled: (value: T) => R | PromiseLike): Promise;
(promise: Promise, onfulfilled: ((value: T) => R | PromiseLike) | undefined | null, onrejected: (reason: any) => R | PromiseLike): Promise;
};
'%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, S extends IntrinsicPath>(name: K, allowMissing?: AllowMissing): SpecialCases[`%${StripPercents}%`];
declare function callBound, S extends IntrinsicPath>(name: S, allowMissing?: AllowMissing): BoundIntrinsic;
export = callBound;
ljharb-call-bound-a9e667e/index.js 0000664 0000000 0000000 00000001257 14761365700 0017105 0 ustar 00root root 0000000 0000000 '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;
};
ljharb-call-bound-a9e667e/package.json 0000664 0000000 0000000 00000004713 14761365700 0017726 0 ustar 00root root 0000000 0000000 {
"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 ",
"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"
}
}
ljharb-call-bound-a9e667e/test/ 0000775 0000000 0000000 00000000000 14761365700 0016412 5 ustar 00root root 0000000 0000000 ljharb-call-bound-a9e667e/test/index.js 0000664 0000000 0000000 00000004562 14761365700 0020066 0 ustar 00root root 0000000 0000000 '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();
});
ljharb-call-bound-a9e667e/tsconfig.json 0000664 0000000 0000000 00000000211 14761365700 0020134 0 ustar 00root root 0000000 0000000 {
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "ESNext",
"lib": ["es2024"],
},
"exclude": [
"coverage",
],
}