pax_global_header00006660000000000000000000000064137771513450014527gustar00rootroot0000000000000052 comment=42b3cbfb095850822acd2352ec2a8cd0f7f58dd0 call-bind-1.0.2/000077500000000000000000000000001377715134500133545ustar00rootroot00000000000000call-bind-1.0.2/.eslintignore000066400000000000000000000000121377715134500160500ustar00rootroot00000000000000coverage/ call-bind-1.0.2/.eslintrc000066400000000000000000000003671377715134500152060ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "func-name-matching": 0, "id-length": 0, "new-cap": [2, { "capIsNewExceptions": [ "GetIntrinsic", ], }], "no-magic-numbers": 0, "operator-linebreak": [2, "before"], }, } call-bind-1.0.2/.github/000077500000000000000000000000001377715134500147145ustar00rootroot00000000000000call-bind-1.0.2/.github/FUNDING.yml000066400000000000000000000011041377715134500165250ustar00rootroot00000000000000# 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-bind 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'] call-bind-1.0.2/.github/workflows/000077500000000000000000000000001377715134500167515ustar00rootroot00000000000000call-bind-1.0.2/.github/workflows/node-4+.yml000066400000000000000000000024501377715134500206360ustar00rootroot00000000000000name: 'Tests: node.js' on: [pull_request, push] jobs: matrix: runs-on: ubuntu-latest outputs: latest: ${{ steps.set-matrix.outputs.requireds }} minors: ${{ steps.set-matrix.outputs.optionals }} steps: - uses: ljharb/actions/node/matrix@main id: set-matrix with: preset: '>=4' latest: needs: [matrix] name: 'latest minors' runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.latest) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main name: 'npm install && npm run tests-only' with: node-version: ${{ matrix.node-version }} command: 'tests-only' minors: needs: [matrix, latest] name: 'non-latest minors' continue-on-error: true if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }} runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.minors) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main with: node-version: ${{ matrix.node-version }} command: 'tests-only' node: name: 'node 4+' needs: [latest, minors] runs-on: ubuntu-latest steps: - run: 'echo tests completed' call-bind-1.0.2/.github/workflows/node-iojs.yml000066400000000000000000000026361377715134500213720ustar00rootroot00000000000000name: 'Tests: node.js (io.js)' on: [pull_request, push] jobs: matrix: runs-on: ubuntu-latest outputs: latest: ${{ steps.set-matrix.outputs.requireds }} minors: ${{ steps.set-matrix.outputs.optionals }} steps: - uses: ljharb/actions/node/matrix@main id: set-matrix with: preset: 'iojs' latest: needs: [matrix] name: 'latest minors' runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.latest) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main name: 'npm install && npm run tests-only' with: node-version: ${{ matrix.node-version }} command: 'tests-only' skip-ls-check: true minors: needs: [matrix, latest] name: 'non-latest minors' continue-on-error: true if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }} runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.minors) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main name: 'npm install && npm run tests-only' with: node-version: ${{ matrix.node-version }} command: 'tests-only' skip-ls-check: true node: name: 'io.js' needs: [latest, minors] runs-on: ubuntu-latest steps: - run: 'echo tests completed' call-bind-1.0.2/.github/workflows/node-pretest.yml000066400000000000000000000010671377715134500221110ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: pretest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main name: 'npm install && npm run pretest' with: node-version: 'lts/*' command: 'pretest' posttest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main name: 'npm install && npm run posttest' with: node-version: 'lts/*' command: 'posttest' call-bind-1.0.2/.github/workflows/node-zero.yml000066400000000000000000000030401377715134500213730ustar00rootroot00000000000000name: 'Tests: node.js (0.x)' on: [pull_request, push] jobs: matrix: runs-on: ubuntu-latest outputs: stable: ${{ steps.set-matrix.outputs.requireds }} unstable: ${{ steps.set-matrix.outputs.optionals }} steps: - uses: ljharb/actions/node/matrix@main id: set-matrix with: preset: '0.x' stable: needs: [matrix] name: 'stable minors' runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.stable) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main with: node-version: ${{ matrix.node-version }} command: 'tests-only' cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} skip-ls-check: true unstable: needs: [matrix, stable] name: 'unstable minors' continue-on-error: true if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }} runs-on: ubuntu-latest strategy: matrix: ${{ fromJson(needs.matrix.outputs.unstable) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/run@main with: node-version: ${{ matrix.node-version }} command: 'tests-only' cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} skip-ls-check: true node: name: 'node 0.x' needs: [stable, unstable] runs-on: ubuntu-latest steps: - run: 'echo tests completed' call-bind-1.0.2/.github/workflows/rebase.yml000066400000000000000000000004011377715134500207300ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: name: "Automatic Rebase" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/rebase@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} call-bind-1.0.2/.github/workflows/require-allow-edits.yml000066400000000000000000000003011377715134500233640ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main call-bind-1.0.2/.gitignore000066400000000000000000000032351377715134500153470ustar00rootroot00000000000000# 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 call-bind-1.0.2/.npmignore000066400000000000000000000032601377715134500153540ustar00rootroot00000000000000# 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 .github/workflows call-bind-1.0.2/.npmrc000066400000000000000000000000671377715134500144770ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s call-bind-1.0.2/.nycrc000066400000000000000000000003301377715134500144670ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "lines": 86, "statements": 85.93, "functions": 82.43, "branches": 76.06, "exclude": [ "coverage", "test" ] } call-bind-1.0.2/CHANGELOG.md000066400000000000000000000064031377715134500151700ustar00rootroot00000000000000# 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.2](https://github.com/ljharb/call-bind/compare/v1.0.1...v1.0.2) - 2021-01-11 ### Commits - [Fix] properly include the receiver in the bound length [`dbae7bc`](https://github.com/ljharb/call-bind/commit/dbae7bc676c079a0d33c0a43e9ef92cb7b01345d) ## [v1.0.1](https://github.com/ljharb/call-bind/compare/v1.0.0...v1.0.1) - 2021-01-08 ### Commits - [Tests] migrate tests to Github Actions [`b6db284`](https://github.com/ljharb/call-bind/commit/b6db284c36f8ccd195b88a6764fe84b7223a0da1) - [meta] do not publish github action workflow files [`ec7fe46`](https://github.com/ljharb/call-bind/commit/ec7fe46e60cfa4764ee943d2755f5e5a366e578e) - [Fix] preserve original function’s length when possible [`adbceaa`](https://github.com/ljharb/call-bind/commit/adbceaa3cac4b41ea78bb19d7ccdbaaf7e0bdadb) - [Tests] gather coverage data on every job [`d69e23c`](https://github.com/ljharb/call-bind/commit/d69e23cc65f101ba1d4c19bb07fa8eb0ec624be8) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`2fd3586`](https://github.com/ljharb/call-bind/commit/2fd3586c5d47b335364c14293114c6b625ae1f71) - [Deps] update `get-intrinsic` [`f23e931`](https://github.com/ljharb/call-bind/commit/f23e9318cc271c2add8bb38cfded85ee7baf8eee) - [Deps] update `get-intrinsic` [`72d9f44`](https://github.com/ljharb/call-bind/commit/72d9f44e184465ba8dd3fb48260bbcff234985f2) - [meta] fix FUNDING.yml [`e723573`](https://github.com/ljharb/call-bind/commit/e723573438c5a68dcec31fb5d96ea6b7e4a93be8) - [eslint] ignore coverage output [`15e76d2`](https://github.com/ljharb/call-bind/commit/15e76d28a5f43e504696401e5b31ebb78ee1b532) - [meta] add Automatic Rebase and Require Allow Edits workflows [`8fa4dab`](https://github.com/ljharb/call-bind/commit/8fa4dabb23ba3dd7bb92c9571c1241c08b56e4b6) ## v1.0.0 - 2020-10-30 ### Commits - Initial commit [`306cf98`](https://github.com/ljharb/call-bind/commit/306cf98c7ec9e7ef66b653ec152277ac1381eb50) - Tests [`e10d0bb`](https://github.com/ljharb/call-bind/commit/e10d0bbdadc7a10ecedc9a1c035112d3e368b8df) - Implementation [`43852ed`](https://github.com/ljharb/call-bind/commit/43852eda0f187327b7fad2423ca972149a52bd65) - npm init [`408f860`](https://github.com/ljharb/call-bind/commit/408f860b773a2f610805fd3613d0d71bac1b6249) - [meta] add Automatic Rebase and Require Allow Edits workflows [`fb349b2`](https://github.com/ljharb/call-bind/commit/fb349b2e48defbec8b5ec8a8395cc8f69f220b13) - [meta] add `auto-changelog` [`c4001fc`](https://github.com/ljharb/call-bind/commit/c4001fc43031799ef908211c98d3b0fb2b60fde4) - [meta] add "funding"; create `FUNDING.yml` [`d4d6d29`](https://github.com/ljharb/call-bind/commit/d4d6d2974a14bc2e98830468eda7fe6d6a776717) - [Tests] add `npm run lint` [`dedfb98`](https://github.com/ljharb/call-bind/commit/dedfb98bd0ecefb08ddb9a94061bd10cde4332af) - Only apps should have lockfiles [`54ac776`](https://github.com/ljharb/call-bind/commit/54ac77653db45a7361dc153d2f478e743f110650) - [meta] add `safe-publish-latest` [`9ea8e43`](https://github.com/ljharb/call-bind/commit/9ea8e435b950ce9b705559cd651039f9bf40140f) call-bind-1.0.2/LICENSE000066400000000000000000000020571377715134500143650ustar00rootroot00000000000000MIT License Copyright (c) 2020 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. call-bind-1.0.2/README.md000066400000000000000000000000601377715134500146270ustar00rootroot00000000000000# call-bind Robustly `.call.bind()` a function. call-bind-1.0.2/callBound.js000066400000000000000000000006351377715134500156210ustar00rootroot00000000000000'use strict'; var GetIntrinsic = require('get-intrinsic'); var callBind = require('./'); var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); module.exports = function callBoundIntrinsic(name, allowMissing) { var intrinsic = GetIntrinsic(name, !!allowMissing); if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { return callBind(intrinsic); } return intrinsic; }; call-bind-1.0.2/index.js000066400000000000000000000024321377715134500150220ustar00rootroot00000000000000'use strict'; var bind = require('function-bind'); var GetIntrinsic = require('get-intrinsic'); var $apply = GetIntrinsic('%Function.prototype.apply%'); var $call = GetIntrinsic('%Function.prototype.call%'); var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); var $max = GetIntrinsic('%Math.max%'); if ($defineProperty) { try { $defineProperty({}, 'a', { value: 1 }); } catch (e) { // IE 8 has a broken defineProperty $defineProperty = null; } } module.exports = function callBind(originalFunction) { var func = $reflectApply(bind, $call, arguments); if ($gOPD && $defineProperty) { var desc = $gOPD(func, 'length'); if (desc.configurable) { // original length, plus the receiver, minus any additional arguments (after the receiver) $defineProperty( func, 'length', { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) } ); } } return func; }; var applyBind = function applyBind() { return $reflectApply(bind, $apply, arguments); }; if ($defineProperty) { $defineProperty(module.exports, 'apply', { value: applyBind }); } else { module.exports.apply = applyBind; } call-bind-1.0.2/package.json000066400000000000000000000034011377715134500156400ustar00rootroot00000000000000{ "name": "call-bind", "version": "1.0.2", "description": "Robustly `.call.bind()` a function", "main": "index.js", "exports": { ".": [ { "default": "./index.js" }, "./index.js" ], "./callBound": [ { "default": "./callBound.js" }, "./callBound.js" ], "./package.json": "./package.json" }, "scripts": { "prepublish": "safe-publish-latest", "lint": "eslint --ext=.js,.mjs .", "pretest": "npm run lint", "tests-only": "nyc tape 'test/*'", "test": "npm run tests-only", "posttest": "aud --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-bind.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-bind/issues" }, "homepage": "https://github.com/ljharb/call-bind#readme", "devDependencies": { "@ljharb/eslint-config": "^17.3.0", "aud": "^1.1.3", "auto-changelog": "^2.2.1", "eslint": "^7.17.0", "nyc": "^10.3.2", "safe-publish-latest": "^1.1.4", "tape": "^5.1.1" }, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true } } call-bind-1.0.2/test/000077500000000000000000000000001377715134500143335ustar00rootroot00000000000000call-bind-1.0.2/test/callBound.js000066400000000000000000000045131377715134500165770ustar00rootroot00000000000000'use strict'; var test = require('tape'); var callBound = require('../callBound'); 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'); // prototype function t.notEqual(callBound('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString does not yield itself'); t.notEqual(callBound('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% does not yield itself'); t.equal(callBound('Object.prototype.toString')(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original'); t.equal(callBound('%Object.prototype.toString%')(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original'); t['throws']( function () { callBound('does not exist'); }, SyntaxError, 'nonexistent intrinsic throws' ); t['throws']( function () { callBound('does not exist', true); }, SyntaxError, 'allowMissing arg still throws for unknown intrinsic' ); /* globals WeakRef: false */ 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(); }); call-bind-1.0.2/test/index.js000066400000000000000000000064321377715134500160050ustar00rootroot00000000000000'use strict'; var callBind = require('../'); var bind = require('function-bind'); var test = require('tape'); /* * older engines have length nonconfigurable * in io.js v3, it is configurable except on bound functions, hence the .bind() */ var functionsHaveConfigurableLengths = !!( Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(bind.call(function () {}), 'length').configurable ); test('callBind', function (t) { var sentinel = { sentinel: true }; var func = function (a, b) { // eslint-disable-next-line no-invalid-this return [this, a, b]; }; t.equal(func.length, 2, 'original function length is 2'); t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args'); t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args'); t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args'); var bound = callBind(func); t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with too few args'); t.deepEqual(bound(1, 2), [1, 2, undefined], 'bound func with right args'); t.deepEqual(bound(1, 2, 3), [1, 2, 3], 'bound func with too many args'); var boundR = callBind(func, sentinel); t.equal(boundR.length, func.length, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args'); t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args'); t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args'); var boundArg = callBind(func, sentinel, 1); t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args'); t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg'); t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args'); t.test('callBind.apply', function (st) { var aBound = callBind.apply(func); st.deepEqual(aBound(sentinel), [sentinel, undefined, undefined], 'apply-bound func with no args'); st.deepEqual(aBound(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args'); st.deepEqual(aBound(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args'); var aBoundArg = callBind.apply(func); st.deepEqual(aBoundArg(sentinel, [1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with too many args'); st.deepEqual(aBoundArg(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args'); st.deepEqual(aBoundArg(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args'); var aBoundR = callBind.apply(func, sentinel); st.deepEqual(aBoundR([1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with receiver and too many args'); st.deepEqual(aBoundR([1, 2], 4), [sentinel, 1, 2], 'apply-bound func with receiver and right args'); st.deepEqual(aBoundR([1], 4), [sentinel, 1, undefined], 'apply-bound func with receiver and too few args'); st.end(); }); t.end(); });