pax_global_header00006660000000000000000000000064147277461010014523gustar00rootroot0000000000000052 comment=07ce64a97a0aa8d745e172f26f49eff863adae01 ljharb-unbox-primitive-57a9506/000077500000000000000000000000001472774610100164065ustar00rootroot00000000000000ljharb-unbox-primitive-57a9506/.editorconfig000066400000000000000000000004361472774610100210660ustar00rootroot00000000000000root = true [*] indent_style = tab indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true max_line_length = 150 [CHANGELOG.md] indent_style = space indent_size = 2 [*.json] max_line_length = off [Makefile] max_line_length = off ljharb-unbox-primitive-57a9506/.eslintrc000066400000000000000000000000531472774610100202300ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", } ljharb-unbox-primitive-57a9506/.github/000077500000000000000000000000001472774610100177465ustar00rootroot00000000000000ljharb-unbox-primitive-57a9506/.github/FUNDING.yml000066400000000000000000000011121472774610100215560ustar00rootroot00000000000000# 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/unbox-primitive 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-unbox-primitive-57a9506/.github/workflows/000077500000000000000000000000001472774610100220035ustar00rootroot00000000000000ljharb-unbox-primitive-57a9506/.github/workflows/node-aught.yml000066400000000000000000000005161472774610100245630ustar00rootroot00000000000000name: '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 node: name: 'node < 10' needs: [tests] runs-on: ubuntu-latest steps: - run: 'echo tests completed' ljharb-unbox-primitive-57a9506/.github/workflows/node-pretest.yml000066400000000000000000000002061472774610100251350ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main ljharb-unbox-primitive-57a9506/.github/workflows/node-tens.yml000066400000000000000000000005471472774610100244300ustar00rootroot00000000000000name: '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 node: name: 'node 10 - 20' needs: [tests] runs-on: ubuntu-latest steps: - run: true ljharb-unbox-primitive-57a9506/.github/workflows/node-twenties.yml000066400000000000000000000005361472774610100253170ustar00rootroot00000000000000name: '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 node: name: 'node >= 20' needs: [tests] runs-on: ubuntu-latest steps: - run: true ljharb-unbox-primitive-57a9506/.github/workflows/rebase.yml000066400000000000000000000007001472774610100237640ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] permissions: contents: read jobs: _: permissions: contents: write # for ljharb/rebase to push code to rebase pull-requests: read # for ljharb/rebase to get info about PR name: "Automatic Rebase" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: ljharb/rebase@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ljharb-unbox-primitive-57a9506/.github/workflows/require-allow-edits.yml000066400000000000000000000003031472774610100264200ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main ljharb-unbox-primitive-57a9506/.gitignore000066400000000000000000000017611472774610100204030ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # 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 # nyc test coverage .nyc_output # Grunt intermediate storage (http://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/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # next.js build output .next # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock .npmignore ljharb-unbox-primitive-57a9506/.npmrc000066400000000000000000000000671472774610100175310ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s ljharb-unbox-primitive-57a9506/.nycrc000066400000000000000000000003301472774610100175210ustar00rootroot00000000000000{ "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" ] } ljharb-unbox-primitive-57a9506/CHANGELOG.md000066400000000000000000000205541472774610100202250ustar00rootroot00000000000000# 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.1.0](https://github.com/ljharb/unbox-primitive/compare/v1.0.2...v1.1.0) - 2024-12-15 ### Commits - [meta] use `npmignore` to autogenerate an npmignore file [`348a5ad`](https://github.com/ljharb/unbox-primitive/commit/348a5ad5d353e7fcd6353934073ca3a982f40a4e) - [New] add types [`a324230`](https://github.com/ljharb/unbox-primitive/commit/a32423092f81bfbf3c4dff77a5fa549ffae87daa) - [Tests] use `es-value-fixtures` [`a321ae5`](https://github.com/ljharb/unbox-primitive/commit/a321ae56aaf30ea843c708bf6c6c13ee52eee205) - [actions] split out node 10-20, and 20+ [`04a0e0d`](https://github.com/ljharb/unbox-primitive/commit/04a0e0d09907c2643e25ad69b49864c1c34e59d0) - [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `npmignore`, `object-inspect`, `object-is`, `tape` [`7fff971`](https://github.com/ljharb/unbox-primitive/commit/7fff97161bf83ebe348290ef27992af630ca92e9) - [actions] update rebase action [`91d6807`](https://github.com/ljharb/unbox-primitive/commit/91d6807c562a39ce876feda777b641eb0ee64ce9) - [Deps] update `call-bind`, `has-symbols`, `which-boxed-primitive` [`f8b6597`](https://github.com/ljharb/unbox-primitive/commit/f8b6597e071d05f0792f6eef0e2fbc30ddfe43d4) - [Dev Deps] update `aud`, `object-inspect`, `tape` [`b3362a1`](https://github.com/ljharb/unbox-primitive/commit/b3362a164fdbee9006be765d99d5d835d6493326) - [Refactor] use `call-bound` directly [`e29ff5f`](https://github.com/ljharb/unbox-primitive/commit/e29ff5f4cbcc58d32e670bce11d5c3137eae0c44) - [meta] add missing `engines.node` [`d3420bc`](https://github.com/ljharb/unbox-primitive/commit/d3420bc8cda471cf62119e08d9581b72962f74f6) - [Tests] replace `aud` with `npm audit` [`5e6a6d0`](https://github.com/ljharb/unbox-primitive/commit/5e6a6d0459b6fa8a812d00362fe60854333f1b64) - [Deps] update `which-boxed-primitive` [`0ff873d`](https://github.com/ljharb/unbox-primitive/commit/0ff873dadf31962c2f00e24d8d7d30cfa8c60ac6) - [Dev Deps] update `aud` [`dd0e373`](https://github.com/ljharb/unbox-primitive/commit/dd0e3733bb9db65d254492d6c1d1b710005b932f) - [Dev Deps] add missing peer dep [`4f79b24`](https://github.com/ljharb/unbox-primitive/commit/4f79b240212d847276dba9a0044f356506eaeaa6) ## [v1.0.2](https://github.com/ljharb/unbox-primitive/compare/v1.0.1...v1.0.2) - 2022-04-24 ### Commits - [actions] reuse common workflows [`e6420b9`](https://github.com/ljharb/unbox-primitive/commit/e6420b94eed3558ef3ecddbd3d85fe2f400d1db1) - [actions] update codecov uploader [`b90aff2`](https://github.com/ljharb/unbox-primitive/commit/b90aff2b17b70c1a7200eb5faa3f9e64ebf055f9) - [readme] add github actions/codecov badges; update URLs [`bcc39b9`](https://github.com/ljharb/unbox-primitive/commit/bcc39b9d6d101bad199c95604f94999f80d6da97) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` [`a704a32`](https://github.com/ljharb/unbox-primitive/commit/a704a32ec4af43cd0631317ae3a537012adc1610) - [Refactor] use `call-bind` instead of `function-bind` [`0a609f1`](https://github.com/ljharb/unbox-primitive/commit/0a609f1be6269cbf501482aacd9a0a1bd8596108) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `safe-publish-latest`, `tape` [`6a45317`](https://github.com/ljharb/unbox-primitive/commit/6a4531757d74af97c9d0770b102f81ce6ff0a8dc) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`795c76f`](https://github.com/ljharb/unbox-primitive/commit/795c76f14c4df3c7ae934f7b14a98c07951ea9c7) - [Deps] update `has-bigints`, `has-symbols` [`257a065`](https://github.com/ljharb/unbox-primitive/commit/257a065496b4190c296d674bff342ea40cf8e176) ## [v1.0.1](https://github.com/ljharb/unbox-primitive/compare/v1.0.0...v1.0.1) - 2021-03-25 ### Commits - [Tests] use shared travis-ci configs [`f977e5f`](https://github.com/ljharb/unbox-primitive/commit/f977e5f8fa532dbc519bd78a48cf4b81c14720fe) - [Tests] migrate tests to Github Actions [`b89def6`](https://github.com/ljharb/unbox-primitive/commit/b89def60908a236aa1b5c756426f7cc61cf458dd) - [meta] do not publish github action workflow files [`325d1f1`](https://github.com/ljharb/unbox-primitive/commit/325d1f1836cecbe57ee148545de5aefcbe7a7dce) - readme [`810cd70`](https://github.com/ljharb/unbox-primitive/commit/810cd70f7b3c670cd55eae64466c89595175ee2a) - [Tests] run `nyc` on all tests; use `tape` runner [`2f5fb08`](https://github.com/ljharb/unbox-primitive/commit/2f5fb08930c8f8e5e069ac61891dc9bd76cb762b) - [meta] add `auto-changelog` [`03ed375`](https://github.com/ljharb/unbox-primitive/commit/03ed3759284493f19323eb0500f726d0851fc085) - [actions] add automatic rebasing / merge commit blocking [`6dec48d`](https://github.com/ljharb/unbox-primitive/commit/6dec48daa357fa79a5cac1add9ca33f7b56276cc) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `object-is`, `tape` [`528ed88`](https://github.com/ljharb/unbox-primitive/commit/528ed8826664b67f7eaf1fe7e2031c063b2d315f) - [actions] check out the entire repo [`5095b29`](https://github.com/ljharb/unbox-primitive/commit/5095b2981f44a78b3f9bfaa1a526f17a6823e383) - [actions] add "Allow Edits" workflow [`5aa26d7`](https://github.com/ljharb/unbox-primitive/commit/5aa26d7f0c32e0e78ba4bf3e5f9abb5478fd97fa) - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `object-is`, `safe-publish-latest`, `tape` [`afc18c6`](https://github.com/ljharb/unbox-primitive/commit/afc18c6cb59cbb6b514e0d8004c6fd264e2a27eb) - [readme] remove travis badge [`a025899`](https://github.com/ljharb/unbox-primitive/commit/a0258997a21604e1266840e6d167f0a870966e9b) - [Dev Deps] update `auto-changelog` [`9219a32`](https://github.com/ljharb/unbox-primitive/commit/9219a32844b2ce3ed0a7ea12a5910a3e92424e4e) - [readme] Fix missing paren in example [`73f5a33`](https://github.com/ljharb/unbox-primitive/commit/73f5a3340ca1ab6c227ed4632117d816d5e35317) - [Dev Deps] update `@ljharb/eslint-config`, `tape` [`e450acc`](https://github.com/ljharb/unbox-primitive/commit/e450accb54ab452f240768a5f0a98e5887b0ba8c) - [Deps] update `has-bigints`, `has-symbols`, `which-boxed-primitive` [`a4279b5`](https://github.com/ljharb/unbox-primitive/commit/a4279b504732002074e5dcb9c5509038d605f563) - [Dev Deps] update `auto-changelog`, `in-publish`, `tape` [`b351548`](https://github.com/ljharb/unbox-primitive/commit/b351548d31789c0d0af4c3bce55c2bdefe51b40f) - [actions] switch Automatic Rebase workflow to `pull_request_target` event [`f600382`](https://github.com/ljharb/unbox-primitive/commit/f600382db83025270969354ac52a72aadb0a7ffa) - [readme] fix travis links [`4d02fa9`](https://github.com/ljharb/unbox-primitive/commit/4d02fa9a4990812b048f8aefe6e46be80b68beef) - [Dev Deps] update `auto-changelog`; add `aud` [`07e74a3`](https://github.com/ljharb/unbox-primitive/commit/07e74a3ca90688122593095849757e3c05c46db0) - [meta] add `funding` field [`7ca4bd7`](https://github.com/ljharb/unbox-primitive/commit/7ca4bd71196e90a2fc9c7cb0ef4e30f949d5a853) - [Tests] only audit prod deps [`47d8d5f`](https://github.com/ljharb/unbox-primitive/commit/47d8d5fbd58bf472e7e83f79ccef7e8379d06b35) - [Deps] update `has-symbols` [`c70c15e`](https://github.com/ljharb/unbox-primitive/commit/c70c15e924191d11a271cff25bde657b0c3c3016) ## v1.0.0 - 2019-08-10 ### Commits - [Tests] add `.travis.yml` [`8c9a5ef`](https://github.com/ljharb/unbox-primitive/commit/8c9a5efdb54be4866e2884bf32cbe830788b2c2a) - Initial commit [`feaff15`](https://github.com/ljharb/unbox-primitive/commit/feaff159eb999adc8763ff3e51d2d3d56d6164f8) - [Tests] add tests [`3dd18d6`](https://github.com/ljharb/unbox-primitive/commit/3dd18d65748efb4af9b8ca66f8d8c5521d8f2dec) - implementation [`472fb41`](https://github.com/ljharb/unbox-primitive/commit/472fb41d049ddee80ebf3219a5837e639a6e9341) - npm init [`e9e426f`](https://github.com/ljharb/unbox-primitive/commit/e9e426fc90b9a3f07ffc48db75f78c414f77bc2b) - [Tests] add linting [`139e74b`](https://github.com/ljharb/unbox-primitive/commit/139e74b94cdfd187b43b24de76c6d84af21ee467) - [meta] create FUNDING.yml [`a9509e1`](https://github.com/ljharb/unbox-primitive/commit/a9509e122163e2b9d98af421e5c0575df36e2310) - Only apps should have lockfiles [`b3d0834`](https://github.com/ljharb/unbox-primitive/commit/b3d0834d69dcbf4cbc1e61ccfaef05acf96cf630) ljharb-unbox-primitive-57a9506/LICENSE000066400000000000000000000020571472774610100174170ustar00rootroot00000000000000MIT License Copyright (c) 2019 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-unbox-primitive-57a9506/README.md000066400000000000000000000041341472774610100176670ustar00rootroot00000000000000# unbox-primitive [![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] Unbox a boxed JS primitive value. This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and works despite ES6 Symbol.toStringTag. ## Example ```js var unboxPrimitive = require('unbox-primitive'); var assert = require('assert'); assert.equal(unboxPrimitive(new Boolean(false)), false); assert.equal(unboxPrimitive(new String('f')), 'f'); assert.equal(unboxPrimitive(new Number(42)), 42); const s = Symbol(); assert.equal(unboxPrimitive(Object(s)), s); assert.equal(unboxPrimitive(new BigInt(42)), 42n); // any primitive, or non-boxed-primitive object, will throw ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/unbox-primitive [npm-version-svg]: https://versionbadg.es/ljharb/unbox-primitive.svg [deps-svg]: https://david-dm.org/ljharb/unbox-primitive.svg [deps-url]: https://david-dm.org/ljharb/unbox-primitive [dev-deps-svg]: https://david-dm.org/ljharb/unbox-primitive/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/unbox-primitive#info=devDependencies [npm-badge-png]: https://nodei.co/npm/unbox-primitive.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/unbox-primitive.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/unbox-primitive.svg [downloads-url]: https://npm-stat.com/charts.html?package=unbox-primitive [codecov-image]: https://codecov.io/gh/ljharb/unbox-primitive/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/ljharb/unbox-primitive/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/unbox-primitive [actions-url]: https://github.com/ljharb/unbox-primitive/actions ljharb-unbox-primitive-57a9506/index.d.ts000066400000000000000000000007011472774610100203050ustar00rootroot00000000000000declare function unboxPrimitive(value: T): unboxPrimitive.Unbox; declare namespace unboxPrimitive { type Boxed = String | Number | Boolean | Symbol | BigInt; type Unbox = T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends Symbol ? symbol : T extends BigInt ? bigint : never; } export = unboxPrimitive; ljharb-unbox-primitive-57a9506/index.js000066400000000000000000000027741472774610100200650ustar00rootroot00000000000000'use strict'; var whichBoxedPrimitive = require('which-boxed-primitive'); var callBound = require('call-bound'); var hasSymbols = require('has-symbols')(); var hasBigInts = require('has-bigints')(); var stringToString = callBound('String.prototype.toString'); var numberValueOf = callBound('Number.prototype.valueOf'); var booleanValueOf = callBound('Boolean.prototype.valueOf'); var symbolValueOf = hasSymbols && callBound('Symbol.prototype.valueOf'); var bigIntValueOf = hasBigInts && callBound('BigInt.prototype.valueOf'); /** @type {import('.')} */ module.exports = function unboxPrimitive(value) { var which = whichBoxedPrimitive(value); if (typeof which !== 'string') { throw new TypeError(which === null ? 'value is an unboxed primitive' : 'value is a non-boxed-primitive object'); } if (which === 'String') { return stringToString(value); } if (which === 'Number') { return numberValueOf(value); } if (which === 'Boolean') { return booleanValueOf(value); } if (which === 'Symbol') { if (!hasSymbols) { throw new EvalError('somehow this environment does not have Symbols, but you have a boxed Symbol value. Please report this!'); } // eslint-disable-next-line no-extra-parens return /** @type {Exclude} */ (symbolValueOf)(value); } if (which === 'BigInt') { // eslint-disable-next-line no-extra-parens return /** @type {Exclude} */ (bigIntValueOf)(value); } throw new RangeError('unknown boxed primitive found: ' + which); }; ljharb-unbox-primitive-57a9506/package.json000066400000000000000000000043121472774610100206740ustar00rootroot00000000000000{ "name": "unbox-primitive", "version": "1.1.0", "description": "Unbox a boxed JS primitive value.", "main": "index.js", "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "lint": "eslint --ext=js,mjs .", "postlint": "tsc && 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/unbox-primitive.git" }, "keywords": [ "unbox", "boxed", "primitive", "object", "javascript", "ecmascript" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/ljharb/unbox-primitive/issues" }, "homepage": "https://github.com/ljharb/unbox-primitive#readme", "devDependencies": { "@arethetypeswrong/cli": "^0.17.1", "@ljharb/eslint-config": "^21.1.1", "@ljharb/tsconfig": "^0.2.2", "@types/for-each": "^0.3.3", "@types/object-inspect": "^1.13.0", "@types/object-is": "^1.1.0", "@types/tape": "^5.7.0", "auto-changelog": "^2.5.0", "encoding": "^0.1.13", "es-value-fixtures": "^1.5.0", "eslint": "=8.8.0", "for-each": "^0.3.3", "in-publish": "^2.0.1", "npmignore": "^0.3.1", "nyc": "^10.3.2", "object-inspect": "^1.13.3", "object-is": "^1.1.6", "safe-publish-latest": "^2.0.0", "tape": "^5.9.0", "typescript": "next" }, "dependencies": { "call-bound": "^1.0.3", "has-bigints": "^1.0.2", "has-symbols": "^1.1.0", "which-boxed-primitive": "^1.1.1" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] }, "engines": { "node": ">= 0.4" } } ljharb-unbox-primitive-57a9506/test/000077500000000000000000000000001472774610100173655ustar00rootroot00000000000000ljharb-unbox-primitive-57a9506/test/index.js000066400000000000000000000024361472774610100210370ustar00rootroot00000000000000'use strict'; var test = require('tape'); var inspect = require('object-inspect'); var is = require('object-is'); var forEach = require('for-each'); var v = require('es-value-fixtures'); var unboxPrimitive = require('..'); test('primitives', function (t) { forEach([null, undefined], function (nullValue) { t['throws']( // @ts-expect-error function () { unboxPrimitive(nullValue); }, TypeError, inspect(nullValue) + ' is not a primitive' ); }); // eslint-disable-next-line no-extra-parens forEach(/** @type {typeof v.nonNullPrimitives} */ ([].concat( // @ts-expect-error TS sucks with concat v.nonNullPrimitives, v.zeroes, v.infinities, NaN )), function (primitive) { var obj = Object(primitive); t.ok( is(unboxPrimitive(obj), primitive), inspect(obj) + 'unboxes to ' + inspect(primitive) ); }); t.end(); }); test('objects', function (t) { // eslint-disable-next-line no-extra-parens forEach(/** @type {typeof v.objects} */ (/** @type {unknown} */ ([].concat( // @ts-expect-error TS sucks with concat v.objects, {}, [], function () {}, /a/g, new Date() ))), function (object) { t['throws']( // @ts-expect-error function () { unboxPrimitive(object); }, TypeError, inspect(object) + ' is not a primitive' ); }); t.end(); }); ljharb-unbox-primitive-57a9506/tsconfig.json000066400000000000000000000001041472774610100211100ustar00rootroot00000000000000{ "extends": "@ljharb/tsconfig", "exclude": [ "coverage", ], }