Spaces:
Paused
Paused
Include updated package-lock.json (part 8)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/optionator/package.json +43 -0
- node_modules/otplib/LICENSE +21 -0
- node_modules/otplib/README.md +534 -0
- node_modules/otplib/core.d.ts +1 -0
- node_modules/otplib/core.js +23 -0
- node_modules/otplib/index.d.ts +1 -0
- node_modules/otplib/index.js +23 -0
- node_modules/otplib/package.json +34 -0
- node_modules/otplib/v11.d.ts +1 -0
- node_modules/otplib/v11.js +23 -0
- node_modules/outvariant/LICENSE +9 -0
- node_modules/outvariant/README.md +146 -0
- node_modules/outvariant/lib/index.d.ts +21 -0
- node_modules/outvariant/lib/index.js +120 -0
- node_modules/outvariant/lib/index.js.map +1 -0
- node_modules/outvariant/lib/index.mjs +91 -0
- node_modules/outvariant/lib/index.mjs.map +1 -0
- node_modules/outvariant/package.json +47 -0
- node_modules/own-keys/.eslintrc +16 -0
- node_modules/own-keys/.github/FUNDING.yml +12 -0
- node_modules/own-keys/.nycrc +9 -0
- node_modules/own-keys/CHANGELOG.md +23 -0
- node_modules/own-keys/LICENSE +21 -0
- node_modules/own-keys/README.md +45 -0
- node_modules/own-keys/index.d.ts +3 -0
- node_modules/own-keys/index.js +21 -0
- node_modules/own-keys/package.json +91 -0
- node_modules/own-keys/test/index.js +72 -0
- node_modules/own-keys/tsconfig.json +9 -0
- node_modules/p-limit/index.d.ts +42 -0
- node_modules/p-limit/index.js +71 -0
- node_modules/p-limit/license +9 -0
- node_modules/p-limit/package.json +52 -0
- node_modules/p-limit/readme.md +101 -0
- node_modules/p-locate/index.d.ts +53 -0
- node_modules/p-locate/index.js +50 -0
- node_modules/p-locate/license +9 -0
- node_modules/p-locate/package.json +54 -0
- node_modules/p-locate/readme.md +93 -0
- node_modules/p-try/index.d.ts +39 -0
- node_modules/p-try/index.js +9 -0
- node_modules/p-try/license +9 -0
- node_modules/p-try/package.json +42 -0
- node_modules/p-try/readme.md +58 -0
- node_modules/package-json-from-dist/LICENSE.md +63 -0
- node_modules/package-json-from-dist/README.md +110 -0
- node_modules/package-json-from-dist/package.json +68 -0
- node_modules/pako/CHANGELOG.md +164 -0
- node_modules/pako/LICENSE +21 -0
- node_modules/pako/README.md +191 -0
node_modules/optionator/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "optionator",
|
| 3 |
+
"version": "0.9.4",
|
| 4 |
+
"author": "George Zahariev <z@georgezahariev.com>",
|
| 5 |
+
"description": "option parsing and help generation",
|
| 6 |
+
"homepage": "https://github.com/gkz/optionator",
|
| 7 |
+
"keywords": [
|
| 8 |
+
"options",
|
| 9 |
+
"flags",
|
| 10 |
+
"option parsing",
|
| 11 |
+
"cli"
|
| 12 |
+
],
|
| 13 |
+
"files": [
|
| 14 |
+
"lib",
|
| 15 |
+
"README.md",
|
| 16 |
+
"LICENSE"
|
| 17 |
+
],
|
| 18 |
+
"main": "./lib/",
|
| 19 |
+
"bugs": "https://github.com/gkz/optionator/issues",
|
| 20 |
+
"license": "MIT",
|
| 21 |
+
"engines": {
|
| 22 |
+
"node": ">= 0.8.0"
|
| 23 |
+
},
|
| 24 |
+
"repository": {
|
| 25 |
+
"type": "git",
|
| 26 |
+
"url": "git://github.com/gkz/optionator.git"
|
| 27 |
+
},
|
| 28 |
+
"scripts": {
|
| 29 |
+
"test": "make test"
|
| 30 |
+
},
|
| 31 |
+
"dependencies": {
|
| 32 |
+
"prelude-ls": "^1.2.1",
|
| 33 |
+
"deep-is": "^0.1.3",
|
| 34 |
+
"word-wrap": "^1.2.5",
|
| 35 |
+
"type-check": "^0.4.0",
|
| 36 |
+
"levn": "^0.4.1",
|
| 37 |
+
"fast-levenshtein": "^2.0.6"
|
| 38 |
+
},
|
| 39 |
+
"devDependencies": {
|
| 40 |
+
"livescript": "^1.6.0",
|
| 41 |
+
"mocha": "^10.4.0"
|
| 42 |
+
}
|
| 43 |
+
}
|
node_modules/otplib/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2014 Gerald Yeo <contact@fusedthought.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/otplib/README.md
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# otplib
|
| 2 |
+
|
| 3 |
+
> Time-based (TOTP) and HMAC-based (HOTP) One-Time Password library
|
| 4 |
+
|
| 5 |
+
[![npm][badge-npm]][project-npm]
|
| 6 |
+
[![Build Status][badge-circle]][project-circle]
|
| 7 |
+
[![Coverage Status][badge-coveralls]][project-coveralls]
|
| 8 |
+
[![npm downloads][badge-npm-downloads]][project-npm]
|
| 9 |
+
[![TypeScript Support][badge-type-ts]][project-v-api]
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
<!-- TOC depthFrom:2 -->
|
| 14 |
+
|
| 15 |
+
- [About](#about)
|
| 16 |
+
- [Features](#features)
|
| 17 |
+
- [Quick Start](#quick-start)
|
| 18 |
+
- [In Node.js](#in-nodejs)
|
| 19 |
+
- [In Browser](#in-browser)
|
| 20 |
+
- [References](#references)
|
| 21 |
+
- [API / Demo Website](#api--demo-website)
|
| 22 |
+
- [Versioning](#versioning)
|
| 23 |
+
- [Migrating from v11.x](#migrating-from-v11x)
|
| 24 |
+
- [Available Options](#available-options)
|
| 25 |
+
- [HOTP Options](#hotp-options)
|
| 26 |
+
- [TOTP Options](#totp-options)
|
| 27 |
+
- [Authenticator Options](#authenticator-options)
|
| 28 |
+
- [Appendix](#appendix)
|
| 29 |
+
- [Type Definitions](#type-definitions)
|
| 30 |
+
- [Async Support](#async-support)
|
| 31 |
+
- [Browser Compatiblity](#browser-compatiblity)
|
| 32 |
+
- [Length of Secrets](#length-of-secrets)
|
| 33 |
+
- [Google Authenticator](#google-authenticator)
|
| 34 |
+
- [Difference between Authenticator and TOTP](#difference-between-authenticator-and-totp)
|
| 35 |
+
- [RFC3548 Base32](#rfc3548-base32)
|
| 36 |
+
- [Displaying a QR code](#displaying-a-qr-code)
|
| 37 |
+
- [Getting Time Remaining / Time Used](#getting-time-remaining--time-used)
|
| 38 |
+
- [Using with Expo](#using-with-expo)
|
| 39 |
+
- [Exploring with local-repl](#exploring-with-local-repl)
|
| 40 |
+
- [OTP Backup Codes](#otp-backup-codes)
|
| 41 |
+
- [Contributors](#contributors)
|
| 42 |
+
- [License](#license)
|
| 43 |
+
|
| 44 |
+
<!-- /TOC -->
|
| 45 |
+
|
| 46 |
+
## About
|
| 47 |
+
|
| 48 |
+
`otplib` is a JavaScript One Time Password (OTP) library for OTP generation and verification.
|
| 49 |
+
|
| 50 |
+
It implements both [HOTP][rfc-4226-wiki] - [RFC 4226][rfc-4226]
|
| 51 |
+
and [TOTP][rfc-6238-wiki] - [RFC 6238][rfc-6238],
|
| 52 |
+
and are tested against the test vectors provided in their respective RFC specifications.
|
| 53 |
+
These datasets can be found in the `tests/data` folder.
|
| 54 |
+
|
| 55 |
+
- [RFC 4226 Dataset][rfc-4226-dataset]
|
| 56 |
+
- [RFC 6238 Dataset][rfc-6238-dataset]
|
| 57 |
+
|
| 58 |
+
This library is also compatible with [Google Authenticator](https://github.com/google/google-authenticator),
|
| 59 |
+
and includes additional methods to allow you to work with Google Authenticator.
|
| 60 |
+
|
| 61 |
+
## Features
|
| 62 |
+
|
| 63 |
+
- Typescript support
|
| 64 |
+
- [Class][link-mdn-classes] interfaces
|
| 65 |
+
- [Function][link-mdn-functions] interfaces
|
| 66 |
+
- [Async][link-mdn-async] interfaces
|
| 67 |
+
- Pluggable modules (crypto / base32)
|
| 68 |
+
- `crypto (node)`
|
| 69 |
+
- `crypto-js`
|
| 70 |
+
- `@ronomon/crypto-async`
|
| 71 |
+
- `thirty-two`
|
| 72 |
+
- `base32-encode` + `base32-decode`
|
| 73 |
+
- Presets provided
|
| 74 |
+
- `browser`
|
| 75 |
+
- `default (node)`
|
| 76 |
+
- `default-async (same as default, but with async methods)`
|
| 77 |
+
- `v11 (adapter for previous version)`
|
| 78 |
+
|
| 79 |
+
## Quick Start
|
| 80 |
+
|
| 81 |
+
> If you need to customise your base32 or crypto libraries,
|
| 82 |
+
> check out the [In-Depth Guide][docs-in-depth] and [Available Packages][docs-available-packages]
|
| 83 |
+
|
| 84 |
+
### In Node.js
|
| 85 |
+
|
| 86 |
+
```bash
|
| 87 |
+
npm install otplib --save
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
```js
|
| 91 |
+
import { authenticator } from 'otplib';
|
| 92 |
+
|
| 93 |
+
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
|
| 94 |
+
// Alternative:
|
| 95 |
+
// const secret = authenticator.generateSecret();
|
| 96 |
+
// Note: .generateSecret() is only available for authenticator and not totp/hotp
|
| 97 |
+
|
| 98 |
+
const token = authenticator.generate(secret);
|
| 99 |
+
|
| 100 |
+
try {
|
| 101 |
+
const isValid = authenticator.check(token, secret);
|
| 102 |
+
// or
|
| 103 |
+
const isValid = authenticator.verify({ token, secret });
|
| 104 |
+
} catch (err) {
|
| 105 |
+
// Possible errors
|
| 106 |
+
// - options validation
|
| 107 |
+
// - "Invalid input - it is not base32 encoded string" (if thiry-two is used)
|
| 108 |
+
console.error(err);
|
| 109 |
+
}
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Please replace "authenticator" with "totp" or "hotp" depending on your requirements.
|
| 113 |
+
|
| 114 |
+
```js
|
| 115 |
+
// For TOTP
|
| 116 |
+
import { totp } from 'otplib';
|
| 117 |
+
const token = totp.generate(secret);
|
| 118 |
+
const isValid = totp.check(token, secret);
|
| 119 |
+
const isValid = totp.verify({ token, secret });
|
| 120 |
+
|
| 121 |
+
// For HOTP
|
| 122 |
+
import { hotp } from 'otplib';
|
| 123 |
+
const token = hotp.generate(secret, counter);
|
| 124 |
+
const isValid = hotp.check(token, secret, counter);
|
| 125 |
+
const isValid = hotp.verify({ token, secret, counter });
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
For all available APIs, please refer to [API Documentation][project-v-api].
|
| 129 |
+
|
| 130 |
+
### In Browser
|
| 131 |
+
|
| 132 |
+
The browser preset is a self-contained `umd` module, and it is provided in a separate bundle.
|
| 133 |
+
|
| 134 |
+
```bash
|
| 135 |
+
npm install @otplib/preset-browser --save
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
The following is an example, where we are using the scripts hosted by `unpkg.com`.
|
| 139 |
+
|
| 140 |
+
```html
|
| 141 |
+
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/buffer.js"></script>
|
| 142 |
+
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/index.js"></script>
|
| 143 |
+
|
| 144 |
+
<script type="text/javascript">
|
| 145 |
+
// window.otplib.authenticator
|
| 146 |
+
// window.otplib.hotp
|
| 147 |
+
// window.otplib.totp
|
| 148 |
+
</script>
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
For more details, please refer to the [@otplib/preset-browser documentation][docs-preset-browser].
|
| 152 |
+
|
| 153 |
+
## References
|
| 154 |
+
|
| 155 |
+
### API / Demo Website
|
| 156 |
+
|
| 157 |
+
| Version | Links |
|
| 158 |
+
| --------------- | ----------------------------------------------------------------------------------- |
|
| 159 |
+
| v12.x | [Website][project-v-site] / [API][project-v-api] / [Readme][project-v-readme] |
|
| 160 |
+
| v11.x | [API][project-v11-api] / [Readme][project-v11-readme] |
|
| 161 |
+
| v10.x and below | Available via git history |
|
| 162 |
+
|
| 163 |
+
### Versioning
|
| 164 |
+
|
| 165 |
+
This library follows `semver`. As such, major version bumps usually mean API changes or behavior changes.
|
| 166 |
+
Please check [upgrade notes](https://github.com/yeojz/otplib/wiki/upgrade-notes) for more information,
|
| 167 |
+
especially before making any major upgrades.
|
| 168 |
+
|
| 169 |
+
To simplify releases, all packages within this repository have their versions synced.
|
| 170 |
+
Therefore, if there are any releases or updates to a package, we will bump all packages.
|
| 171 |
+
|
| 172 |
+
Check out the release notes associated with each tagged versions
|
| 173 |
+
in the [releases](https://github.com/yeojz/otplib/releases) page.
|
| 174 |
+
|
| 175 |
+
| Release Type | Version Pattern | Command | |
|
| 176 |
+
| :---------------- | --------------- | ------------------------- | :------------------------------------ |
|
| 177 |
+
| Current / Stable | 0.0.0 | `npm install otplib` | [![npm][badge-npm]][project-npm] |
|
| 178 |
+
| Release Candidate | 0.0.0-0 | `npm install otplib@next` | [![npm][badge-npm-next]][project-npm] |
|
| 179 |
+
|
| 180 |
+
### Migrating from v11.x
|
| 181 |
+
|
| 182 |
+
> v12.x is a huge architectural and language rewrite. Please check out the docs if you are migrating.
|
| 183 |
+
> A preset adapter is available to provide methods that behave like `v11.x` of `otplib`.
|
| 184 |
+
|
| 185 |
+
```js
|
| 186 |
+
// Update
|
| 187 |
+
import { authenticator } from 'otplib'; // v11.x
|
| 188 |
+
// to
|
| 189 |
+
import { authenticator } from '@otplib/preset-v11';
|
| 190 |
+
|
| 191 |
+
// There should be no changes to your current code.
|
| 192 |
+
// However, deprecated or modified class methods will have console.warn.
|
| 193 |
+
```
|
| 194 |
+
|
| 195 |
+
### Available Options
|
| 196 |
+
|
| 197 |
+
All instantiated classes will have their options inherited from their respective options
|
| 198 |
+
generator. i.e. HOTP from `hotpOptions`, TOTP from `totpOptions`
|
| 199 |
+
and Authenticator from `authenticatorOptions`.
|
| 200 |
+
|
| 201 |
+
All OTP classes have an object setter and getter method to override these default options.
|
| 202 |
+
|
| 203 |
+
For example,
|
| 204 |
+
|
| 205 |
+
```js
|
| 206 |
+
import { authenticator, totp, hotp } from 'otplib';
|
| 207 |
+
|
| 208 |
+
// setting
|
| 209 |
+
authenticator.options = { digits: 6 };
|
| 210 |
+
totp.options = { digits: 6 };
|
| 211 |
+
hotp.options = { digits: 6 };
|
| 212 |
+
|
| 213 |
+
// getting
|
| 214 |
+
const opts = authenticator.options;
|
| 215 |
+
const opts = totp.options;
|
| 216 |
+
const opts = hotp.options;
|
| 217 |
+
|
| 218 |
+
// reset to default
|
| 219 |
+
authenticator.resetOptions();
|
| 220 |
+
totp.resetOptions();
|
| 221 |
+
hotp.resetOptions();
|
| 222 |
+
|
| 223 |
+
// getting all options, with validation
|
| 224 |
+
// and backfilled with library defaults
|
| 225 |
+
const opts = authenticator.allOptions();
|
| 226 |
+
const opts = totp.allOptions();
|
| 227 |
+
const opts = hotp.allOptions();
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
#### HOTP Options
|
| 231 |
+
|
| 232 |
+
| Option | Type | Description |
|
| 233 |
+
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
| 234 |
+
| algorithm | string | The algorithm used for calculating the HMAC. |
|
| 235 |
+
| createDigest | function | Creates the digest which token is derived from. |
|
| 236 |
+
| createHmacKey | function | Formats the secret into a HMAC key, applying transformations (like padding) where needed. |
|
| 237 |
+
| digest | string | **USE WITH CAUTION**. Same digest = same token. <br />Used in cases where digest is generated externally. (eg: async use cases) |
|
| 238 |
+
| digits | integer | The length of the token. |
|
| 239 |
+
| encoding | string | The encoding that was used on the secret. |
|
| 240 |
+
|
| 241 |
+
```js
|
| 242 |
+
// HOTP defaults
|
| 243 |
+
{
|
| 244 |
+
algorithm: 'sha1'
|
| 245 |
+
createDigest: undefined, // to be provided via a @otplib/plugin-*
|
| 246 |
+
createHmacKey: hotpCreateHmacKey,
|
| 247 |
+
digits: 6,
|
| 248 |
+
encoding: 'ascii',
|
| 249 |
+
}
|
| 250 |
+
```
|
| 251 |
+
|
| 252 |
+
#### TOTP Options
|
| 253 |
+
|
| 254 |
+
> Note: Includes all HOTP Options
|
| 255 |
+
|
| 256 |
+
| Option | Type | Description |
|
| 257 |
+
| ------ | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 258 |
+
| epoch | integer | **USE WITH CAUTION**. Same epoch = same token. <br />Starting time since the UNIX epoch (seconds). <br /> Epoch is JavaScript formatted. i.e. `Date.now()` or `UNIX time * 1000` |
|
| 259 |
+
| step | integer | Time step (seconds) |
|
| 260 |
+
| window | integer, <br /> [number, number] | Tokens in the previous and future x-windows that should be considered valid. <br /> If integer, same value will be used for both. <br /> Alternatively, define array: `[past, future]` |
|
| 261 |
+
|
| 262 |
+
```js
|
| 263 |
+
// TOTP defaults
|
| 264 |
+
{
|
| 265 |
+
// ...includes all HOTP defaults
|
| 266 |
+
createHmacKey: totpCreateHmacKey,
|
| 267 |
+
epoch: Date.now(),
|
| 268 |
+
step: 30,
|
| 269 |
+
window: 0,
|
| 270 |
+
}
|
| 271 |
+
```
|
| 272 |
+
|
| 273 |
+
#### Authenticator Options
|
| 274 |
+
|
| 275 |
+
> Note: Includes all HOTP + TOTP Options
|
| 276 |
+
|
| 277 |
+
| Option | Type | Description |
|
| 278 |
+
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------- |
|
| 279 |
+
| createRandomBytes | function | Creates a random string containing the defined number of bytes to be used in generating a secret key. |
|
| 280 |
+
| keyEncoder | function | Encodes a secret key into a Base32 string before it is sent to the user (in QR Code etc). |
|
| 281 |
+
| keyDecoder | function | Decodes the Base32 string given by the user into a secret. |
|
| 282 |
+
|
| 283 |
+
```js
|
| 284 |
+
// Authenticator defaults
|
| 285 |
+
{
|
| 286 |
+
// ...includes all HOTP + TOTP defaults
|
| 287 |
+
encoding: 'hex',
|
| 288 |
+
createRandomBytes: undefined, // to be provided via a @otplib/plugin-*
|
| 289 |
+
keyEncoder: undefined, // to be provided via a @otplib/plugin-*
|
| 290 |
+
keyDecoder: undefined, // to be provided via a @otplib/plugin-*
|
| 291 |
+
}
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
## Appendix
|
| 295 |
+
|
| 296 |
+
### Type Definitions
|
| 297 |
+
|
| 298 |
+
`TypeScript` support was introduced in `v10.0.0`, which added type definitions over `.js` files.
|
| 299 |
+
|
| 300 |
+
As of `v12.0.0`, the library has been re-written in Typescript from the ground up.
|
| 301 |
+
|
| 302 |
+
### Async Support
|
| 303 |
+
|
| 304 |
+
`async` support was introduced in `v12.0.0` as an additional core library.
|
| 305 |
+
|
| 306 |
+
This was added as some libraries like [expo.io][link-expo-crypto] or even
|
| 307 |
+
the browser API ([window.Crypto.subtle][link-mdn-subtlecrypto]) started providing
|
| 308 |
+
only async methods.
|
| 309 |
+
|
| 310 |
+
You to find more details in the [core-async][docs-core-async] folder.
|
| 311 |
+
|
| 312 |
+
### Browser Compatiblity
|
| 313 |
+
|
| 314 |
+
`@otplib/preset-browser` is a `umd` bundle with some node modules replaced to reduce the browser size.
|
| 315 |
+
|
| 316 |
+
The approximate size for the **optimised, minified + gzipped** bundle is **9.53KB**.
|
| 317 |
+
Paired with the gzipped browser `buffer.js` module, it would be about `7.65KB + 9.53KB = 17.18KB`.
|
| 318 |
+
|
| 319 |
+
For more details, please refer to the [@otplib/preset-browser documentation][docs-preset-browser].
|
| 320 |
+
|
| 321 |
+
### Length of Secrets
|
| 322 |
+
|
| 323 |
+
In [RFC 6238][rfc-6238], the secret / seed length for different algorithms are predefined:
|
| 324 |
+
|
| 325 |
+
```txt
|
| 326 |
+
HMAC-SHA1 - 20 bytes
|
| 327 |
+
HMAC-SHA256 - 32 bytes
|
| 328 |
+
HMAC-SHA512 - 64 bytes
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
As such, the length of the secret provided (after any decoding) will be padded and sliced
|
| 332 |
+
according to the expected length for respective algorithms.
|
| 333 |
+
|
| 334 |
+
### Google Authenticator
|
| 335 |
+
|
| 336 |
+
#### Difference between Authenticator and TOTP
|
| 337 |
+
|
| 338 |
+
The default encoding option has been set to `hex` (Authenticator) instead of `ascii` (TOTP).
|
| 339 |
+
|
| 340 |
+
#### RFC3548 Base32
|
| 341 |
+
|
| 342 |
+
> Note: [RFC4648][rfc-4648] obseletes [RFC 3548][rfc-3548].
|
| 343 |
+
> Any encoders following the newer specifications will work.
|
| 344 |
+
|
| 345 |
+
Google Authenticator requires keys to be base32 encoded.
|
| 346 |
+
It also requires the base32 encoder to be [RFC 3548][rfc-3548] compliant.
|
| 347 |
+
|
| 348 |
+
OTP calculation will still work should you want to use
|
| 349 |
+
other base32 encoding methods (like Crockford's Base32)
|
| 350 |
+
but it will NOT be compatible with Google Authenticator.
|
| 351 |
+
|
| 352 |
+
```js
|
| 353 |
+
const secret = authenticator.generateSecret(); // base32 encoded hex secret key
|
| 354 |
+
const token = authenticator.generate(secret);
|
| 355 |
+
```
|
| 356 |
+
|
| 357 |
+
#### Displaying a QR code
|
| 358 |
+
|
| 359 |
+
You may want to generate and display a QR Code so that users can scan
|
| 360 |
+
instead of manually entering the secret. Google Authenticator and similar apps
|
| 361 |
+
take in a QR code that holds a URL with the protocol `otpauth://`,
|
| 362 |
+
which you get from `authenticator.keyuri`.
|
| 363 |
+
|
| 364 |
+
Google Authenticator will ignore the `algorithm`, `digits`, and `step` options.
|
| 365 |
+
See the [keyuri documentation](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)
|
| 366 |
+
for more information.
|
| 367 |
+
|
| 368 |
+
If you are using a different authenticator app, check the documentation
|
| 369 |
+
for that app to see if any options are ignored, which will result in invalid tokens.
|
| 370 |
+
|
| 371 |
+
While this library provides the "otpauth" uri, you'll need a library to
|
| 372 |
+
generate the QR Code image.
|
| 373 |
+
|
| 374 |
+
An example is shown below:
|
| 375 |
+
|
| 376 |
+
```js
|
| 377 |
+
// npm install qrcode
|
| 378 |
+
import qrcode from 'qrcode';
|
| 379 |
+
import { authenticator } from '@otplib/preset-default';
|
| 380 |
+
|
| 381 |
+
const user = 'A user name, possibly an email';
|
| 382 |
+
const service = 'A service name';
|
| 383 |
+
|
| 384 |
+
// v11.x and above
|
| 385 |
+
const otpauth = authenticator.keyuri(user, service, secret);
|
| 386 |
+
|
| 387 |
+
// v10.x and below
|
| 388 |
+
const otpauth = authenticator.keyuri(
|
| 389 |
+
encodeURIComponent(user),
|
| 390 |
+
encodeURIComponent(service),
|
| 391 |
+
secret
|
| 392 |
+
);
|
| 393 |
+
|
| 394 |
+
qrcode.toDataURL(otpauth, (err, imageUrl) => {
|
| 395 |
+
if (err) {
|
| 396 |
+
console.log('Error with QR');
|
| 397 |
+
return;
|
| 398 |
+
}
|
| 399 |
+
console.log(imageUrl);
|
| 400 |
+
});
|
| 401 |
+
```
|
| 402 |
+
|
| 403 |
+
> **Note**: For versions `v10.x` and below, `keyuri` does not URI encode
|
| 404 |
+
> `user` and `service`. You'll need to do so before passing in the parameteres.
|
| 405 |
+
|
| 406 |
+
### Getting Time Remaining / Time Used
|
| 407 |
+
|
| 408 |
+
Helper methods for getting the remaining time and used time within a validity period
|
| 409 |
+
of a `totp` or `authenticator` token were introduced in `v10.0.0`.
|
| 410 |
+
|
| 411 |
+
```js
|
| 412 |
+
authenticator.timeUsed(); // or totp.timeUsed();
|
| 413 |
+
authenticator.timeRemaining(); // or totp.timeRemaining();
|
| 414 |
+
|
| 415 |
+
// The start of a new token would be when:
|
| 416 |
+
// - timeUsed() === 0
|
| 417 |
+
// - timeRemaining() === step
|
| 418 |
+
```
|
| 419 |
+
|
| 420 |
+
### Using with Expo
|
| 421 |
+
|
| 422 |
+
[Expo][link-expo-io] contains modified crypto implmentations targeted at the platform.
|
| 423 |
+
While `otplib` does not provide an `expo` specified package, with the re-architecture
|
| 424 |
+
of `otplib`, you can now provide an expo native `createDigest` to the library.
|
| 425 |
+
|
| 426 |
+
Alternatively, you can make use of crypto provided by `@otplib/plugin-crypto-js` or
|
| 427 |
+
the bundled browser umd module `@otplib/preset-browser`.
|
| 428 |
+
|
| 429 |
+
Pull Requests are much welcomed for a native expo implementation as well.
|
| 430 |
+
|
| 431 |
+
### Exploring with local-repl
|
| 432 |
+
|
| 433 |
+
If you'll like to explore the library with `local-repl` you can do so as well.
|
| 434 |
+
|
| 435 |
+
```bash
|
| 436 |
+
# after cloning the repo:
|
| 437 |
+
npm run setup
|
| 438 |
+
npm run build
|
| 439 |
+
npx local-repl
|
| 440 |
+
# You should see something like:
|
| 441 |
+
# Node v8.9.4, local-repl 4.0.0
|
| 442 |
+
# otplib 10.0.0
|
| 443 |
+
# Context: otplib
|
| 444 |
+
# [otplib] >
|
| 445 |
+
|
| 446 |
+
[otplib] > secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD'
|
| 447 |
+
[otplib] > otplib.authenticator.generate(secret)
|
| 448 |
+
```
|
| 449 |
+
|
| 450 |
+
### OTP Backup Codes
|
| 451 |
+
|
| 452 |
+
It is common for services to also provide a set of backup codes to authenticate
|
| 453 |
+
and bypass the OTP step in the event that you are not able to access your 2FA
|
| 454 |
+
device or have misplaced the device.
|
| 455 |
+
|
| 456 |
+
As this process is separate from the specifications for OTP, this library does not
|
| 457 |
+
provide any backup code related verification logic, and thus would have to be
|
| 458 |
+
implemented separately.
|
| 459 |
+
|
| 460 |
+
## Contributors
|
| 461 |
+
|
| 462 |
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
| 463 |
+
|
| 464 |
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
| 465 |
+
<!-- prettier-ignore-start -->
|
| 466 |
+
<!-- markdownlint-disable -->
|
| 467 |
+
<table>
|
| 468 |
+
<tr>
|
| 469 |
+
<td align="center"><a href="https://github.com/yeojz"><img src="https://avatars2.githubusercontent.com/u/429598?v=4" width="80px;" alt="Gerald Yeo"/><br /><sub><b>Gerald Yeo</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Code">💻</a> <a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Documentation">📖</a> <a href="#maintenance-yeojz" title="Maintenance">🚧</a> <a href="https://github.com/yeojz/otplib/commits?author=yeojz" title="Tests">⚠️</a></td>
|
| 470 |
+
<td align="center"><a href="https://ols.io"><img src="https://avatars3.githubusercontent.com/u/6209178?v=4" width="80px;" alt="Oliver Schneider"/><br /><sub><b>Oliver Schneider</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=olsio" title="Documentation">📖</a></td>
|
| 471 |
+
<td align="center"><a href="https://developer.mozilla.org/profiles/madarche/"><img src="https://avatars0.githubusercontent.com/u/152407?v=4" width="80px;" alt="Marc-Aurèle DARCHE"/><br /><sub><b>Marc-Aurèle DARCHE</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=madarche" title="Documentation">📖</a></td>
|
| 472 |
+
<td align="center"><a href="http://shakram02.github.io/"><img src="https://avatars3.githubusercontent.com/u/10996982?v=4" width="80px;" alt="Ahmed Hamdy (@shakram02)"/><br /><sub><b>Ahmed Hamdy (@shakram02)</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=shakram02" title="Documentation">📖</a></td>
|
| 473 |
+
<td align="center"><a href="https://tony.brix.ninja"><img src="https://avatars3.githubusercontent.com/u/97994?v=4" width="80px;" alt="Tony Brix"/><br /><sub><b>Tony Brix</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=UziTech" title="Code">💻</a> <a href="https://github.com/yeojz/otplib/commits?author=UziTech" title="Documentation">📖</a></td>
|
| 474 |
+
<td align="center"><a href="https://github.com/encX"><img src="https://avatars3.githubusercontent.com/u/5965883?v=4" width="80px;" alt="Plai"/><br /><sub><b>Plai</b></sub></a><br /><a href="https://github.com/yeojz/otplib/commits?author=encX" title="Documentation">📖</a></td>
|
| 475 |
+
</tr>
|
| 476 |
+
</table>
|
| 477 |
+
|
| 478 |
+
<!-- markdownlint-enable -->
|
| 479 |
+
<!-- prettier-ignore-end -->
|
| 480 |
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
| 481 |
+
|
| 482 |
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
|
| 483 |
+
specification. Contributions of any kind welcome!
|
| 484 |
+
|
| 485 |
+
## License
|
| 486 |
+
|
| 487 |
+
`otplib` is [MIT licensed][project-license]
|
| 488 |
+
|
| 489 |
+
<img width="150" src="https://otplib.yeojz.dev/otplib.png" />
|
| 490 |
+
|
| 491 |
+
<!-- Badges -->
|
| 492 |
+
|
| 493 |
+
[badge-circle]: https://img.shields.io/circleci/project/github/yeojz/otplib/master.svg?style=flat-square
|
| 494 |
+
[badge-coveralls]: https://img.shields.io/coveralls/yeojz/otplib/master.svg?style=flat-square
|
| 495 |
+
[badge-npm-downloads]: https://img.shields.io/npm/dt/otplib.svg?style=flat-square
|
| 496 |
+
[badge-npm-next]: https://img.shields.io/npm/v/otplib/next.svg?style=flat-square
|
| 497 |
+
[badge-npm]: https://img.shields.io/npm/v/otplib.svg?style=flat-square
|
| 498 |
+
[badge-type-ts]: https://img.shields.io/badge/typedef-.d.ts-blue.svg?style=flat-square&longCache=true
|
| 499 |
+
|
| 500 |
+
<!-- External Links -->
|
| 501 |
+
|
| 502 |
+
[link-expo-crypto]: https://docs.expo.io/versions/v33.0.0/sdk/crypto/
|
| 503 |
+
[link-expo-io]: https://expo.io
|
| 504 |
+
[link-mdn-async]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
|
| 505 |
+
[link-mdn-classes]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
|
| 506 |
+
[link-mdn-functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
|
| 507 |
+
[link-mdn-subtlecrypto]: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
|
| 508 |
+
[link-npm-buffer]: https://www.npmjs.com/package/buffer
|
| 509 |
+
[rfc-3548]: http://tools.ietf.org/html/rfc3548
|
| 510 |
+
[rfc-4226-dataset]: https://github.com/yeojz/otplib/blob/master/tests/data/rfc-4226.ts
|
| 511 |
+
[rfc-4226-wiki]: http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm
|
| 512 |
+
[rfc-4226]: http://tools.ietf.org/html/rfc4226
|
| 513 |
+
[rfc-4648]: https://tools.ietf.org/html/rfc4648
|
| 514 |
+
[rfc-6238-dataset]: https://github.com/yeojz/otplib/blob/master/tests/data/rfc-6238.ts
|
| 515 |
+
[rfc-6238-wiki]: http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
|
| 516 |
+
[rfc-6238]: http://tools.ietf.org/html/rfc6238
|
| 517 |
+
|
| 518 |
+
<!-- Project Links -->
|
| 519 |
+
|
| 520 |
+
[docs-available-packages]: https://github.com/yeojz/otplib/blob/master/packages/README.md
|
| 521 |
+
[docs-core-async]: https://github.com/yeojz/otplib/blob/master/packages/otplib-core-async/README.md
|
| 522 |
+
[docs-in-depth]: https://github.com/yeojz/otplib/blob/master/packages/otplib-core/README.md#getting-started
|
| 523 |
+
[docs-preset-browser-src]: https://github.com/yeojz/otplib/blob/master/packages/otplib-preset-browser/src/index.ts
|
| 524 |
+
[docs-preset-browser]: https://github.com/yeojz/otplib/blob/master/packages/otplib-preset-browser/README.md
|
| 525 |
+
[project-circle]: https://circleci.com/gh/yeojz/otplib
|
| 526 |
+
[project-coveralls]: https://coveralls.io/github/yeojz/otplib
|
| 527 |
+
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
|
| 528 |
+
[project-npm]: https://www.npmjs.com/package/otplib
|
| 529 |
+
[project-repo]: https://github.com/yeojz/otplib
|
| 530 |
+
[project-v-api]: https://otplib.yeojz.dev/api
|
| 531 |
+
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
|
| 532 |
+
[project-v-site]: https://otplib.yeojz.dev
|
| 533 |
+
[project-v11-api]: https://5d4d0cc4c85e00000788a456--otplib.netlify.com/docs
|
| 534 |
+
[project-v11-readme]: https://github.com/yeojz/otplib/blob/d0aedccbca8ae7ec1983f40da4d7a14c9e815e9c/README.md
|
node_modules/otplib/core.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from '@otplib/core';
|
node_modules/otplib/core.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* otplib
|
| 3 |
+
*
|
| 4 |
+
* @author Gerald Yeo <contact@fusedthought.com>
|
| 5 |
+
* @version: 12.0.1
|
| 6 |
+
* @license: MIT
|
| 7 |
+
**/
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
Object.defineProperty(exports, '__esModule', { value: true });
|
| 11 |
+
|
| 12 |
+
var core = require('@otplib/core');
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Object.keys(core).forEach(function (k) {
|
| 17 |
+
if (k !== 'default') Object.defineProperty(exports, k, {
|
| 18 |
+
enumerable: true,
|
| 19 |
+
get: function () {
|
| 20 |
+
return core[k];
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
});
|
node_modules/otplib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from '@otplib/preset-default';
|
node_modules/otplib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* otplib
|
| 3 |
+
*
|
| 4 |
+
* @author Gerald Yeo <contact@fusedthought.com>
|
| 5 |
+
* @version: 12.0.1
|
| 6 |
+
* @license: MIT
|
| 7 |
+
**/
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
Object.defineProperty(exports, '__esModule', { value: true });
|
| 11 |
+
|
| 12 |
+
var presetDefault = require('@otplib/preset-default');
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Object.keys(presetDefault).forEach(function (k) {
|
| 17 |
+
if (k !== 'default') Object.defineProperty(exports, k, {
|
| 18 |
+
enumerable: true,
|
| 19 |
+
get: function () {
|
| 20 |
+
return presetDefault[k];
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
});
|
node_modules/otplib/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "otplib",
|
| 3 |
+
"description": "HMAC-based (HOTP) and Time-based (TOTP) One-Time Password library",
|
| 4 |
+
"version": "12.0.1",
|
| 5 |
+
"main": "./index.js",
|
| 6 |
+
"publishConfig": {
|
| 7 |
+
"access": "public"
|
| 8 |
+
},
|
| 9 |
+
"scripts": {},
|
| 10 |
+
"dependencies": {
|
| 11 |
+
"@otplib/core": "^12.0.1",
|
| 12 |
+
"@otplib/preset-default": "^12.0.1",
|
| 13 |
+
"@otplib/preset-v11": "^12.0.1"
|
| 14 |
+
},
|
| 15 |
+
"otplib": {},
|
| 16 |
+
"keywords": [
|
| 17 |
+
"totp",
|
| 18 |
+
"hotp",
|
| 19 |
+
"otp",
|
| 20 |
+
"authenticator",
|
| 21 |
+
"one time password",
|
| 22 |
+
"google authenticator",
|
| 23 |
+
"authentication",
|
| 24 |
+
"2FA",
|
| 25 |
+
"2 factor",
|
| 26 |
+
"node",
|
| 27 |
+
"browser"
|
| 28 |
+
],
|
| 29 |
+
"author": "Gerald Yeo <contact@fusedthought.com>",
|
| 30 |
+
"license": "MIT",
|
| 31 |
+
"homepage": "https://yeojz.otplib.dev",
|
| 32 |
+
"repository": "https://github.com/yeojz/otplib",
|
| 33 |
+
"types": "./index.d.ts"
|
| 34 |
+
}
|
node_modules/otplib/v11.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from '@otplib/preset-v11';
|
node_modules/otplib/v11.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* otplib
|
| 3 |
+
*
|
| 4 |
+
* @author Gerald Yeo <contact@fusedthought.com>
|
| 5 |
+
* @version: 12.0.1
|
| 6 |
+
* @license: MIT
|
| 7 |
+
**/
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
Object.defineProperty(exports, '__esModule', { value: true });
|
| 11 |
+
|
| 12 |
+
var presetV11 = require('@otplib/preset-v11');
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Object.keys(presetV11).forEach(function (k) {
|
| 17 |
+
if (k !== 'default') Object.defineProperty(exports, k, {
|
| 18 |
+
enumerable: true,
|
| 19 |
+
get: function () {
|
| 20 |
+
return presetV11[k];
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
});
|
node_modules/outvariant/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2021–present Artem Zakharchenko
|
| 4 |
+
|
| 5 |
+
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:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
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.
|
node_modules/outvariant/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# `outvariant`
|
| 2 |
+
|
| 3 |
+
Type-safe implementation of invariant with positionals.
|
| 4 |
+
|
| 5 |
+
## Motivation
|
| 6 |
+
|
| 7 |
+
### Type-safely
|
| 8 |
+
|
| 9 |
+
This implementation asserts the given predicate expression so it's treated as non-nullable after the `invariant` call:
|
| 10 |
+
|
| 11 |
+
```ts
|
| 12 |
+
// Regular invariant:
|
| 13 |
+
invariant(user, 'Failed to fetch')
|
| 14 |
+
user?.firstName // "user" is possibly undefined
|
| 15 |
+
|
| 16 |
+
// Outvariant:
|
| 17 |
+
invariant(user, 'Failed to fetch')
|
| 18 |
+
user.firstName // OK, "invariant" ensured the "user" exists
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### Positionals support
|
| 22 |
+
|
| 23 |
+
This implementation uses [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) to support dynamic number of positionals:
|
| 24 |
+
|
| 25 |
+
```js
|
| 26 |
+
invariant(predicate, 'Expected %s but got %s', 'one', false)
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## What is this for?
|
| 30 |
+
|
| 31 |
+
Invariant is a shorthand function that asserts a given predicate and throws an error if that predicate is false.
|
| 32 |
+
|
| 33 |
+
Compare these two pieces of code identical in behavior:
|
| 34 |
+
|
| 35 |
+
```js
|
| 36 |
+
if (!token) {
|
| 37 |
+
throw new Error(`Expected a token to be set but got ${typeof token}`)
|
| 38 |
+
}
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
```js
|
| 42 |
+
import { invariant } from 'outvariant'
|
| 43 |
+
|
| 44 |
+
invariant(token, 'Expected a token to be set but got %s', typeof token)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Using `invariant` reduces the visual nesting of the code and leads to cleaner error messages thanks to formatted positionals (i.e. the `%s` (string) positional above).
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
|
| 51 |
+
### Install
|
| 52 |
+
|
| 53 |
+
```sh
|
| 54 |
+
npm install outvariant
|
| 55 |
+
# or
|
| 56 |
+
yarn add outvariant
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
> You may want to install this library as a dev dependency (`-D`) based on your usage.
|
| 60 |
+
|
| 61 |
+
### Write an assertion
|
| 62 |
+
|
| 63 |
+
```js
|
| 64 |
+
import { invariant } from 'outvariant'
|
| 65 |
+
|
| 66 |
+
invariant(user, 'Failed to load: expected user, but got %o', user)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Positionals
|
| 70 |
+
|
| 71 |
+
The following positional tokens are supported:
|
| 72 |
+
|
| 73 |
+
| Token | Expected value type |
|
| 74 |
+
| --------- | ------------------------------------------------------- |
|
| 75 |
+
| `%s` | String |
|
| 76 |
+
| `%d`/`%i` | Number |
|
| 77 |
+
| `%j` | JSON (non-stringified) |
|
| 78 |
+
| `%o` | Arbitrary object or object-like (i.e. a class instance) |
|
| 79 |
+
|
| 80 |
+
Whenever present in the error message, a positional token will look up the value to insert in its place from the arguments given to `invariant`.
|
| 81 |
+
|
| 82 |
+
```js
|
| 83 |
+
invariant(
|
| 84 |
+
false,
|
| 85 |
+
'Expected the "%s" property but got %j',
|
| 86 |
+
// Note that positionals are sensitive to order:
|
| 87 |
+
// - "firstName" replaces "%s" because it's first.
|
| 88 |
+
// - {"id":1} replaces "%j" because it's second.
|
| 89 |
+
'firstName',
|
| 90 |
+
{
|
| 91 |
+
id: 1,
|
| 92 |
+
}
|
| 93 |
+
)
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## Polymorphic errors
|
| 97 |
+
|
| 98 |
+
It is possible to throw a custom `Error` instance using `invariant.as`:
|
| 99 |
+
|
| 100 |
+
```js
|
| 101 |
+
import { invariant } from 'outvariant'
|
| 102 |
+
|
| 103 |
+
class NetworkError extends Error {
|
| 104 |
+
constructor(message) {
|
| 105 |
+
super(message)
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
invariant.as(NetworkError, res.fulfilled, 'Failed to handle response')
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Note that providing a custom error constructor as the argument to `invariant.as` requires the custom constructor's signature to be compatible with the `Error` class constructor.
|
| 113 |
+
|
| 114 |
+
If your error constructor has a different signature, you can pass a function as the first argument to `invariant.as` that creates a new custom error instance.
|
| 115 |
+
|
| 116 |
+
```js
|
| 117 |
+
import { invariant } from 'outvariant'
|
| 118 |
+
|
| 119 |
+
class NetworkError extends Error {
|
| 120 |
+
constructor(statusCode, message) {
|
| 121 |
+
super(message)
|
| 122 |
+
this.statusCode = statusCode
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
invariant.as(
|
| 127 |
+
(message) => new NetworkError(500, message),
|
| 128 |
+
res.fulfilled,
|
| 129 |
+
'Failed to handle response'
|
| 130 |
+
)
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
Abstract the error into helper functions for flexibility:
|
| 134 |
+
|
| 135 |
+
```js
|
| 136 |
+
function toNetworkError(statusCode) {
|
| 137 |
+
return (message) => new NetworkError(statusCode, message)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
invariant.as(toNetworkError(404), res?.user?.id, 'User Not Found')
|
| 141 |
+
invariant.as(toNetworkError(500), res.fulfilled, 'Internal Server Error')
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
## Contributing
|
| 145 |
+
|
| 146 |
+
Please [open an issue](https://github.com/open-draft/outvariant/issues) or [submit a pull request](https://github.com/open-draft/outvariant/pulls) if you wish to contribute. Thank you.
|
node_modules/outvariant/lib/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare class InvariantError extends Error {
|
| 2 |
+
readonly message: string;
|
| 3 |
+
name: string;
|
| 4 |
+
constructor(message: string, ...positionals: any[]);
|
| 5 |
+
}
|
| 6 |
+
interface CustomErrorConstructor {
|
| 7 |
+
new (message: string): Error;
|
| 8 |
+
}
|
| 9 |
+
interface CustomErrorFactory {
|
| 10 |
+
(message: string): Error;
|
| 11 |
+
}
|
| 12 |
+
declare type CustomError = CustomErrorConstructor | CustomErrorFactory;
|
| 13 |
+
declare type Invariant = {
|
| 14 |
+
(predicate: unknown, message: string, ...positionals: any[]): asserts predicate;
|
| 15 |
+
as(ErrorConstructor: CustomError, predicate: unknown, message: string, ...positionals: unknown[]): asserts predicate;
|
| 16 |
+
};
|
| 17 |
+
declare const invariant: Invariant;
|
| 18 |
+
|
| 19 |
+
declare function format(message: string, ...positionals: any[]): string;
|
| 20 |
+
|
| 21 |
+
export { CustomError, CustomErrorConstructor, CustomErrorFactory, InvariantError, format, invariant };
|
node_modules/outvariant/lib/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
|
| 20 |
+
// src/index.ts
|
| 21 |
+
var src_exports = {};
|
| 22 |
+
__export(src_exports, {
|
| 23 |
+
InvariantError: () => InvariantError,
|
| 24 |
+
format: () => format,
|
| 25 |
+
invariant: () => invariant
|
| 26 |
+
});
|
| 27 |
+
module.exports = __toCommonJS(src_exports);
|
| 28 |
+
|
| 29 |
+
// src/format.ts
|
| 30 |
+
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
| 31 |
+
function serializePositional(positional, flag) {
|
| 32 |
+
switch (flag) {
|
| 33 |
+
case "s":
|
| 34 |
+
return positional;
|
| 35 |
+
case "d":
|
| 36 |
+
case "i":
|
| 37 |
+
return Number(positional);
|
| 38 |
+
case "j":
|
| 39 |
+
return JSON.stringify(positional);
|
| 40 |
+
case "o": {
|
| 41 |
+
if (typeof positional === "string") {
|
| 42 |
+
return positional;
|
| 43 |
+
}
|
| 44 |
+
const json = JSON.stringify(positional);
|
| 45 |
+
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
| 46 |
+
return positional;
|
| 47 |
+
}
|
| 48 |
+
return json;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
function format(message, ...positionals) {
|
| 53 |
+
if (positionals.length === 0) {
|
| 54 |
+
return message;
|
| 55 |
+
}
|
| 56 |
+
let positionalIndex = 0;
|
| 57 |
+
let formattedMessage = message.replace(
|
| 58 |
+
POSITIONALS_EXP,
|
| 59 |
+
(match, isEscaped, _, flag) => {
|
| 60 |
+
const positional = positionals[positionalIndex];
|
| 61 |
+
const value = serializePositional(positional, flag);
|
| 62 |
+
if (!isEscaped) {
|
| 63 |
+
positionalIndex++;
|
| 64 |
+
return value;
|
| 65 |
+
}
|
| 66 |
+
return match;
|
| 67 |
+
}
|
| 68 |
+
);
|
| 69 |
+
if (positionalIndex < positionals.length) {
|
| 70 |
+
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
| 71 |
+
}
|
| 72 |
+
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
| 73 |
+
return formattedMessage;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// src/invariant.ts
|
| 77 |
+
var STACK_FRAMES_TO_IGNORE = 2;
|
| 78 |
+
function cleanErrorStack(error) {
|
| 79 |
+
if (!error.stack) {
|
| 80 |
+
return;
|
| 81 |
+
}
|
| 82 |
+
const nextStack = error.stack.split("\n");
|
| 83 |
+
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
|
| 84 |
+
error.stack = nextStack.join("\n");
|
| 85 |
+
}
|
| 86 |
+
var InvariantError = class extends Error {
|
| 87 |
+
constructor(message, ...positionals) {
|
| 88 |
+
super(message);
|
| 89 |
+
this.message = message;
|
| 90 |
+
this.name = "Invariant Violation";
|
| 91 |
+
this.message = format(message, ...positionals);
|
| 92 |
+
cleanErrorStack(this);
|
| 93 |
+
}
|
| 94 |
+
};
|
| 95 |
+
var invariant = (predicate, message, ...positionals) => {
|
| 96 |
+
if (!predicate) {
|
| 97 |
+
throw new InvariantError(message, ...positionals);
|
| 98 |
+
}
|
| 99 |
+
};
|
| 100 |
+
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
| 101 |
+
if (!predicate) {
|
| 102 |
+
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
|
| 103 |
+
let error;
|
| 104 |
+
try {
|
| 105 |
+
error = Reflect.construct(ErrorConstructor, [
|
| 106 |
+
formatMessage
|
| 107 |
+
]);
|
| 108 |
+
} catch (err) {
|
| 109 |
+
error = ErrorConstructor(formatMessage);
|
| 110 |
+
}
|
| 111 |
+
throw error;
|
| 112 |
+
}
|
| 113 |
+
};
|
| 114 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 115 |
+
0 && (module.exports = {
|
| 116 |
+
InvariantError,
|
| 117 |
+
format,
|
| 118 |
+
invariant
|
| 119 |
+
});
|
| 120 |
+
//# sourceMappingURL=index.js.map
|
node_modules/outvariant/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../src/index.ts","../src/format.ts","../src/invariant.ts"],"sourcesContent":["export * from './invariant'\nexport * from './format'\n","const POSITIONALS_EXP = /(%?)(%([sdijo]))/g\n\nfunction serializePositional(positional: any, flag: string): any {\n switch (flag) {\n // Strings.\n case 's':\n return positional\n\n // Digits.\n case 'd':\n case 'i':\n return Number(positional)\n\n // JSON.\n case 'j':\n return JSON.stringify(positional)\n\n // Objects.\n case 'o': {\n // Preserve stings to prevent extra quotes around them.\n if (typeof positional === 'string') {\n return positional\n }\n\n const json = JSON.stringify(positional)\n\n // If the positional isn't serializable, return it as-is.\n if (json === '{}' || json === '[]' || /^\\[object .+?\\]$/.test(json)) {\n return positional\n }\n\n return json\n }\n }\n}\n\nexport function format(message: string, ...positionals: any[]): string {\n if (positionals.length === 0) {\n return message\n }\n\n let positionalIndex = 0\n let formattedMessage = message.replace(\n POSITIONALS_EXP,\n (match, isEscaped, _, flag) => {\n const positional = positionals[positionalIndex]\n const value = serializePositional(positional, flag)\n\n if (!isEscaped) {\n positionalIndex++\n return value\n }\n\n return match\n }\n )\n\n // Append unresolved positionals to string as-is.\n if (positionalIndex < positionals.length) {\n formattedMessage += ` ${positionals.slice(positionalIndex).join(' ')}`\n }\n\n formattedMessage = formattedMessage.replace(/%{2,2}/g, '%')\n\n return formattedMessage\n}\n","import { format } from './format'\n\nconst STACK_FRAMES_TO_IGNORE = 2\n\n/**\n * Remove the \"outvariant\" package trace from the given error.\n * This scopes down the error stack to the relevant parts\n * when used in other applications.\n */\nfunction cleanErrorStack(error: Error): void {\n if (!error.stack) {\n return\n }\n\n const nextStack = error.stack.split('\\n')\n nextStack.splice(1, STACK_FRAMES_TO_IGNORE)\n error.stack = nextStack.join('\\n')\n}\n\nexport class InvariantError extends Error {\n name = 'Invariant Violation'\n\n constructor(public readonly message: string, ...positionals: any[]) {\n super(message)\n this.message = format(message, ...positionals)\n cleanErrorStack(this)\n }\n}\n\nexport interface CustomErrorConstructor {\n new (message: string): Error\n}\n\nexport interface CustomErrorFactory {\n (message: string): Error\n}\n\nexport type CustomError = CustomErrorConstructor | CustomErrorFactory\n\ntype Invariant = {\n (\n predicate: unknown,\n message: string,\n ...positionals: any[]\n ): asserts predicate\n\n as(\n ErrorConstructor: CustomError,\n predicate: unknown,\n message: string,\n ...positionals: unknown[]\n ): asserts predicate\n}\n\nexport const invariant: Invariant = (\n predicate,\n message,\n ...positionals\n): asserts predicate => {\n if (!predicate) {\n throw new InvariantError(message, ...positionals)\n }\n}\n\ninvariant.as = (ErrorConstructor, predicate, message, ...positionals) => {\n if (!predicate) {\n const formatMessage =\n positionals.length === 0 ? message : format(message, ...positionals)\n let error: Error\n\n try {\n error = Reflect.construct(ErrorConstructor as CustomErrorConstructor, [\n formatMessage,\n ])\n } catch (err) {\n error = (ErrorConstructor as CustomErrorFactory)(formatMessage)\n }\n\n throw error\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,kBAAkB;AAExB,SAAS,oBAAoB,YAAiB,MAAmB;AAC/D,UAAQ,MAAM;AAAA,IAEZ,KAAK;AACH,aAAO;AAAA,IAGT,KAAK;AAAA,IACL,KAAK;AACH,aAAO,OAAO,UAAU;AAAA,IAG1B,KAAK;AACH,aAAO,KAAK,UAAU,UAAU;AAAA,IAGlC,KAAK,KAAK;AAER,UAAI,OAAO,eAAe,UAAU;AAClC,eAAO;AAAA,MACT;AAEA,YAAM,OAAO,KAAK,UAAU,UAAU;AAGtC,UAAI,SAAS,QAAQ,SAAS,QAAQ,mBAAmB,KAAK,IAAI,GAAG;AACnE,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,OAAO,YAAoB,aAA4B;AACrE,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB;AACtB,MAAI,mBAAmB,QAAQ;AAAA,IAC7B;AAAA,IACA,CAAC,OAAO,WAAW,GAAG,SAAS;AAC7B,YAAM,aAAa,YAAY;AAC/B,YAAM,QAAQ,oBAAoB,YAAY,IAAI;AAElD,UAAI,CAAC,WAAW;AACd;AACA,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,MAAI,kBAAkB,YAAY,QAAQ;AACxC,wBAAoB,IAAI,YAAY,MAAM,eAAe,EAAE,KAAK,GAAG;AAAA,EACrE;AAEA,qBAAmB,iBAAiB,QAAQ,WAAW,GAAG;AAE1D,SAAO;AACT;;;AC/DA,IAAM,yBAAyB;AAO/B,SAAS,gBAAgB,OAAoB;AAC3C,MAAI,CAAC,MAAM,OAAO;AAChB;AAAA,EACF;AAEA,QAAM,YAAY,MAAM,MAAM,MAAM,IAAI;AACxC,YAAU,OAAO,GAAG,sBAAsB;AAC1C,QAAM,QAAQ,UAAU,KAAK,IAAI;AACnC;AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAGxC,YAA4B,YAAoB,aAAoB;AAClE,UAAM,OAAO;AADa;AAF5B,gBAAO;AAIL,SAAK,UAAU,OAAO,SAAS,GAAG,WAAW;AAC7C,oBAAgB,IAAI;AAAA,EACtB;AACF;AA2BO,IAAM,YAAuB,CAClC,WACA,YACG,gBACmB;AACtB,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,eAAe,SAAS,GAAG,WAAW;AAAA,EAClD;AACF;AAEA,UAAU,KAAK,CAAC,kBAAkB,WAAW,YAAY,gBAAgB;AACvE,MAAI,CAAC,WAAW;AACd,UAAM,gBACJ,YAAY,WAAW,IAAI,UAAU,OAAO,SAAS,GAAG,WAAW;AACrE,QAAI;AAEJ,QAAI;AACF,cAAQ,QAAQ,UAAU,kBAA4C;AAAA,QACpE;AAAA,MACF,CAAC;AAAA,IACH,SAAS,KAAP;AACA,cAAS,iBAAwC,aAAa;AAAA,IAChE;AAEA,UAAM;AAAA,EACR;AACF;","names":[]}
|
node_modules/outvariant/lib/index.mjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/format.ts
|
| 2 |
+
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
| 3 |
+
function serializePositional(positional, flag) {
|
| 4 |
+
switch (flag) {
|
| 5 |
+
case "s":
|
| 6 |
+
return positional;
|
| 7 |
+
case "d":
|
| 8 |
+
case "i":
|
| 9 |
+
return Number(positional);
|
| 10 |
+
case "j":
|
| 11 |
+
return JSON.stringify(positional);
|
| 12 |
+
case "o": {
|
| 13 |
+
if (typeof positional === "string") {
|
| 14 |
+
return positional;
|
| 15 |
+
}
|
| 16 |
+
const json = JSON.stringify(positional);
|
| 17 |
+
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
| 18 |
+
return positional;
|
| 19 |
+
}
|
| 20 |
+
return json;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
function format(message, ...positionals) {
|
| 25 |
+
if (positionals.length === 0) {
|
| 26 |
+
return message;
|
| 27 |
+
}
|
| 28 |
+
let positionalIndex = 0;
|
| 29 |
+
let formattedMessage = message.replace(
|
| 30 |
+
POSITIONALS_EXP,
|
| 31 |
+
(match, isEscaped, _, flag) => {
|
| 32 |
+
const positional = positionals[positionalIndex];
|
| 33 |
+
const value = serializePositional(positional, flag);
|
| 34 |
+
if (!isEscaped) {
|
| 35 |
+
positionalIndex++;
|
| 36 |
+
return value;
|
| 37 |
+
}
|
| 38 |
+
return match;
|
| 39 |
+
}
|
| 40 |
+
);
|
| 41 |
+
if (positionalIndex < positionals.length) {
|
| 42 |
+
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
| 43 |
+
}
|
| 44 |
+
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
| 45 |
+
return formattedMessage;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// src/invariant.ts
|
| 49 |
+
var STACK_FRAMES_TO_IGNORE = 2;
|
| 50 |
+
function cleanErrorStack(error) {
|
| 51 |
+
if (!error.stack) {
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
const nextStack = error.stack.split("\n");
|
| 55 |
+
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
|
| 56 |
+
error.stack = nextStack.join("\n");
|
| 57 |
+
}
|
| 58 |
+
var InvariantError = class extends Error {
|
| 59 |
+
constructor(message, ...positionals) {
|
| 60 |
+
super(message);
|
| 61 |
+
this.message = message;
|
| 62 |
+
this.name = "Invariant Violation";
|
| 63 |
+
this.message = format(message, ...positionals);
|
| 64 |
+
cleanErrorStack(this);
|
| 65 |
+
}
|
| 66 |
+
};
|
| 67 |
+
var invariant = (predicate, message, ...positionals) => {
|
| 68 |
+
if (!predicate) {
|
| 69 |
+
throw new InvariantError(message, ...positionals);
|
| 70 |
+
}
|
| 71 |
+
};
|
| 72 |
+
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
| 73 |
+
if (!predicate) {
|
| 74 |
+
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
|
| 75 |
+
let error;
|
| 76 |
+
try {
|
| 77 |
+
error = Reflect.construct(ErrorConstructor, [
|
| 78 |
+
formatMessage
|
| 79 |
+
]);
|
| 80 |
+
} catch (err) {
|
| 81 |
+
error = ErrorConstructor(formatMessage);
|
| 82 |
+
}
|
| 83 |
+
throw error;
|
| 84 |
+
}
|
| 85 |
+
};
|
| 86 |
+
export {
|
| 87 |
+
InvariantError,
|
| 88 |
+
format,
|
| 89 |
+
invariant
|
| 90 |
+
};
|
| 91 |
+
//# sourceMappingURL=index.mjs.map
|
node_modules/outvariant/lib/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../src/format.ts","../src/invariant.ts"],"sourcesContent":["const POSITIONALS_EXP = /(%?)(%([sdijo]))/g\n\nfunction serializePositional(positional: any, flag: string): any {\n switch (flag) {\n // Strings.\n case 's':\n return positional\n\n // Digits.\n case 'd':\n case 'i':\n return Number(positional)\n\n // JSON.\n case 'j':\n return JSON.stringify(positional)\n\n // Objects.\n case 'o': {\n // Preserve stings to prevent extra quotes around them.\n if (typeof positional === 'string') {\n return positional\n }\n\n const json = JSON.stringify(positional)\n\n // If the positional isn't serializable, return it as-is.\n if (json === '{}' || json === '[]' || /^\\[object .+?\\]$/.test(json)) {\n return positional\n }\n\n return json\n }\n }\n}\n\nexport function format(message: string, ...positionals: any[]): string {\n if (positionals.length === 0) {\n return message\n }\n\n let positionalIndex = 0\n let formattedMessage = message.replace(\n POSITIONALS_EXP,\n (match, isEscaped, _, flag) => {\n const positional = positionals[positionalIndex]\n const value = serializePositional(positional, flag)\n\n if (!isEscaped) {\n positionalIndex++\n return value\n }\n\n return match\n }\n )\n\n // Append unresolved positionals to string as-is.\n if (positionalIndex < positionals.length) {\n formattedMessage += ` ${positionals.slice(positionalIndex).join(' ')}`\n }\n\n formattedMessage = formattedMessage.replace(/%{2,2}/g, '%')\n\n return formattedMessage\n}\n","import { format } from './format'\n\nconst STACK_FRAMES_TO_IGNORE = 2\n\n/**\n * Remove the \"outvariant\" package trace from the given error.\n * This scopes down the error stack to the relevant parts\n * when used in other applications.\n */\nfunction cleanErrorStack(error: Error): void {\n if (!error.stack) {\n return\n }\n\n const nextStack = error.stack.split('\\n')\n nextStack.splice(1, STACK_FRAMES_TO_IGNORE)\n error.stack = nextStack.join('\\n')\n}\n\nexport class InvariantError extends Error {\n name = 'Invariant Violation'\n\n constructor(public readonly message: string, ...positionals: any[]) {\n super(message)\n this.message = format(message, ...positionals)\n cleanErrorStack(this)\n }\n}\n\nexport interface CustomErrorConstructor {\n new (message: string): Error\n}\n\nexport interface CustomErrorFactory {\n (message: string): Error\n}\n\nexport type CustomError = CustomErrorConstructor | CustomErrorFactory\n\ntype Invariant = {\n (\n predicate: unknown,\n message: string,\n ...positionals: any[]\n ): asserts predicate\n\n as(\n ErrorConstructor: CustomError,\n predicate: unknown,\n message: string,\n ...positionals: unknown[]\n ): asserts predicate\n}\n\nexport const invariant: Invariant = (\n predicate,\n message,\n ...positionals\n): asserts predicate => {\n if (!predicate) {\n throw new InvariantError(message, ...positionals)\n }\n}\n\ninvariant.as = (ErrorConstructor, predicate, message, ...positionals) => {\n if (!predicate) {\n const formatMessage =\n positionals.length === 0 ? message : format(message, ...positionals)\n let error: Error\n\n try {\n error = Reflect.construct(ErrorConstructor as CustomErrorConstructor, [\n formatMessage,\n ])\n } catch (err) {\n error = (ErrorConstructor as CustomErrorFactory)(formatMessage)\n }\n\n throw error\n }\n}\n"],"mappings":";AAAA,IAAM,kBAAkB;AAExB,SAAS,oBAAoB,YAAiB,MAAmB;AAC/D,UAAQ,MAAM;AAAA,IAEZ,KAAK;AACH,aAAO;AAAA,IAGT,KAAK;AAAA,IACL,KAAK;AACH,aAAO,OAAO,UAAU;AAAA,IAG1B,KAAK;AACH,aAAO,KAAK,UAAU,UAAU;AAAA,IAGlC,KAAK,KAAK;AAER,UAAI,OAAO,eAAe,UAAU;AAClC,eAAO;AAAA,MACT;AAEA,YAAM,OAAO,KAAK,UAAU,UAAU;AAGtC,UAAI,SAAS,QAAQ,SAAS,QAAQ,mBAAmB,KAAK,IAAI,GAAG;AACnE,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,OAAO,YAAoB,aAA4B;AACrE,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB;AACtB,MAAI,mBAAmB,QAAQ;AAAA,IAC7B;AAAA,IACA,CAAC,OAAO,WAAW,GAAG,SAAS;AAC7B,YAAM,aAAa,YAAY;AAC/B,YAAM,QAAQ,oBAAoB,YAAY,IAAI;AAElD,UAAI,CAAC,WAAW;AACd;AACA,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAGA,MAAI,kBAAkB,YAAY,QAAQ;AACxC,wBAAoB,IAAI,YAAY,MAAM,eAAe,EAAE,KAAK,GAAG;AAAA,EACrE;AAEA,qBAAmB,iBAAiB,QAAQ,WAAW,GAAG;AAE1D,SAAO;AACT;;;AC/DA,IAAM,yBAAyB;AAO/B,SAAS,gBAAgB,OAAoB;AAC3C,MAAI,CAAC,MAAM,OAAO;AAChB;AAAA,EACF;AAEA,QAAM,YAAY,MAAM,MAAM,MAAM,IAAI;AACxC,YAAU,OAAO,GAAG,sBAAsB;AAC1C,QAAM,QAAQ,UAAU,KAAK,IAAI;AACnC;AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAGxC,YAA4B,YAAoB,aAAoB;AAClE,UAAM,OAAO;AADa;AAF5B,gBAAO;AAIL,SAAK,UAAU,OAAO,SAAS,GAAG,WAAW;AAC7C,oBAAgB,IAAI;AAAA,EACtB;AACF;AA2BO,IAAM,YAAuB,CAClC,WACA,YACG,gBACmB;AACtB,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,eAAe,SAAS,GAAG,WAAW;AAAA,EAClD;AACF;AAEA,UAAU,KAAK,CAAC,kBAAkB,WAAW,YAAY,gBAAgB;AACvE,MAAI,CAAC,WAAW;AACd,UAAM,gBACJ,YAAY,WAAW,IAAI,UAAU,OAAO,SAAS,GAAG,WAAW;AACrE,QAAI;AAEJ,QAAI;AACF,cAAQ,QAAQ,UAAU,kBAA4C;AAAA,QACpE;AAAA,MACF,CAAC;AAAA,IACH,SAAS,KAAP;AACA,cAAS,iBAAwC,aAAa;AAAA,IAChE;AAEA,UAAM;AAAA,EACR;AACF;","names":[]}
|
node_modules/outvariant/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "outvariant",
|
| 3 |
+
"version": "1.4.3",
|
| 4 |
+
"description": "Type-safe implementation of invariant with positionals.",
|
| 5 |
+
"main": "lib/index.js",
|
| 6 |
+
"module": "lib/index.mjs",
|
| 7 |
+
"typings": "lib/index.d.ts",
|
| 8 |
+
"exports": {
|
| 9 |
+
".": {
|
| 10 |
+
"types": "./lib/index.d.ts",
|
| 11 |
+
"require": "./lib/index.js",
|
| 12 |
+
"default": "./lib/index.mjs"
|
| 13 |
+
}
|
| 14 |
+
},
|
| 15 |
+
"author": "Artem Zakharchenko",
|
| 16 |
+
"license": "MIT",
|
| 17 |
+
"scripts": {
|
| 18 |
+
"test": "jest",
|
| 19 |
+
"clean": "rimraf ./lib",
|
| 20 |
+
"build": "yarn clean && tsup",
|
| 21 |
+
"prepublishOnly": "yarn test && yarn build",
|
| 22 |
+
"release": "release publish"
|
| 23 |
+
},
|
| 24 |
+
"files": [
|
| 25 |
+
"lib"
|
| 26 |
+
],
|
| 27 |
+
"keywords": [
|
| 28 |
+
"invariant",
|
| 29 |
+
"outvariant",
|
| 30 |
+
"exception",
|
| 31 |
+
"positional"
|
| 32 |
+
],
|
| 33 |
+
"devDependencies": {
|
| 34 |
+
"@ossjs/release": "^0.8.0",
|
| 35 |
+
"@types/jest": "^26.0.23",
|
| 36 |
+
"jest": "^27.0.6",
|
| 37 |
+
"rimraf": "^3.0.2",
|
| 38 |
+
"ts-jest": "^27.0.3",
|
| 39 |
+
"ts-node": "^10.0.0",
|
| 40 |
+
"tsup": "^6.2.3",
|
| 41 |
+
"typescript": "^4.3.4"
|
| 42 |
+
},
|
| 43 |
+
"repository": {
|
| 44 |
+
"type": "git",
|
| 45 |
+
"url": "https://github.com/open-draft/outvariant"
|
| 46 |
+
}
|
| 47 |
+
}
|
node_modules/own-keys/.eslintrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"root": true,
|
| 3 |
+
|
| 4 |
+
"extends": "@ljharb",
|
| 5 |
+
|
| 6 |
+
"rules": {
|
| 7 |
+
"func-style": "off",
|
| 8 |
+
"id-length": "off",
|
| 9 |
+
"max-lines-per-function": "off",
|
| 10 |
+
"new-cap": ["error", {
|
| 11 |
+
"capIsNewExceptions": [
|
| 12 |
+
"GetIntrinsic",
|
| 13 |
+
],
|
| 14 |
+
}],
|
| 15 |
+
},
|
| 16 |
+
}
|
node_modules/own-keys/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [ljharb]
|
| 4 |
+
patreon: # Replace with a single Patreon username
|
| 5 |
+
open_collective: # Replace with a single Open Collective username
|
| 6 |
+
ko_fi: # Replace with a single Ko-fi username
|
| 7 |
+
tidelift: npm/own-keys
|
| 8 |
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
| 9 |
+
liberapay: # Replace with a single Liberapay username
|
| 10 |
+
issuehunt: # Replace with a single IssueHunt username
|
| 11 |
+
otechie: # Replace with a single Otechie username
|
| 12 |
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
node_modules/own-keys/.nycrc
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"all": true,
|
| 3 |
+
"check-coverage": false,
|
| 4 |
+
"reporter": ["text-summary", "text", "html", "json"],
|
| 5 |
+
"exclude": [
|
| 6 |
+
"coverage",
|
| 7 |
+
"test"
|
| 8 |
+
]
|
| 9 |
+
}
|
node_modules/own-keys/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
## [v1.0.1](https://github.com/ljharb/own-keys/compare/v1.0.0...v1.0.1) - 2024-12-29
|
| 9 |
+
|
| 10 |
+
### Commits
|
| 11 |
+
|
| 12 |
+
- [Tests] sort with a proper comparator [`4a65b56`](https://github.com/ljharb/own-keys/commit/4a65b569d10985032a0773806dcdec8866132baa)
|
| 13 |
+
- [Fix] fix function name when `Reflect.ownKeys` is absent [`5cf17cb`](https://github.com/ljharb/own-keys/commit/5cf17cb1c9adfa836a1ddc467da4da20973db2ae)
|
| 14 |
+
|
| 15 |
+
## v1.0.0 - 2024-12-28
|
| 16 |
+
|
| 17 |
+
### Commits
|
| 18 |
+
|
| 19 |
+
- Initial implementation, tests, readme, types [`870a06f`](https://github.com/ljharb/own-keys/commit/870a06f9d7a2a6ecee283319d9a7388f8fc1c811)
|
| 20 |
+
- Initial commit [`70323dc`](https://github.com/ljharb/own-keys/commit/70323dc09541b4ee80426acfc89762605d7fc7bf)
|
| 21 |
+
- npm init [`4a3ad06`](https://github.com/ljharb/own-keys/commit/4a3ad0659defe9a67541c198743bd7733d437725)
|
| 22 |
+
- [Tests] node 0.8 sorts object keys differently [`b449364`](https://github.com/ljharb/own-keys/commit/b4493649ead7441fd8e65ab4718acbd088ceac70)
|
| 23 |
+
- Only apps should have lockfiles [`a54acbf`](https://github.com/ljharb/own-keys/commit/a54acbf2c6b8ef320abf7493b7c88002c690f9c0)
|
node_modules/own-keys/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Jordan Harband
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/own-keys/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# own-keys <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
| 2 |
+
|
| 3 |
+
[![github actions][actions-image]][actions-url]
|
| 4 |
+
[![coverage][codecov-image]][codecov-url]
|
| 5 |
+
[![License][license-image]][license-url]
|
| 6 |
+
[![Downloads][downloads-image]][downloads-url]
|
| 7 |
+
|
| 8 |
+
[![npm badge][npm-badge-png]][package-url]
|
| 9 |
+
|
| 10 |
+
Robustly get an object's own property keys (strings and symbols), including non-enumerables when possible.
|
| 11 |
+
|
| 12 |
+
## Getting started
|
| 13 |
+
|
| 14 |
+
```sh
|
| 15 |
+
npm install --save own-keys
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
## Usage/Examples
|
| 19 |
+
|
| 20 |
+
```js
|
| 21 |
+
var ownKeys = require('own-keys');
|
| 22 |
+
var assert = require('assert');
|
| 23 |
+
|
| 24 |
+
assert.deepEqual(ownKeys({ a: 1, b: 2 }), ['a', 'b']);
|
| 25 |
+
assert.deepEqual(ownKeys([1, 2, 3]), [0, 1, 2, 'length']);
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
## Tests
|
| 29 |
+
Simply clone the repo, `npm install`, and run `npm test`
|
| 30 |
+
|
| 31 |
+
[package-url]: https://npmjs.org/package/own-keys
|
| 32 |
+
[npm-version-svg]: https://versionbadg.es/ljharb/own-keys.svg
|
| 33 |
+
[deps-svg]: https://david-dm.org/ljharb/own-keys.svg
|
| 34 |
+
[deps-url]: https://david-dm.org/ljharb/own-keys
|
| 35 |
+
[dev-deps-svg]: https://david-dm.org/ljharb/own-keys/dev-status.svg
|
| 36 |
+
[dev-deps-url]: https://david-dm.org/ljharb/own-keys#info=devDependencies
|
| 37 |
+
[npm-badge-png]: https://nodei.co/npm/own-keys.png?downloads=true&stars=true
|
| 38 |
+
[license-image]: https://img.shields.io/npm/l/own-keys.svg
|
| 39 |
+
[license-url]: LICENSE
|
| 40 |
+
[downloads-image]: https://img.shields.io/npm/dm/own-keys.svg
|
| 41 |
+
[downloads-url]: https://npm-stat.com/charts.html?package=own-keys
|
| 42 |
+
[codecov-image]: https://codecov.io/gh/ljharb/own-keys/branch/main/graphs/badge.svg
|
| 43 |
+
[codecov-url]: https://app.codecov.io/gh/ljharb/own-keys/
|
| 44 |
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/own-keys
|
| 45 |
+
[actions-url]: https://github.com/ljharb/own-keys/actions
|
node_modules/own-keys/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare function ownKeys<T extends Record<PropertyKey, V>, V>(object: T): (keyof T)[];
|
| 2 |
+
|
| 3 |
+
export = ownKeys;
|
node_modules/own-keys/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var GetIntrinsic = require('get-intrinsic');
|
| 4 |
+
|
| 5 |
+
var safePushApply = require('safe-push-apply');
|
| 6 |
+
|
| 7 |
+
var $ownKeys = GetIntrinsic('%Reflect.ownKeys%', true);
|
| 8 |
+
var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
|
| 9 |
+
var $gOPS = GetIntrinsic('%Object.getOwnPropertySymbols%', true);
|
| 10 |
+
|
| 11 |
+
var keys = require('object-keys');
|
| 12 |
+
|
| 13 |
+
/** @type {import('.')} */
|
| 14 |
+
module.exports = $ownKeys || function ownKeys(source) {
|
| 15 |
+
/** @type {(keyof typeof source)[]} */
|
| 16 |
+
var sourceKeys = ($gOPN || keys)(source);
|
| 17 |
+
if ($gOPS) {
|
| 18 |
+
safePushApply(sourceKeys, $gOPS(source));
|
| 19 |
+
}
|
| 20 |
+
return sourceKeys;
|
| 21 |
+
};
|
node_modules/own-keys/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "own-keys",
|
| 3 |
+
"version": "1.0.1",
|
| 4 |
+
"description": "Robustly get an object's own property keys (strings and symbols), including non-enumerables when possible",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"exports": {
|
| 7 |
+
".": "./index.js",
|
| 8 |
+
"./package.json": "./package.json"
|
| 9 |
+
},
|
| 10 |
+
"sideEffects": false,
|
| 11 |
+
"scripts": {
|
| 12 |
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
| 13 |
+
"version": "auto-changelog && git add CHANGELOG.md",
|
| 14 |
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
|
| 15 |
+
"prelint": "evalmd README.md",
|
| 16 |
+
"lint": "eslint --ext=js,mjs .",
|
| 17 |
+
"postlint": "tsc && attw -P",
|
| 18 |
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
| 19 |
+
"prepublishOnly": "safe-publish-latest",
|
| 20 |
+
"pretest": "npm run lint",
|
| 21 |
+
"tests-only": "nyc tape test",
|
| 22 |
+
"test": "npm run tests-only",
|
| 23 |
+
"posttest": "npx npm@'>= 10.2' audit --production"
|
| 24 |
+
},
|
| 25 |
+
"keywords": [
|
| 26 |
+
"own",
|
| 27 |
+
"key",
|
| 28 |
+
"keys",
|
| 29 |
+
"propertykey",
|
| 30 |
+
"string",
|
| 31 |
+
"symbol",
|
| 32 |
+
"enumerable",
|
| 33 |
+
"non-enumerable",
|
| 34 |
+
"robust"
|
| 35 |
+
],
|
| 36 |
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
| 37 |
+
"funding": {
|
| 38 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 39 |
+
},
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"repository": {
|
| 42 |
+
"type": "git",
|
| 43 |
+
"url": "git+https://github.com/ljharb/own-keys.git"
|
| 44 |
+
},
|
| 45 |
+
"bugs": {
|
| 46 |
+
"url": "https://github.com/ljharb/own-keys/issues"
|
| 47 |
+
},
|
| 48 |
+
"homepage": "https://github.com/ljharb/own-keys#readme",
|
| 49 |
+
"dependencies": {
|
| 50 |
+
"get-intrinsic": "^1.2.6",
|
| 51 |
+
"object-keys": "^1.1.1",
|
| 52 |
+
"safe-push-apply": "^1.0.0"
|
| 53 |
+
},
|
| 54 |
+
"devDependencies": {
|
| 55 |
+
"@arethetypeswrong/cli": "^0.17.2",
|
| 56 |
+
"@ljharb/eslint-config": "^21.1.1",
|
| 57 |
+
"@ljharb/tsconfig": "^0.2.3",
|
| 58 |
+
"@types/get-intrinsic": "^1.2.3",
|
| 59 |
+
"@types/isarray": "^2.0.3",
|
| 60 |
+
"@types/object-keys": "^1.0.3",
|
| 61 |
+
"@types/tape": "^5.8.0",
|
| 62 |
+
"auto-changelog": "^2.5.0",
|
| 63 |
+
"encoding": "^0.1.13",
|
| 64 |
+
"eslint": "=8.8.0",
|
| 65 |
+
"evalmd": "^0.0.19",
|
| 66 |
+
"has-property-descriptors": "^1.0.2",
|
| 67 |
+
"has-symbols": "^1.1.0",
|
| 68 |
+
"in-publish": "^2.0.1",
|
| 69 |
+
"npmignore": "^0.3.1",
|
| 70 |
+
"nyc": "^10.3.2",
|
| 71 |
+
"safe-publish-latest": "^2.0.0",
|
| 72 |
+
"tape": "^5.9.0",
|
| 73 |
+
"typescript": "next"
|
| 74 |
+
},
|
| 75 |
+
"engines": {
|
| 76 |
+
"node": ">= 0.4"
|
| 77 |
+
},
|
| 78 |
+
"auto-changelog": {
|
| 79 |
+
"output": "CHANGELOG.md",
|
| 80 |
+
"template": "keepachangelog",
|
| 81 |
+
"unreleased": false,
|
| 82 |
+
"commitLimit": false,
|
| 83 |
+
"backfillLimit": false,
|
| 84 |
+
"hideCredit": true
|
| 85 |
+
},
|
| 86 |
+
"publishConfig": {
|
| 87 |
+
"ignore": [
|
| 88 |
+
".github/workflows"
|
| 89 |
+
]
|
| 90 |
+
}
|
| 91 |
+
}
|
node_modules/own-keys/test/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
var hasSymbols = require('has-symbols/shams')();
|
| 5 |
+
var hasPropertyDescriptors = require('has-property-descriptors')();
|
| 6 |
+
|
| 7 |
+
var ownKeys = require('../');
|
| 8 |
+
|
| 9 |
+
/** @type {(a: PropertyKey, b: PropertyKey) => number} */
|
| 10 |
+
function comparator(a, b) {
|
| 11 |
+
if (typeof a === 'string' && typeof b === 'string') {
|
| 12 |
+
return a.localeCompare(b);
|
| 13 |
+
}
|
| 14 |
+
if (typeof a === 'number' && typeof b === 'number') {
|
| 15 |
+
return a - b;
|
| 16 |
+
}
|
| 17 |
+
return typeof a === 'symbol' ? 1 : -1;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test('ownKeys', function (t) {
|
| 21 |
+
t.equal(typeof ownKeys, 'function', 'is a function');
|
| 22 |
+
t.equal(
|
| 23 |
+
ownKeys.length,
|
| 24 |
+
1,
|
| 25 |
+
'has a length of 1'
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
t.test('basics', function (st) {
|
| 29 |
+
var obj = { a: 1, b: 2 };
|
| 30 |
+
if (hasPropertyDescriptors) {
|
| 31 |
+
Object.defineProperty(obj, 'c', {
|
| 32 |
+
configurable: true,
|
| 33 |
+
enumerable: false,
|
| 34 |
+
writable: true,
|
| 35 |
+
value: 3
|
| 36 |
+
});
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
st.deepEqual(
|
| 40 |
+
ownKeys(obj).sort(comparator),
|
| 41 |
+
(hasPropertyDescriptors ? ['a', 'b', 'c'] : ['a', 'b']).sort(comparator),
|
| 42 |
+
'includes non-enumerable properties'
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
st.end();
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
t.test('symbols', { skip: !hasSymbols }, function (st) {
|
| 49 |
+
/** @type {Record<PropertyKey, unknown>} */
|
| 50 |
+
var obj = { a: 1 };
|
| 51 |
+
var sym = Symbol('b');
|
| 52 |
+
obj[sym] = 2;
|
| 53 |
+
|
| 54 |
+
var nonEnumSym = Symbol('c');
|
| 55 |
+
Object.defineProperty(obj, nonEnumSym, {
|
| 56 |
+
configurable: true,
|
| 57 |
+
enumerable: false,
|
| 58 |
+
writable: true,
|
| 59 |
+
value: 3
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
st.deepEqual(
|
| 63 |
+
ownKeys(obj).sort(comparator),
|
| 64 |
+
['a', sym, nonEnumSym].sort(comparator),
|
| 65 |
+
'works with symbols, both enum and non-enum'
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
st.end();
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
t.end();
|
| 72 |
+
});
|
node_modules/own-keys/tsconfig.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"extends": "@ljharb/tsconfig",
|
| 3 |
+
"compilerOptions": {
|
| 4 |
+
"target": "es2021",
|
| 5 |
+
},
|
| 6 |
+
"exclude": [
|
| 7 |
+
"coverage",
|
| 8 |
+
],
|
| 9 |
+
}
|
node_modules/p-limit/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare namespace pLimit {
|
| 2 |
+
interface Limit {
|
| 3 |
+
/**
|
| 4 |
+
The number of promises that are currently running.
|
| 5 |
+
*/
|
| 6 |
+
readonly activeCount: number;
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
|
| 10 |
+
*/
|
| 11 |
+
readonly pendingCount: number;
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
Discard pending promises that are waiting to run.
|
| 15 |
+
|
| 16 |
+
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
|
| 17 |
+
|
| 18 |
+
Note: This does not cancel promises that are already running.
|
| 19 |
+
*/
|
| 20 |
+
clearQueue: () => void;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
@param fn - Promise-returning/async function.
|
| 24 |
+
@param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
|
| 25 |
+
@returns The promise returned by calling `fn(...arguments)`.
|
| 26 |
+
*/
|
| 27 |
+
<Arguments extends unknown[], ReturnType>(
|
| 28 |
+
fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
|
| 29 |
+
...arguments: Arguments
|
| 30 |
+
): Promise<ReturnType>;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
Run multiple promise-returning & async functions with limited concurrency.
|
| 36 |
+
|
| 37 |
+
@param concurrency - Concurrency limit. Minimum: `1`.
|
| 38 |
+
@returns A `limit` function.
|
| 39 |
+
*/
|
| 40 |
+
declare function pLimit(concurrency: number): pLimit.Limit;
|
| 41 |
+
|
| 42 |
+
export = pLimit;
|
node_modules/p-limit/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const Queue = require('yocto-queue');
|
| 3 |
+
|
| 4 |
+
const pLimit = concurrency => {
|
| 5 |
+
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
| 6 |
+
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
const queue = new Queue();
|
| 10 |
+
let activeCount = 0;
|
| 11 |
+
|
| 12 |
+
const next = () => {
|
| 13 |
+
activeCount--;
|
| 14 |
+
|
| 15 |
+
if (queue.size > 0) {
|
| 16 |
+
queue.dequeue()();
|
| 17 |
+
}
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
const run = async (fn, resolve, ...args) => {
|
| 21 |
+
activeCount++;
|
| 22 |
+
|
| 23 |
+
const result = (async () => fn(...args))();
|
| 24 |
+
|
| 25 |
+
resolve(result);
|
| 26 |
+
|
| 27 |
+
try {
|
| 28 |
+
await result;
|
| 29 |
+
} catch {}
|
| 30 |
+
|
| 31 |
+
next();
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
const enqueue = (fn, resolve, ...args) => {
|
| 35 |
+
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
| 36 |
+
|
| 37 |
+
(async () => {
|
| 38 |
+
// This function needs to wait until the next microtask before comparing
|
| 39 |
+
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
| 40 |
+
// when the run function is dequeued and called. The comparison in the if-statement
|
| 41 |
+
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
| 42 |
+
await Promise.resolve();
|
| 43 |
+
|
| 44 |
+
if (activeCount < concurrency && queue.size > 0) {
|
| 45 |
+
queue.dequeue()();
|
| 46 |
+
}
|
| 47 |
+
})();
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
const generator = (fn, ...args) => new Promise(resolve => {
|
| 51 |
+
enqueue(fn, resolve, ...args);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
Object.defineProperties(generator, {
|
| 55 |
+
activeCount: {
|
| 56 |
+
get: () => activeCount
|
| 57 |
+
},
|
| 58 |
+
pendingCount: {
|
| 59 |
+
get: () => queue.size
|
| 60 |
+
},
|
| 61 |
+
clearQueue: {
|
| 62 |
+
value: () => {
|
| 63 |
+
queue.clear();
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
return generator;
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
module.exports = pLimit;
|
node_modules/p-limit/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
| 4 |
+
|
| 5 |
+
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:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
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.
|
node_modules/p-limit/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "p-limit",
|
| 3 |
+
"version": "3.1.0",
|
| 4 |
+
"description": "Run multiple promise-returning & async functions with limited concurrency",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "sindresorhus/p-limit",
|
| 7 |
+
"funding": "https://github.com/sponsors/sindresorhus",
|
| 8 |
+
"author": {
|
| 9 |
+
"name": "Sindre Sorhus",
|
| 10 |
+
"email": "sindresorhus@gmail.com",
|
| 11 |
+
"url": "https://sindresorhus.com"
|
| 12 |
+
},
|
| 13 |
+
"engines": {
|
| 14 |
+
"node": ">=10"
|
| 15 |
+
},
|
| 16 |
+
"scripts": {
|
| 17 |
+
"test": "xo && ava && tsd"
|
| 18 |
+
},
|
| 19 |
+
"files": [
|
| 20 |
+
"index.js",
|
| 21 |
+
"index.d.ts"
|
| 22 |
+
],
|
| 23 |
+
"keywords": [
|
| 24 |
+
"promise",
|
| 25 |
+
"limit",
|
| 26 |
+
"limited",
|
| 27 |
+
"concurrency",
|
| 28 |
+
"throttle",
|
| 29 |
+
"throat",
|
| 30 |
+
"rate",
|
| 31 |
+
"batch",
|
| 32 |
+
"ratelimit",
|
| 33 |
+
"task",
|
| 34 |
+
"queue",
|
| 35 |
+
"async",
|
| 36 |
+
"await",
|
| 37 |
+
"promises",
|
| 38 |
+
"bluebird"
|
| 39 |
+
],
|
| 40 |
+
"dependencies": {
|
| 41 |
+
"yocto-queue": "^0.1.0"
|
| 42 |
+
},
|
| 43 |
+
"devDependencies": {
|
| 44 |
+
"ava": "^2.4.0",
|
| 45 |
+
"delay": "^4.4.0",
|
| 46 |
+
"in-range": "^2.0.0",
|
| 47 |
+
"random-int": "^2.0.1",
|
| 48 |
+
"time-span": "^4.0.0",
|
| 49 |
+
"tsd": "^0.13.1",
|
| 50 |
+
"xo": "^0.35.0"
|
| 51 |
+
}
|
| 52 |
+
}
|
node_modules/p-limit/readme.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# p-limit
|
| 2 |
+
|
| 3 |
+
> Run multiple promise-returning & async functions with limited concurrency
|
| 4 |
+
|
| 5 |
+
## Install
|
| 6 |
+
|
| 7 |
+
```
|
| 8 |
+
$ npm install p-limit
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
```js
|
| 14 |
+
const pLimit = require('p-limit');
|
| 15 |
+
|
| 16 |
+
const limit = pLimit(1);
|
| 17 |
+
|
| 18 |
+
const input = [
|
| 19 |
+
limit(() => fetchSomething('foo')),
|
| 20 |
+
limit(() => fetchSomething('bar')),
|
| 21 |
+
limit(() => doSomething())
|
| 22 |
+
];
|
| 23 |
+
|
| 24 |
+
(async () => {
|
| 25 |
+
// Only one promise is run at once
|
| 26 |
+
const result = await Promise.all(input);
|
| 27 |
+
console.log(result);
|
| 28 |
+
})();
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## API
|
| 32 |
+
|
| 33 |
+
### pLimit(concurrency)
|
| 34 |
+
|
| 35 |
+
Returns a `limit` function.
|
| 36 |
+
|
| 37 |
+
#### concurrency
|
| 38 |
+
|
| 39 |
+
Type: `number`\
|
| 40 |
+
Minimum: `1`\
|
| 41 |
+
Default: `Infinity`
|
| 42 |
+
|
| 43 |
+
Concurrency limit.
|
| 44 |
+
|
| 45 |
+
### limit(fn, ...args)
|
| 46 |
+
|
| 47 |
+
Returns the promise returned by calling `fn(...args)`.
|
| 48 |
+
|
| 49 |
+
#### fn
|
| 50 |
+
|
| 51 |
+
Type: `Function`
|
| 52 |
+
|
| 53 |
+
Promise-returning/async function.
|
| 54 |
+
|
| 55 |
+
#### args
|
| 56 |
+
|
| 57 |
+
Any arguments to pass through to `fn`.
|
| 58 |
+
|
| 59 |
+
Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
|
| 60 |
+
|
| 61 |
+
### limit.activeCount
|
| 62 |
+
|
| 63 |
+
The number of promises that are currently running.
|
| 64 |
+
|
| 65 |
+
### limit.pendingCount
|
| 66 |
+
|
| 67 |
+
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
|
| 68 |
+
|
| 69 |
+
### limit.clearQueue()
|
| 70 |
+
|
| 71 |
+
Discard pending promises that are waiting to run.
|
| 72 |
+
|
| 73 |
+
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
|
| 74 |
+
|
| 75 |
+
Note: This does not cancel promises that are already running.
|
| 76 |
+
|
| 77 |
+
## FAQ
|
| 78 |
+
|
| 79 |
+
### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?
|
| 80 |
+
|
| 81 |
+
This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
|
| 82 |
+
|
| 83 |
+
## Related
|
| 84 |
+
|
| 85 |
+
- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
|
| 86 |
+
- [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
|
| 87 |
+
- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
|
| 88 |
+
- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
|
| 89 |
+
- [More…](https://github.com/sindresorhus/promise-fun)
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
<div align="center">
|
| 94 |
+
<b>
|
| 95 |
+
<a href="https://tidelift.com/subscription/pkg/npm-p-limit?utm_source=npm-p-limit&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
| 96 |
+
</b>
|
| 97 |
+
<br>
|
| 98 |
+
<sub>
|
| 99 |
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
| 100 |
+
</sub>
|
| 101 |
+
</div>
|
node_modules/p-locate/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare namespace pLocate {
|
| 2 |
+
interface Options {
|
| 3 |
+
/**
|
| 4 |
+
Number of concurrently pending promises returned by `tester`. Minimum: `1`.
|
| 5 |
+
|
| 6 |
+
@default Infinity
|
| 7 |
+
*/
|
| 8 |
+
readonly concurrency?: number;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
Preserve `input` order when searching.
|
| 12 |
+
|
| 13 |
+
Disable this to improve performance if you don't care about the order.
|
| 14 |
+
|
| 15 |
+
@default true
|
| 16 |
+
*/
|
| 17 |
+
readonly preserveOrder?: boolean;
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
Get the first fulfilled promise that satisfies the provided testing function.
|
| 23 |
+
|
| 24 |
+
@param input - An iterable of promises/values to test.
|
| 25 |
+
@param tester - This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
| 26 |
+
@returns A `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
| 27 |
+
|
| 28 |
+
@example
|
| 29 |
+
```
|
| 30 |
+
import pathExists = require('path-exists');
|
| 31 |
+
import pLocate = require('p-locate');
|
| 32 |
+
|
| 33 |
+
const files = [
|
| 34 |
+
'unicorn.png',
|
| 35 |
+
'rainbow.png', // Only this one actually exists on disk
|
| 36 |
+
'pony.png'
|
| 37 |
+
];
|
| 38 |
+
|
| 39 |
+
(async () => {
|
| 40 |
+
const foundPath = await pLocate(files, file => pathExists(file));
|
| 41 |
+
|
| 42 |
+
console.log(foundPath);
|
| 43 |
+
//=> 'rainbow'
|
| 44 |
+
})();
|
| 45 |
+
```
|
| 46 |
+
*/
|
| 47 |
+
declare function pLocate<ValueType>(
|
| 48 |
+
input: Iterable<PromiseLike<ValueType> | ValueType>,
|
| 49 |
+
tester: (element: ValueType) => PromiseLike<boolean> | boolean,
|
| 50 |
+
options?: pLocate.Options
|
| 51 |
+
): Promise<ValueType | undefined>;
|
| 52 |
+
|
| 53 |
+
export = pLocate;
|
node_modules/p-locate/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const pLimit = require('p-limit');
|
| 3 |
+
|
| 4 |
+
class EndError extends Error {
|
| 5 |
+
constructor(value) {
|
| 6 |
+
super();
|
| 7 |
+
this.value = value;
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
// The input can also be a promise, so we await it
|
| 12 |
+
const testElement = async (element, tester) => tester(await element);
|
| 13 |
+
|
| 14 |
+
// The input can also be a promise, so we `Promise.all()` them both
|
| 15 |
+
const finder = async element => {
|
| 16 |
+
const values = await Promise.all(element);
|
| 17 |
+
if (values[1] === true) {
|
| 18 |
+
throw new EndError(values[0]);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
return false;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
const pLocate = async (iterable, tester, options) => {
|
| 25 |
+
options = {
|
| 26 |
+
concurrency: Infinity,
|
| 27 |
+
preserveOrder: true,
|
| 28 |
+
...options
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
const limit = pLimit(options.concurrency);
|
| 32 |
+
|
| 33 |
+
// Start all the promises concurrently with optional limit
|
| 34 |
+
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
| 35 |
+
|
| 36 |
+
// Check the promises either serially or concurrently
|
| 37 |
+
const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
|
| 38 |
+
|
| 39 |
+
try {
|
| 40 |
+
await Promise.all(items.map(element => checkLimit(finder, element)));
|
| 41 |
+
} catch (error) {
|
| 42 |
+
if (error instanceof EndError) {
|
| 43 |
+
return error.value;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
throw error;
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
module.exports = pLocate;
|
node_modules/p-locate/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
| 4 |
+
|
| 5 |
+
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:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
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.
|
node_modules/p-locate/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "p-locate",
|
| 3 |
+
"version": "5.0.0",
|
| 4 |
+
"description": "Get the first fulfilled promise that satisfies the provided testing function",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "sindresorhus/p-locate",
|
| 7 |
+
"funding": "https://github.com/sponsors/sindresorhus",
|
| 8 |
+
"author": {
|
| 9 |
+
"name": "Sindre Sorhus",
|
| 10 |
+
"email": "sindresorhus@gmail.com",
|
| 11 |
+
"url": "https://sindresorhus.com"
|
| 12 |
+
},
|
| 13 |
+
"engines": {
|
| 14 |
+
"node": ">=10"
|
| 15 |
+
},
|
| 16 |
+
"scripts": {
|
| 17 |
+
"test": "xo && ava && tsd"
|
| 18 |
+
},
|
| 19 |
+
"files": [
|
| 20 |
+
"index.js",
|
| 21 |
+
"index.d.ts"
|
| 22 |
+
],
|
| 23 |
+
"keywords": [
|
| 24 |
+
"promise",
|
| 25 |
+
"locate",
|
| 26 |
+
"find",
|
| 27 |
+
"finder",
|
| 28 |
+
"search",
|
| 29 |
+
"searcher",
|
| 30 |
+
"test",
|
| 31 |
+
"array",
|
| 32 |
+
"collection",
|
| 33 |
+
"iterable",
|
| 34 |
+
"iterator",
|
| 35 |
+
"race",
|
| 36 |
+
"fulfilled",
|
| 37 |
+
"fastest",
|
| 38 |
+
"async",
|
| 39 |
+
"await",
|
| 40 |
+
"promises",
|
| 41 |
+
"bluebird"
|
| 42 |
+
],
|
| 43 |
+
"dependencies": {
|
| 44 |
+
"p-limit": "^3.0.2"
|
| 45 |
+
},
|
| 46 |
+
"devDependencies": {
|
| 47 |
+
"ava": "^2.4.0",
|
| 48 |
+
"delay": "^4.1.0",
|
| 49 |
+
"in-range": "^2.0.0",
|
| 50 |
+
"time-span": "^4.0.0",
|
| 51 |
+
"tsd": "^0.13.1",
|
| 52 |
+
"xo": "^0.32.1"
|
| 53 |
+
}
|
| 54 |
+
}
|
node_modules/p-locate/readme.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# p-locate [](https://travis-ci.com/github/sindresorhus/p-locate)
|
| 2 |
+
|
| 3 |
+
> Get the first fulfilled promise that satisfies the provided testing function
|
| 4 |
+
|
| 5 |
+
Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
| 6 |
+
|
| 7 |
+
## Install
|
| 8 |
+
|
| 9 |
+
```
|
| 10 |
+
$ npm install p-locate
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
## Usage
|
| 14 |
+
|
| 15 |
+
Here we find the first file that exists on disk, in array order.
|
| 16 |
+
|
| 17 |
+
```js
|
| 18 |
+
const pathExists = require('path-exists');
|
| 19 |
+
const pLocate = require('p-locate');
|
| 20 |
+
|
| 21 |
+
const files = [
|
| 22 |
+
'unicorn.png',
|
| 23 |
+
'rainbow.png', // Only this one actually exists on disk
|
| 24 |
+
'pony.png'
|
| 25 |
+
];
|
| 26 |
+
|
| 27 |
+
(async () => {
|
| 28 |
+
const foundPath = await pLocate(files, file => pathExists(file));
|
| 29 |
+
|
| 30 |
+
console.log(foundPath);
|
| 31 |
+
//=> 'rainbow'
|
| 32 |
+
})();
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
|
| 36 |
+
|
| 37 |
+
## API
|
| 38 |
+
|
| 39 |
+
### pLocate(input, tester, options?)
|
| 40 |
+
|
| 41 |
+
Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
| 42 |
+
|
| 43 |
+
#### input
|
| 44 |
+
|
| 45 |
+
Type: `Iterable<Promise | unknown>`
|
| 46 |
+
|
| 47 |
+
An iterable of promises/values to test.
|
| 48 |
+
|
| 49 |
+
#### tester(element)
|
| 50 |
+
|
| 51 |
+
Type: `Function`
|
| 52 |
+
|
| 53 |
+
This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
| 54 |
+
|
| 55 |
+
#### options
|
| 56 |
+
|
| 57 |
+
Type: `object`
|
| 58 |
+
|
| 59 |
+
##### concurrency
|
| 60 |
+
|
| 61 |
+
Type: `number`\
|
| 62 |
+
Default: `Infinity`\
|
| 63 |
+
Minimum: `1`
|
| 64 |
+
|
| 65 |
+
Number of concurrently pending promises returned by `tester`.
|
| 66 |
+
|
| 67 |
+
##### preserveOrder
|
| 68 |
+
|
| 69 |
+
Type: `boolean`\
|
| 70 |
+
Default: `true`
|
| 71 |
+
|
| 72 |
+
Preserve `input` order when searching.
|
| 73 |
+
|
| 74 |
+
Disable this to improve performance if you don't care about the order.
|
| 75 |
+
|
| 76 |
+
## Related
|
| 77 |
+
|
| 78 |
+
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
|
| 79 |
+
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
|
| 80 |
+
- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled
|
| 81 |
+
- [More…](https://github.com/sindresorhus/promise-fun)
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
<div align="center">
|
| 86 |
+
<b>
|
| 87 |
+
<a href="https://tidelift.com/subscription/pkg/npm-p-locate?utm_source=npm-p-locate&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
| 88 |
+
</b>
|
| 89 |
+
<br>
|
| 90 |
+
<sub>
|
| 91 |
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
| 92 |
+
</sub>
|
| 93 |
+
</div>
|
node_modules/p-try/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare const pTry: {
|
| 2 |
+
/**
|
| 3 |
+
Start a promise chain.
|
| 4 |
+
|
| 5 |
+
@param fn - The function to run to start the promise chain.
|
| 6 |
+
@param arguments - Arguments to pass to `fn`.
|
| 7 |
+
@returns The value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
|
| 8 |
+
|
| 9 |
+
@example
|
| 10 |
+
```
|
| 11 |
+
import pTry = require('p-try');
|
| 12 |
+
|
| 13 |
+
(async () => {
|
| 14 |
+
try {
|
| 15 |
+
const value = await pTry(() => {
|
| 16 |
+
return synchronousFunctionThatMightThrow();
|
| 17 |
+
});
|
| 18 |
+
console.log(value);
|
| 19 |
+
} catch (error) {
|
| 20 |
+
console.error(error);
|
| 21 |
+
}
|
| 22 |
+
})();
|
| 23 |
+
```
|
| 24 |
+
*/
|
| 25 |
+
<ValueType, ArgumentsType extends unknown[]>(
|
| 26 |
+
fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
|
| 27 |
+
...arguments: ArgumentsType
|
| 28 |
+
): Promise<ValueType>;
|
| 29 |
+
|
| 30 |
+
// TODO: remove this in the next major version, refactor the whole definition to:
|
| 31 |
+
// declare function pTry<ValueType, ArgumentsType extends unknown[]>(
|
| 32 |
+
// fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
|
| 33 |
+
// ...arguments: ArgumentsType
|
| 34 |
+
// ): Promise<ValueType>;
|
| 35 |
+
// export = pTry;
|
| 36 |
+
default: typeof pTry;
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
export = pTry;
|
node_modules/p-try/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const pTry = (fn, ...arguments_) => new Promise(resolve => {
|
| 4 |
+
resolve(fn(...arguments_));
|
| 5 |
+
});
|
| 6 |
+
|
| 7 |
+
module.exports = pTry;
|
| 8 |
+
// TODO: remove this in the next major version
|
| 9 |
+
module.exports.default = pTry;
|
node_modules/p-try/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 4 |
+
|
| 5 |
+
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:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
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.
|
node_modules/p-try/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "p-try",
|
| 3 |
+
"version": "2.2.0",
|
| 4 |
+
"description": "`Start a promise chain",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "sindresorhus/p-try",
|
| 7 |
+
"author": {
|
| 8 |
+
"name": "Sindre Sorhus",
|
| 9 |
+
"email": "sindresorhus@gmail.com",
|
| 10 |
+
"url": "sindresorhus.com"
|
| 11 |
+
},
|
| 12 |
+
"engines": {
|
| 13 |
+
"node": ">=6"
|
| 14 |
+
},
|
| 15 |
+
"scripts": {
|
| 16 |
+
"test": "xo && ava && tsd"
|
| 17 |
+
},
|
| 18 |
+
"files": [
|
| 19 |
+
"index.js",
|
| 20 |
+
"index.d.ts"
|
| 21 |
+
],
|
| 22 |
+
"keywords": [
|
| 23 |
+
"promise",
|
| 24 |
+
"try",
|
| 25 |
+
"resolve",
|
| 26 |
+
"function",
|
| 27 |
+
"catch",
|
| 28 |
+
"async",
|
| 29 |
+
"await",
|
| 30 |
+
"promises",
|
| 31 |
+
"settled",
|
| 32 |
+
"ponyfill",
|
| 33 |
+
"polyfill",
|
| 34 |
+
"shim",
|
| 35 |
+
"bluebird"
|
| 36 |
+
],
|
| 37 |
+
"devDependencies": {
|
| 38 |
+
"ava": "^1.4.1",
|
| 39 |
+
"tsd": "^0.7.1",
|
| 40 |
+
"xo": "^0.24.0"
|
| 41 |
+
}
|
| 42 |
+
}
|
node_modules/p-try/readme.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# p-try [](https://travis-ci.org/sindresorhus/p-try)
|
| 2 |
+
|
| 3 |
+
> Start a promise chain
|
| 4 |
+
|
| 5 |
+
[How is it useful?](http://cryto.net/~joepie91/blog/2016/05/11/what-is-promise-try-and-why-does-it-matter/)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
## Install
|
| 9 |
+
|
| 10 |
+
```
|
| 11 |
+
$ npm install p-try
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
```js
|
| 18 |
+
const pTry = require('p-try');
|
| 19 |
+
|
| 20 |
+
(async () => {
|
| 21 |
+
try {
|
| 22 |
+
const value = await pTry(() => {
|
| 23 |
+
return synchronousFunctionThatMightThrow();
|
| 24 |
+
});
|
| 25 |
+
console.log(value);
|
| 26 |
+
} catch (error) {
|
| 27 |
+
console.error(error);
|
| 28 |
+
}
|
| 29 |
+
})();
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## API
|
| 34 |
+
|
| 35 |
+
### pTry(fn, ...arguments)
|
| 36 |
+
|
| 37 |
+
Returns a `Promise` resolved with the value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
|
| 38 |
+
|
| 39 |
+
Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
|
| 40 |
+
|
| 41 |
+
#### fn
|
| 42 |
+
|
| 43 |
+
The function to run to start the promise chain.
|
| 44 |
+
|
| 45 |
+
#### arguments
|
| 46 |
+
|
| 47 |
+
Arguments to pass to `fn`.
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
## Related
|
| 51 |
+
|
| 52 |
+
- [p-finally](https://github.com/sindresorhus/p-finally) - `Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
|
| 53 |
+
- [More…](https://github.com/sindresorhus/promise-fun)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
## License
|
| 57 |
+
|
| 58 |
+
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
node_modules/package-json-from-dist/LICENSE.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
All packages under `src/` are licensed according to the terms in
|
| 2 |
+
their respective `LICENSE` or `LICENSE.md` files.
|
| 3 |
+
|
| 4 |
+
The remainder of this project is licensed under the Blue Oak
|
| 5 |
+
Model License, as follows:
|
| 6 |
+
|
| 7 |
+
-----
|
| 8 |
+
|
| 9 |
+
# Blue Oak Model License
|
| 10 |
+
|
| 11 |
+
Version 1.0.0
|
| 12 |
+
|
| 13 |
+
## Purpose
|
| 14 |
+
|
| 15 |
+
This license gives everyone as much permission to work with
|
| 16 |
+
this software as possible, while protecting contributors
|
| 17 |
+
from liability.
|
| 18 |
+
|
| 19 |
+
## Acceptance
|
| 20 |
+
|
| 21 |
+
In order to receive this license, you must agree to its
|
| 22 |
+
rules. The rules of this license are both obligations
|
| 23 |
+
under that agreement and conditions to your license.
|
| 24 |
+
You must not do anything with this software that triggers
|
| 25 |
+
a rule that you cannot or will not follow.
|
| 26 |
+
|
| 27 |
+
## Copyright
|
| 28 |
+
|
| 29 |
+
Each contributor licenses you to do everything with this
|
| 30 |
+
software that would otherwise infringe that contributor's
|
| 31 |
+
copyright in it.
|
| 32 |
+
|
| 33 |
+
## Notices
|
| 34 |
+
|
| 35 |
+
You must ensure that everyone who gets a copy of
|
| 36 |
+
any part of this software from you, with or without
|
| 37 |
+
changes, also gets the text of this license or a link to
|
| 38 |
+
<https://blueoakcouncil.org/license/1.0.0>.
|
| 39 |
+
|
| 40 |
+
## Excuse
|
| 41 |
+
|
| 42 |
+
If anyone notifies you in writing that you have not
|
| 43 |
+
complied with [Notices](#notices), you can keep your
|
| 44 |
+
license by taking all practical steps to comply within 30
|
| 45 |
+
days after the notice. If you do not do so, your license
|
| 46 |
+
ends immediately.
|
| 47 |
+
|
| 48 |
+
## Patent
|
| 49 |
+
|
| 50 |
+
Each contributor licenses you to do everything with this
|
| 51 |
+
software that would otherwise infringe any patent claims
|
| 52 |
+
they can license or become able to license.
|
| 53 |
+
|
| 54 |
+
## Reliability
|
| 55 |
+
|
| 56 |
+
No contributor can revoke this license.
|
| 57 |
+
|
| 58 |
+
## No Liability
|
| 59 |
+
|
| 60 |
+
***As far as the law allows, this software comes as is,
|
| 61 |
+
without any warranty or condition, and no contributor
|
| 62 |
+
will be liable to anyone for any damages related to this
|
| 63 |
+
software or this license, under any kind of legal claim.***
|
node_modules/package-json-from-dist/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# package-json-from-dist
|
| 2 |
+
|
| 3 |
+
Sometimes you want to load the `package.json` into your
|
| 4 |
+
TypeScript program, and it's tempting to just `import
|
| 5 |
+
'../package.json'`, since that seems to work.
|
| 6 |
+
|
| 7 |
+
However, this requires `tsc` to make an entire copy of your
|
| 8 |
+
`package.json` file into the `dist` folder, which is a problem if
|
| 9 |
+
you're using something like
|
| 10 |
+
[tshy](https://github.com/isaacs/tshy), which uses the
|
| 11 |
+
`package.json` file in dist for another purpose. Even when that
|
| 12 |
+
does work, it's asking the module system to do a bunch of extra
|
| 13 |
+
fs system calls, just to load a version number or something. (See
|
| 14 |
+
[this issue](https://github.com/isaacs/tshy/issues/61).)
|
| 15 |
+
|
| 16 |
+
This module helps by just finding the package.json file
|
| 17 |
+
appropriately, and reading and parsing it in the most normal
|
| 18 |
+
fashion.
|
| 19 |
+
|
| 20 |
+
## Caveats
|
| 21 |
+
|
| 22 |
+
This _only_ works if your code builds into a target folder called
|
| 23 |
+
`dist`, which is in the root of the package. It also requires
|
| 24 |
+
that you do not have a folder named `node_modules` anywhere
|
| 25 |
+
within your dev environment, or else it'll get the wrong answers
|
| 26 |
+
there. (But, at least, that'll be in dev, so you're pretty likely
|
| 27 |
+
to notice.)
|
| 28 |
+
|
| 29 |
+
If you build to some other location, then you'll need a different
|
| 30 |
+
approach. (Feel free to fork this module and make it your own, or
|
| 31 |
+
just put the code right inline, there's not much of it.)
|
| 32 |
+
|
| 33 |
+
## USAGE
|
| 34 |
+
|
| 35 |
+
```js
|
| 36 |
+
// src/index.ts
|
| 37 |
+
import {
|
| 38 |
+
findPackageJson,
|
| 39 |
+
loadPackageJson,
|
| 40 |
+
} from 'package-json-from-dist'
|
| 41 |
+
|
| 42 |
+
const pj = findPackageJson(import.meta.url)
|
| 43 |
+
console.log(`package.json found at ${pj}`)
|
| 44 |
+
|
| 45 |
+
const pkg = loadPackageJson(import.meta.url)
|
| 46 |
+
console.log(`Hello from ${pkg.name}@${pkg.version}`)
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
If your module is not directly in the `./src` folder, then you need
|
| 50 |
+
to specify the path that you would expect to find the
|
| 51 |
+
`package.json` when it's _not_ built to the `dist` folder.
|
| 52 |
+
|
| 53 |
+
```js
|
| 54 |
+
// src/components/something.ts
|
| 55 |
+
import {
|
| 56 |
+
findPackageJson,
|
| 57 |
+
loadPackageJson,
|
| 58 |
+
} from 'package-json-from-dist'
|
| 59 |
+
|
| 60 |
+
const pj = findPackageJson(import.meta.url, '../../package.json')
|
| 61 |
+
console.log(`package.json found at ${pj}`)
|
| 62 |
+
|
| 63 |
+
const pkg = loadPackageJson(import.meta.url, '../../package.json')
|
| 64 |
+
console.log(`Hello from ${pkg.name}@${pkg.version}`)
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
When running from CommmonJS, use `__filename` instead of
|
| 68 |
+
`import.meta.url`.
|
| 69 |
+
|
| 70 |
+
```js
|
| 71 |
+
// src/index.cts
|
| 72 |
+
import {
|
| 73 |
+
findPackageJson,
|
| 74 |
+
loadPackageJson,
|
| 75 |
+
} from 'package-json-from-dist'
|
| 76 |
+
|
| 77 |
+
const pj = findPackageJson(__filename)
|
| 78 |
+
console.log(`package.json found at ${pj}`)
|
| 79 |
+
|
| 80 |
+
const pkg = loadPackageJson(__filename)
|
| 81 |
+
console.log(`Hello from ${pkg.name}@${pkg.version}`)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
Since [tshy](https://github.com/isaacs/tshy) builds _both_
|
| 85 |
+
CommonJS and ESM by default, you may find that you need a
|
| 86 |
+
CommonJS override and some `//@ts-ignore` magic to make it work.
|
| 87 |
+
|
| 88 |
+
`src/pkg.ts`:
|
| 89 |
+
|
| 90 |
+
```js
|
| 91 |
+
import {
|
| 92 |
+
findPackageJson,
|
| 93 |
+
loadPackageJson,
|
| 94 |
+
} from 'package-json-from-dist'
|
| 95 |
+
//@ts-ignore
|
| 96 |
+
export const pkg = loadPackageJson(import.meta.url)
|
| 97 |
+
//@ts-ignore
|
| 98 |
+
export const pj = findPackageJson(import.meta.url)
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
`src/pkg-cjs.cts`:
|
| 102 |
+
|
| 103 |
+
```js
|
| 104 |
+
import {
|
| 105 |
+
findPackageJson,
|
| 106 |
+
loadPackageJson,
|
| 107 |
+
} from 'package-json-from-dist'
|
| 108 |
+
export const pkg = loadPackageJson(__filename)
|
| 109 |
+
export const pj = findPackageJson(__filename)
|
| 110 |
+
```
|
node_modules/package-json-from-dist/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "package-json-from-dist",
|
| 3 |
+
"version": "1.0.1",
|
| 4 |
+
"description": "Load the local package.json from either src or dist folder",
|
| 5 |
+
"main": "./dist/commonjs/index.js",
|
| 6 |
+
"exports": {
|
| 7 |
+
"./package.json": "./package.json",
|
| 8 |
+
".": {
|
| 9 |
+
"import": {
|
| 10 |
+
"types": "./dist/esm/index.d.ts",
|
| 11 |
+
"default": "./dist/esm/index.js"
|
| 12 |
+
},
|
| 13 |
+
"require": {
|
| 14 |
+
"types": "./dist/commonjs/index.d.ts",
|
| 15 |
+
"default": "./dist/commonjs/index.js"
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
},
|
| 19 |
+
"files": [
|
| 20 |
+
"dist"
|
| 21 |
+
],
|
| 22 |
+
"scripts": {
|
| 23 |
+
"preversion": "npm test",
|
| 24 |
+
"postversion": "npm publish",
|
| 25 |
+
"prepublishOnly": "git push origin --follow-tags",
|
| 26 |
+
"prepare": "tshy",
|
| 27 |
+
"pretest": "npm run prepare",
|
| 28 |
+
"presnap": "npm run prepare",
|
| 29 |
+
"test": "tap",
|
| 30 |
+
"snap": "tap",
|
| 31 |
+
"format": "prettier --write . --log-level warn",
|
| 32 |
+
"typedoc": "typedoc"
|
| 33 |
+
},
|
| 34 |
+
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
|
| 35 |
+
"license": "BlueOak-1.0.0",
|
| 36 |
+
"repository": {
|
| 37 |
+
"type": "git",
|
| 38 |
+
"url": "git+https://github.com/isaacs/package-json-from-dist.git"
|
| 39 |
+
},
|
| 40 |
+
"devDependencies": {
|
| 41 |
+
"@types/node": "^20.12.12",
|
| 42 |
+
"prettier": "^3.2.5",
|
| 43 |
+
"tap": "^18.5.3",
|
| 44 |
+
"typedoc": "^0.24.8",
|
| 45 |
+
"typescript": "^5.1.6",
|
| 46 |
+
"tshy": "^1.14.0"
|
| 47 |
+
},
|
| 48 |
+
"prettier": {
|
| 49 |
+
"semi": false,
|
| 50 |
+
"printWidth": 70,
|
| 51 |
+
"tabWidth": 2,
|
| 52 |
+
"useTabs": false,
|
| 53 |
+
"singleQuote": true,
|
| 54 |
+
"jsxSingleQuote": false,
|
| 55 |
+
"bracketSameLine": true,
|
| 56 |
+
"arrowParens": "avoid",
|
| 57 |
+
"endOfLine": "lf",
|
| 58 |
+
"experimentalTernaries": true
|
| 59 |
+
},
|
| 60 |
+
"tshy": {
|
| 61 |
+
"exports": {
|
| 62 |
+
"./package.json": "./package.json",
|
| 63 |
+
".": "./src/index.ts"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"types": "./dist/commonjs/index.d.ts",
|
| 67 |
+
"type": "module"
|
| 68 |
+
}
|
node_modules/pako/CHANGELOG.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
## [1.0.11] - 2020-01-29
|
| 10 |
+
### Fixed
|
| 11 |
+
- Fix tests in node.js v12+, #179.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
## [1.0.10] - 2019-02-28
|
| 15 |
+
### Fixed
|
| 16 |
+
- Fix minified version, #161.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## [1.0.9] - 2019-02-28
|
| 20 |
+
### Fixed
|
| 21 |
+
- Fix `new Buffer()` warning, #154.
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
## [1.0.8] - 2019-01-14
|
| 25 |
+
### Fixed
|
| 26 |
+
- Fix raw inflate with dictionary, #155.
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
## [1.0.7] - 2018-11-29
|
| 30 |
+
### Fixed
|
| 31 |
+
- Fixed RangeError in Crome 72, #150.
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
## [1.0.6] - 2017-09-14
|
| 35 |
+
### Changed
|
| 36 |
+
- Improve @std/esm compatibility.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
## [1.0.5] - 2017-03-17
|
| 40 |
+
### Changed
|
| 41 |
+
- Maintenance. More formal `zlib` attribution and related
|
| 42 |
+
changes, #93. Thanks to @bastien-roucaries for the help.
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
## [1.0.4] - 2016-12-15
|
| 46 |
+
### Changed
|
| 47 |
+
- Bump dev dependencies.
|
| 48 |
+
|
| 49 |
+
### Fixed
|
| 50 |
+
- Make sure `err.message` is filled on throw.
|
| 51 |
+
|
| 52 |
+
### Added
|
| 53 |
+
- Code examples for utf-16 string encoding & object compression.
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
## [1.0.3] - 2016-07-25
|
| 57 |
+
### Fixed
|
| 58 |
+
- Maintenance: re-release to properly display latest version in npm registry
|
| 59 |
+
and badges. Because `npm publish` timestamp used instead of versions.
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
## [1.0.2] - 2016-07-21
|
| 63 |
+
### Fixed
|
| 64 |
+
- Fixed nasty bug in deflate (wrong `d_buf` offset), which could cause
|
| 65 |
+
broken data in some rare cases.
|
| 66 |
+
- Also released as 0.2.9 to give chance to old dependents, not updated to 1.x
|
| 67 |
+
version.
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
## [1.0.1] - 2016-04-01
|
| 71 |
+
### Added
|
| 72 |
+
- Added dictionary support. Thanks to @dignifiedquire.
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
## [1.0.0] - 2016-02-17
|
| 76 |
+
### Changed
|
| 77 |
+
- Maintenance release (semver, coding style).
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
## [0.2.8] - 2015-09-14
|
| 81 |
+
### Fixed
|
| 82 |
+
- Fixed regression after 0.2.4 for edge conditions in inflate wrapper (#65).
|
| 83 |
+
Added more tests to cover possible cases.
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
## [0.2.7] - 2015-06-09
|
| 87 |
+
### Added
|
| 88 |
+
- Added Z_SYNC_FLUSH support. Thanks to @TinoLange.
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
## [0.2.6] - 2015-03-24
|
| 92 |
+
### Added
|
| 93 |
+
- Allow ArrayBuffer input.
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
## [0.2.5] - 2014-07-19
|
| 97 |
+
### Fixed
|
| 98 |
+
- Workaround for Chrome 38.0.2096.0 script parser bug, #30.
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
## [0.2.4] - 2014-07-07
|
| 102 |
+
### Fixed
|
| 103 |
+
- Fixed bug in inflate wrapper, #29
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
## [0.2.3] - 2014-06-09
|
| 107 |
+
### Changed
|
| 108 |
+
- Maintenance release, dependencies update.
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
## [0.2.2] - 2014-06-04
|
| 112 |
+
### Fixed
|
| 113 |
+
- Fixed iOS 5.1 Safari issue with `apply(typed_array)`, #26.
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
## [0.2.1] - 2014-05-01
|
| 117 |
+
### Fixed
|
| 118 |
+
- Fixed collision on switch dynamic/fixed tables.
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
## [0.2.0] - 2014-04-18
|
| 122 |
+
### Added
|
| 123 |
+
- Added custom gzip headers support.
|
| 124 |
+
- Added strings support.
|
| 125 |
+
- More coverage tests.
|
| 126 |
+
|
| 127 |
+
### Fixed
|
| 128 |
+
- Improved memory allocations for small chunks.
|
| 129 |
+
- ZStream properties rename/cleanup.
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
## [0.1.1] - 2014-03-20
|
| 133 |
+
### Fixed
|
| 134 |
+
- Bugfixes for inflate/deflate.
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
## [0.1.0] - 2014-03-15
|
| 138 |
+
### Added
|
| 139 |
+
- First release.
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
[1.0.10]: https://github.com/nodeca/pako/compare/1.0.10...1.0.11
|
| 143 |
+
[1.0.10]: https://github.com/nodeca/pako/compare/1.0.9...1.0.10
|
| 144 |
+
[1.0.9]: https://github.com/nodeca/pako/compare/1.0.8...1.0.9
|
| 145 |
+
[1.0.8]: https://github.com/nodeca/pako/compare/1.0.7...1.0.8
|
| 146 |
+
[1.0.7]: https://github.com/nodeca/pako/compare/1.0.6...1.0.7
|
| 147 |
+
[1.0.6]: https://github.com/nodeca/pako/compare/1.0.5...1.0.6
|
| 148 |
+
[1.0.5]: https://github.com/nodeca/pako/compare/1.0.4...1.0.5
|
| 149 |
+
[1.0.4]: https://github.com/nodeca/pako/compare/1.0.3...1.0.4
|
| 150 |
+
[1.0.3]: https://github.com/nodeca/pako/compare/1.0.2...1.0.3
|
| 151 |
+
[1.0.2]: https://github.com/nodeca/pako/compare/1.0.1...1.0.2
|
| 152 |
+
[1.0.1]: https://github.com/nodeca/pako/compare/1.0.0...1.0.1
|
| 153 |
+
[1.0.0]: https://github.com/nodeca/pako/compare/0.2.8...1.0.0
|
| 154 |
+
[0.2.8]: https://github.com/nodeca/pako/compare/0.2.7...0.2.8
|
| 155 |
+
[0.2.7]: https://github.com/nodeca/pako/compare/0.2.6...0.2.7
|
| 156 |
+
[0.2.6]: https://github.com/nodeca/pako/compare/0.2.5...0.2.6
|
| 157 |
+
[0.2.5]: https://github.com/nodeca/pako/compare/0.2.4...0.2.5
|
| 158 |
+
[0.2.4]: https://github.com/nodeca/pako/compare/0.2.3...0.2.4
|
| 159 |
+
[0.2.3]: https://github.com/nodeca/pako/compare/0.2.2...0.2.3
|
| 160 |
+
[0.2.2]: https://github.com/nodeca/pako/compare/0.2.1...0.2.2
|
| 161 |
+
[0.2.1]: https://github.com/nodeca/pako/compare/0.2.0...0.2.1
|
| 162 |
+
[0.2.0]: https://github.com/nodeca/pako/compare/0.1.1...0.2.0
|
| 163 |
+
[0.1.1]: https://github.com/nodeca/pako/compare/0.1.0...0.1.1
|
| 164 |
+
[0.1.0]: https://github.com/nodeca/pako/releases/tag/0.1.0
|
node_modules/pako/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(The MIT License)
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
node_modules/pako/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pako
|
| 2 |
+
==========================================
|
| 3 |
+
|
| 4 |
+
[](https://travis-ci.org/nodeca/pako)
|
| 5 |
+
[](https://www.npmjs.org/package/pako)
|
| 6 |
+
|
| 7 |
+
> zlib port to javascript, very fast!
|
| 8 |
+
|
| 9 |
+
__Why pako is cool:__
|
| 10 |
+
|
| 11 |
+
- Almost as fast in modern JS engines as C implementation (see benchmarks).
|
| 12 |
+
- Works in browsers, you can browserify any separate component.
|
| 13 |
+
- Chunking support for big blobs.
|
| 14 |
+
- Results are binary equal to well known [zlib](http://www.zlib.net/) (now contains ported zlib v1.2.8).
|
| 15 |
+
|
| 16 |
+
This project was done to understand how fast JS can be and is it necessary to
|
| 17 |
+
develop native C modules for CPU-intensive tasks. Enjoy the result!
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
__Famous projects, using pako:__
|
| 21 |
+
|
| 22 |
+
- [browserify](http://browserify.org/) (via [browserify-zlib](https://github.com/devongovett/browserify-zlib))
|
| 23 |
+
- [JSZip](http://stuk.github.io/jszip/)
|
| 24 |
+
- [mincer](https://github.com/nodeca/mincer)
|
| 25 |
+
- [JS-Git](https://github.com/creationix/js-git) and
|
| 26 |
+
[Tedit](https://chrome.google.com/webstore/detail/tedit-development-environ/ooekdijbnbbjdfjocaiflnjgoohnblgf)
|
| 27 |
+
by [@creationix](https://github.com/creationix)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
__Benchmarks:__
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
node v0.10.26, 1mb sample:
|
| 34 |
+
|
| 35 |
+
deflate-dankogai x 4.73 ops/sec ±0.82% (15 runs sampled)
|
| 36 |
+
deflate-gildas x 4.58 ops/sec ±2.33% (15 runs sampled)
|
| 37 |
+
deflate-imaya x 3.22 ops/sec ±3.95% (12 runs sampled)
|
| 38 |
+
! deflate-pako x 6.99 ops/sec ±0.51% (21 runs sampled)
|
| 39 |
+
deflate-pako-string x 5.89 ops/sec ±0.77% (18 runs sampled)
|
| 40 |
+
deflate-pako-untyped x 4.39 ops/sec ±1.58% (14 runs sampled)
|
| 41 |
+
* deflate-zlib x 14.71 ops/sec ±4.23% (59 runs sampled)
|
| 42 |
+
inflate-dankogai x 32.16 ops/sec ±0.13% (56 runs sampled)
|
| 43 |
+
inflate-imaya x 30.35 ops/sec ±0.92% (53 runs sampled)
|
| 44 |
+
! inflate-pako x 69.89 ops/sec ±1.46% (71 runs sampled)
|
| 45 |
+
inflate-pako-string x 19.22 ops/sec ±1.86% (49 runs sampled)
|
| 46 |
+
inflate-pako-untyped x 17.19 ops/sec ±0.85% (32 runs sampled)
|
| 47 |
+
* inflate-zlib x 70.03 ops/sec ±1.64% (81 runs sampled)
|
| 48 |
+
|
| 49 |
+
node v0.11.12, 1mb sample:
|
| 50 |
+
|
| 51 |
+
deflate-dankogai x 5.60 ops/sec ±0.49% (17 runs sampled)
|
| 52 |
+
deflate-gildas x 5.06 ops/sec ±6.00% (16 runs sampled)
|
| 53 |
+
deflate-imaya x 3.52 ops/sec ±3.71% (13 runs sampled)
|
| 54 |
+
! deflate-pako x 11.52 ops/sec ±0.22% (32 runs sampled)
|
| 55 |
+
deflate-pako-string x 9.53 ops/sec ±1.12% (27 runs sampled)
|
| 56 |
+
deflate-pako-untyped x 5.44 ops/sec ±0.72% (17 runs sampled)
|
| 57 |
+
* deflate-zlib x 14.05 ops/sec ±3.34% (63 runs sampled)
|
| 58 |
+
inflate-dankogai x 42.19 ops/sec ±0.09% (56 runs sampled)
|
| 59 |
+
inflate-imaya x 79.68 ops/sec ±1.07% (68 runs sampled)
|
| 60 |
+
! inflate-pako x 97.52 ops/sec ±0.83% (80 runs sampled)
|
| 61 |
+
inflate-pako-string x 45.19 ops/sec ±1.69% (57 runs sampled)
|
| 62 |
+
inflate-pako-untyped x 24.35 ops/sec ±2.59% (40 runs sampled)
|
| 63 |
+
* inflate-zlib x 60.32 ops/sec ±1.36% (69 runs sampled)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
zlib's test is partially affected by marshalling (that make sense for inflate only).
|
| 67 |
+
You can change deflate level to 0 in benchmark source, to investigate details.
|
| 68 |
+
For deflate level 6 results can be considered as correct.
|
| 69 |
+
|
| 70 |
+
__Install:__
|
| 71 |
+
|
| 72 |
+
node.js:
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
npm install pako
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
browser:
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
bower install pako
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
Example & API
|
| 86 |
+
-------------
|
| 87 |
+
|
| 88 |
+
Full docs - http://nodeca.github.io/pako/
|
| 89 |
+
|
| 90 |
+
```javascript
|
| 91 |
+
var pako = require('pako');
|
| 92 |
+
|
| 93 |
+
// Deflate
|
| 94 |
+
//
|
| 95 |
+
var input = new Uint8Array();
|
| 96 |
+
//... fill input data here
|
| 97 |
+
var output = pako.deflate(input);
|
| 98 |
+
|
| 99 |
+
// Inflate (simple wrapper can throw exception on broken stream)
|
| 100 |
+
//
|
| 101 |
+
var compressed = new Uint8Array();
|
| 102 |
+
//... fill data to uncompress here
|
| 103 |
+
try {
|
| 104 |
+
var result = pako.inflate(compressed);
|
| 105 |
+
} catch (err) {
|
| 106 |
+
console.log(err);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
//
|
| 110 |
+
// Alternate interface for chunking & without exceptions
|
| 111 |
+
//
|
| 112 |
+
|
| 113 |
+
var inflator = new pako.Inflate();
|
| 114 |
+
|
| 115 |
+
inflator.push(chunk1, false);
|
| 116 |
+
inflator.push(chunk2, false);
|
| 117 |
+
...
|
| 118 |
+
inflator.push(chunkN, true); // true -> last chunk
|
| 119 |
+
|
| 120 |
+
if (inflator.err) {
|
| 121 |
+
console.log(inflator.msg);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
var output = inflator.result;
|
| 125 |
+
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
Sometime you can wish to work with strings. For example, to send
|
| 129 |
+
big objects as json to server. Pako detects input data type. You can
|
| 130 |
+
force output to be string with option `{ to: 'string' }`.
|
| 131 |
+
|
| 132 |
+
```javascript
|
| 133 |
+
var pako = require('pako');
|
| 134 |
+
|
| 135 |
+
var test = { my: 'super', puper: [456, 567], awesome: 'pako' };
|
| 136 |
+
|
| 137 |
+
var binaryString = pako.deflate(JSON.stringify(test), { to: 'string' });
|
| 138 |
+
|
| 139 |
+
//
|
| 140 |
+
// Here you can do base64 encode, make xhr requests and so on.
|
| 141 |
+
//
|
| 142 |
+
|
| 143 |
+
var restored = JSON.parse(pako.inflate(binaryString, { to: 'string' }));
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
Notes
|
| 148 |
+
-----
|
| 149 |
+
|
| 150 |
+
Pako does not contain some specific zlib functions:
|
| 151 |
+
|
| 152 |
+
- __deflate__ - methods `deflateCopy`, `deflateBound`, `deflateParams`,
|
| 153 |
+
`deflatePending`, `deflatePrime`, `deflateTune`.
|
| 154 |
+
- __inflate__ - methods `inflateCopy`, `inflateMark`,
|
| 155 |
+
`inflatePrime`, `inflateGetDictionary`, `inflateSync`, `inflateSyncPoint`, `inflateUndermine`.
|
| 156 |
+
- High level inflate/deflate wrappers (classes) may not support some flush
|
| 157 |
+
modes. Those should work: Z_NO_FLUSH, Z_FINISH, Z_SYNC_FLUSH.
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
pako for enterprise
|
| 161 |
+
-------------------
|
| 162 |
+
|
| 163 |
+
Available as part of the Tidelift Subscription
|
| 164 |
+
|
| 165 |
+
The maintainers of pako and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-pako?utm_source=npm-pako&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
Authors
|
| 169 |
+
-------
|
| 170 |
+
|
| 171 |
+
- Andrey Tupitsin [@anrd83](https://github.com/andr83)
|
| 172 |
+
- Vitaly Puzrin [@puzrin](https://github.com/puzrin)
|
| 173 |
+
|
| 174 |
+
Personal thanks to:
|
| 175 |
+
|
| 176 |
+
- Vyacheslav Egorov ([@mraleph](https://github.com/mraleph)) for his awesome
|
| 177 |
+
tutorials about optimising JS code for v8, [IRHydra](http://mrale.ph/irhydra/)
|
| 178 |
+
tool and his advices.
|
| 179 |
+
- David Duponchel ([@dduponchel](https://github.com/dduponchel)) for help with
|
| 180 |
+
testing.
|
| 181 |
+
|
| 182 |
+
Original implementation (in C):
|
| 183 |
+
|
| 184 |
+
- [zlib](http://zlib.net/) by Jean-loup Gailly and Mark Adler.
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
License
|
| 188 |
+
-------
|
| 189 |
+
|
| 190 |
+
- MIT - all files, except `/lib/zlib` folder
|
| 191 |
+
- ZLIB - `/lib/zlib` content
|