@wener/utils 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/jest.config.js +7 -5
- package/lib/cjs/arrays/MaybeArray.js +45 -33
- package/lib/cjs/arrays/index.js +17 -5
- package/lib/cjs/asyncs/AsyncInterval.js +32 -25
- package/lib/cjs/asyncs/LazyPromise.js +41 -24
- package/lib/cjs/asyncs/MaybePromise.js +15 -3
- package/lib/cjs/asyncs/generatorOfStream.js +33 -28
- package/lib/cjs/asyncs/index.js +23 -11
- package/lib/cjs/asyncs/isPromise.js +23 -6
- package/lib/cjs/asyncs/promiseOfCallback.js +34 -19
- package/lib/cjs/asyncs/sleep.js +23 -5
- package/lib/cjs/asyncs/timeout.js +42 -28
- package/lib/cjs/browsers/copy.js +71 -0
- package/lib/cjs/browsers/download.js +44 -33
- package/lib/cjs/browsers/getFileFromDataTransfer.js +48 -0
- package/lib/cjs/browsers/index.js +20 -8
- package/lib/cjs/browsers/loaders.js +48 -35
- package/lib/cjs/formats/formatBytes.js +36 -0
- package/lib/cjs/index.js +35 -13
- package/lib/cjs/io/index.js +17 -5
- package/lib/cjs/io/isBuffer.js +23 -10
- package/lib/cjs/isomorphics/getGlobalThis.js +32 -27
- package/lib/cjs/maths/index.js +17 -5
- package/lib/cjs/maths/random.js +34 -19
- package/lib/cjs/shim/urljoin.js +70 -0
- package/lib/cjs/shim/urljoin.test.js +4 -0
- package/lib/cjs/strings/camelCase.js +70 -68
- package/lib/cjs/strings/index.js +18 -7
- package/lib/cjs/strings/templates.js +26 -18
- package/lib/cjs/validations/asserts.js +25 -14
- package/lib/cjs/validations/index.js +20 -8
- package/lib/cjs/validations/isClass.js +23 -6
- package/lib/cjs/validations/isDefined.js +23 -6
- package/lib/cjs/validations/isEmptyObject.js +26 -9
- package/lib/esm/arrays/MaybeArray.js +29 -29
- package/lib/esm/arrays/index.js +1 -2
- package/lib/esm/asyncs/AsyncInterval.js +14 -21
- package/lib/esm/asyncs/LazyPromise.js +23 -21
- package/lib/esm/asyncs/MaybePromise.js +0 -1
- package/lib/esm/asyncs/generatorOfStream.js +14 -24
- package/lib/esm/asyncs/index.js +7 -8
- package/lib/esm/asyncs/isPromise.js +5 -3
- package/lib/esm/asyncs/promiseOfCallback.js +16 -16
- package/lib/esm/asyncs/sleep.js +4 -2
- package/lib/esm/asyncs/timeout.js +24 -25
- package/lib/{cjs/browsers/clipboard.d.ts → esm/browsers/copy.d.ts} +0 -0
- package/lib/esm/browsers/copy.js +52 -0
- package/lib/esm/browsers/download.js +25 -29
- package/lib/esm/browsers/getFileFromDataTransfer.d.ts +4 -0
- package/lib/esm/browsers/getFileFromDataTransfer.js +29 -0
- package/lib/esm/browsers/index.d.ts +2 -2
- package/lib/esm/browsers/index.js +4 -5
- package/lib/esm/browsers/loaders.js +31 -32
- package/lib/esm/formats/formatBytes.d.ts +11 -0
- package/lib/esm/formats/formatBytes.js +17 -0
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +15 -10
- package/lib/esm/io/index.js +1 -2
- package/lib/esm/io/isBuffer.js +5 -7
- package/lib/esm/isomorphics/getGlobalThis.d.ts +1 -1
- package/lib/esm/isomorphics/getGlobalThis.js +13 -24
- package/lib/esm/maths/index.js +1 -2
- package/lib/esm/maths/random.d.ts +2 -2
- package/lib/esm/maths/random.js +15 -15
- package/lib/{cjs/strings → esm/shim}/urljoin.d.ts +1 -0
- package/lib/esm/shim/urljoin.js +51 -0
- package/lib/{cjs/strings → esm/shim}/urljoin.test.d.ts +0 -0
- package/lib/esm/shim/urljoin.test.js +4 -0
- package/lib/esm/strings/camelCase.js +52 -64
- package/lib/esm/strings/index.d.ts +0 -1
- package/lib/esm/strings/index.js +2 -4
- package/lib/esm/strings/templates.d.ts +1 -1
- package/lib/esm/strings/templates.js +7 -14
- package/lib/esm/validations/asserts.js +8 -11
- package/lib/esm/validations/index.js +4 -5
- package/lib/esm/validations/isClass.js +5 -3
- package/lib/esm/validations/isDefined.js +5 -3
- package/lib/esm/validations/isEmptyObject.js +8 -6
- package/package.json +23 -32
- package/src/arrays/MaybeArray.ts +5 -2
- package/src/asyncs/timeout.ts +1 -1
- package/src/browsers/{clipboard.ts → copy.ts} +0 -0
- package/src/browsers/{transfers.ts → getFileFromDataTransfer.ts} +12 -7
- package/src/browsers/index.ts +2 -2
- package/src/browsers/loaders.ts +1 -1
- package/src/formats/formatBytes.ts +30 -0
- package/src/index.ts +4 -2
- package/src/isomorphics/getGlobalThis.ts +2 -4
- package/src/maths/random.ts +5 -5
- package/src/shim/urljoin.test.ts +5 -0
- package/src/{strings → shim}/urljoin.ts +18 -5
- package/src/strings/index.ts +0 -1
- package/src/strings/templates.ts +2 -4
- package/tsconfig.json +15 -4
- package/dist/wener-utils.cjs +0 -882
- package/dist/wener-utils.cjs.map +0 -1
- package/dist/wener-utils.esm.js +0 -849
- package/dist/wener-utils.esm.js.map +0 -1
- package/dist/wener-utils.system.js +0 -887
- package/dist/wener-utils.system.js.map +0 -1
- package/dist/wener-utils.umd.js +0 -886
- package/dist/wener-utils.umd.js.map +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -10
- package/lib/cjs/arrays/MaybeArray.d.ts +0 -5
- package/lib/cjs/arrays/MaybeArray.js.map +0 -1
- package/lib/cjs/arrays/index.d.ts +0 -1
- package/lib/cjs/arrays/index.js.map +0 -1
- package/lib/cjs/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/cjs/asyncs/AsyncInterval.js.map +0 -1
- package/lib/cjs/asyncs/LazyPromise.d.ts +0 -5
- package/lib/cjs/asyncs/LazyPromise.js.map +0 -1
- package/lib/cjs/asyncs/MaybePromise.d.ts +0 -1
- package/lib/cjs/asyncs/MaybePromise.js.map +0 -1
- package/lib/cjs/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/cjs/asyncs/generatorOfStream.js.map +0 -1
- package/lib/cjs/asyncs/index.d.ts +0 -7
- package/lib/cjs/asyncs/index.js.map +0 -1
- package/lib/cjs/asyncs/isPromise.d.ts +0 -1
- package/lib/cjs/asyncs/isPromise.js.map +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/cjs/asyncs/sleep.d.ts +0 -1
- package/lib/cjs/asyncs/sleep.js.map +0 -1
- package/lib/cjs/asyncs/timeout.d.ts +0 -4
- package/lib/cjs/asyncs/timeout.js.map +0 -1
- package/lib/cjs/browsers/clipboard.js +0 -56
- package/lib/cjs/browsers/clipboard.js.map +0 -1
- package/lib/cjs/browsers/download.d.ts +0 -4
- package/lib/cjs/browsers/download.js.map +0 -1
- package/lib/cjs/browsers/index.d.ts +0 -4
- package/lib/cjs/browsers/index.js.map +0 -1
- package/lib/cjs/browsers/loaders.d.ts +0 -6
- package/lib/cjs/browsers/loaders.js.map +0 -1
- package/lib/cjs/browsers/transfers.d.ts +0 -4
- package/lib/cjs/browsers/transfers.js +0 -38
- package/lib/cjs/browsers/transfers.js.map +0 -1
- package/lib/cjs/envs/index.d.ts +0 -1
- package/lib/cjs/envs/index.js +0 -5
- package/lib/cjs/envs/index.js.map +0 -1
- package/lib/cjs/envs/isDev.d.ts +0 -1
- package/lib/cjs/envs/isDev.js +0 -8
- package/lib/cjs/envs/isDev.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -9
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/io/index.d.ts +0 -1
- package/lib/cjs/io/index.js.map +0 -1
- package/lib/cjs/io/isBuffer.d.ts +0 -2
- package/lib/cjs/io/isBuffer.js.map +0 -1
- package/lib/cjs/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/cjs/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/cjs/isomorphics/index.d.ts +0 -1
- package/lib/cjs/isomorphics/index.js +0 -5
- package/lib/cjs/isomorphics/index.js.map +0 -1
- package/lib/cjs/maths/index.d.ts +0 -1
- package/lib/cjs/maths/index.js.map +0 -1
- package/lib/cjs/maths/random.d.ts +0 -3
- package/lib/cjs/maths/random.js.map +0 -1
- package/lib/cjs/strings/camelCase.d.ts +0 -4
- package/lib/cjs/strings/camelCase.js.map +0 -1
- package/lib/cjs/strings/index.d.ts +0 -3
- package/lib/cjs/strings/index.js.map +0 -1
- package/lib/cjs/strings/templates.d.ts +0 -7
- package/lib/cjs/strings/templates.js.map +0 -1
- package/lib/cjs/strings/urljoin.js +0 -61
- package/lib/cjs/strings/urljoin.js.map +0 -1
- package/lib/cjs/strings/urljoin.test.js +0 -7
- package/lib/cjs/strings/urljoin.test.js.map +0 -1
- package/lib/cjs/validations/asserts.d.ts +0 -2
- package/lib/cjs/validations/asserts.js.map +0 -1
- package/lib/cjs/validations/index.d.ts +0 -4
- package/lib/cjs/validations/index.js.map +0 -1
- package/lib/cjs/validations/isClass.d.ts +0 -1
- package/lib/cjs/validations/isClass.js.map +0 -1
- package/lib/cjs/validations/isDefined.d.ts +0 -1
- package/lib/cjs/validations/isDefined.js.map +0 -1
- package/lib/cjs/validations/isEmptyObject.d.ts +0 -1
- package/lib/cjs/validations/isEmptyObject.js.map +0 -1
- package/lib/esm/arrays/MaybeArray.js.map +0 -1
- package/lib/esm/arrays/index.js.map +0 -1
- package/lib/esm/asyncs/AsyncInterval.js.map +0 -1
- package/lib/esm/asyncs/LazyPromise.js.map +0 -1
- package/lib/esm/asyncs/MaybePromise.js.map +0 -1
- package/lib/esm/asyncs/generatorOfStream.js.map +0 -1
- package/lib/esm/asyncs/index.js.map +0 -1
- package/lib/esm/asyncs/isPromise.js.map +0 -1
- package/lib/esm/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/esm/asyncs/sleep.js.map +0 -1
- package/lib/esm/asyncs/timeout.js.map +0 -1
- package/lib/esm/browsers/clipboard.d.ts +0 -1
- package/lib/esm/browsers/clipboard.js +0 -52
- package/lib/esm/browsers/clipboard.js.map +0 -1
- package/lib/esm/browsers/download.js.map +0 -1
- package/lib/esm/browsers/index.js.map +0 -1
- package/lib/esm/browsers/loaders.js.map +0 -1
- package/lib/esm/browsers/transfers.d.ts +0 -4
- package/lib/esm/browsers/transfers.js +0 -34
- package/lib/esm/browsers/transfers.js.map +0 -1
- package/lib/esm/envs/index.d.ts +0 -1
- package/lib/esm/envs/index.js +0 -2
- package/lib/esm/envs/index.js.map +0 -1
- package/lib/esm/envs/isDev.d.ts +0 -1
- package/lib/esm/envs/isDev.js +0 -5
- package/lib/esm/envs/isDev.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/io/index.js.map +0 -1
- package/lib/esm/io/isBuffer.js.map +0 -1
- package/lib/esm/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/esm/isomorphics/index.d.ts +0 -1
- package/lib/esm/isomorphics/index.js +0 -2
- package/lib/esm/isomorphics/index.js.map +0 -1
- package/lib/esm/maths/index.js.map +0 -1
- package/lib/esm/maths/random.js.map +0 -1
- package/lib/esm/strings/camelCase.js.map +0 -1
- package/lib/esm/strings/index.js.map +0 -1
- package/lib/esm/strings/templates.js.map +0 -1
- package/lib/esm/strings/urljoin.d.ts +0 -1
- package/lib/esm/strings/urljoin.js +0 -57
- package/lib/esm/strings/urljoin.js.map +0 -1
- package/lib/esm/strings/urljoin.test.d.ts +0 -1
- package/lib/esm/strings/urljoin.test.js +0 -5
- package/lib/esm/strings/urljoin.test.js.map +0 -1
- package/lib/esm/validations/asserts.js.map +0 -1
- package/lib/esm/validations/index.js.map +0 -1
- package/lib/esm/validations/isClass.js.map +0 -1
- package/lib/esm/validations/isDefined.js.map +0 -1
- package/lib/esm/validations/isEmptyObject.js.map +0 -1
- package/lib/esnext/arrays/MaybeArray.d.ts +0 -5
- package/lib/esnext/arrays/MaybeArray.js +0 -33
- package/lib/esnext/arrays/MaybeArray.js.map +0 -1
- package/lib/esnext/arrays/index.d.ts +0 -1
- package/lib/esnext/arrays/index.js +0 -2
- package/lib/esnext/arrays/index.js.map +0 -1
- package/lib/esnext/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/esnext/asyncs/AsyncInterval.js +0 -23
- package/lib/esnext/asyncs/AsyncInterval.js.map +0 -1
- package/lib/esnext/asyncs/LazyPromise.d.ts +0 -5
- package/lib/esnext/asyncs/LazyPromise.js +0 -22
- package/lib/esnext/asyncs/LazyPromise.js.map +0 -1
- package/lib/esnext/asyncs/MaybePromise.d.ts +0 -1
- package/lib/esnext/asyncs/MaybePromise.js +0 -1
- package/lib/esnext/asyncs/MaybePromise.js.map +0 -1
- package/lib/esnext/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/esnext/asyncs/generatorOfStream.js +0 -26
- package/lib/esnext/asyncs/generatorOfStream.js.map +0 -1
- package/lib/esnext/asyncs/index.d.ts +0 -7
- package/lib/esnext/asyncs/index.js +0 -8
- package/lib/esnext/asyncs/index.js.map +0 -1
- package/lib/esnext/asyncs/isPromise.d.ts +0 -1
- package/lib/esnext/asyncs/isPromise.js +0 -4
- package/lib/esnext/asyncs/isPromise.js.map +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.js +0 -18
- package/lib/esnext/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/esnext/asyncs/sleep.d.ts +0 -1
- package/lib/esnext/asyncs/sleep.js +0 -2
- package/lib/esnext/asyncs/sleep.js.map +0 -1
- package/lib/esnext/asyncs/timeout.d.ts +0 -4
- package/lib/esnext/asyncs/timeout.js +0 -26
- package/lib/esnext/asyncs/timeout.js.map +0 -1
- package/lib/esnext/browsers/clipboard.d.ts +0 -1
- package/lib/esnext/browsers/clipboard.js +0 -52
- package/lib/esnext/browsers/clipboard.js.map +0 -1
- package/lib/esnext/browsers/download.d.ts +0 -4
- package/lib/esnext/browsers/download.js +0 -32
- package/lib/esnext/browsers/download.js.map +0 -1
- package/lib/esnext/browsers/index.d.ts +0 -4
- package/lib/esnext/browsers/index.js +0 -5
- package/lib/esnext/browsers/index.js.map +0 -1
- package/lib/esnext/browsers/loaders.d.ts +0 -6
- package/lib/esnext/browsers/loaders.js +0 -36
- package/lib/esnext/browsers/loaders.js.map +0 -1
- package/lib/esnext/browsers/transfers.d.ts +0 -4
- package/lib/esnext/browsers/transfers.js +0 -34
- package/lib/esnext/browsers/transfers.js.map +0 -1
- package/lib/esnext/envs/index.d.ts +0 -1
- package/lib/esnext/envs/index.js +0 -2
- package/lib/esnext/envs/index.js.map +0 -1
- package/lib/esnext/envs/isDev.d.ts +0 -1
- package/lib/esnext/envs/isDev.js +0 -5
- package/lib/esnext/envs/isDev.js.map +0 -1
- package/lib/esnext/index.d.ts +0 -9
- package/lib/esnext/index.js +0 -10
- package/lib/esnext/index.js.map +0 -1
- package/lib/esnext/io/index.d.ts +0 -1
- package/lib/esnext/io/index.js +0 -2
- package/lib/esnext/io/index.js.map +0 -1
- package/lib/esnext/io/isBuffer.d.ts +0 -2
- package/lib/esnext/io/isBuffer.js +0 -8
- package/lib/esnext/io/isBuffer.js.map +0 -1
- package/lib/esnext/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/esnext/isomorphics/getGlobalThis.js +0 -25
- package/lib/esnext/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/esnext/isomorphics/index.d.ts +0 -1
- package/lib/esnext/isomorphics/index.js +0 -2
- package/lib/esnext/isomorphics/index.js.map +0 -1
- package/lib/esnext/maths/index.d.ts +0 -1
- package/lib/esnext/maths/index.js +0 -2
- package/lib/esnext/maths/index.js.map +0 -1
- package/lib/esnext/maths/random.d.ts +0 -3
- package/lib/esnext/maths/random.js +0 -17
- package/lib/esnext/maths/random.js.map +0 -1
- package/lib/esnext/strings/camelCase.d.ts +0 -4
- package/lib/esnext/strings/camelCase.js +0 -69
- package/lib/esnext/strings/camelCase.js.map +0 -1
- package/lib/esnext/strings/index.d.ts +0 -3
- package/lib/esnext/strings/index.js +0 -4
- package/lib/esnext/strings/index.js.map +0 -1
- package/lib/esnext/strings/templates.d.ts +0 -7
- package/lib/esnext/strings/templates.js +0 -15
- package/lib/esnext/strings/templates.js.map +0 -1
- package/lib/esnext/strings/urljoin.d.ts +0 -1
- package/lib/esnext/strings/urljoin.js +0 -57
- package/lib/esnext/strings/urljoin.js.map +0 -1
- package/lib/esnext/strings/urljoin.test.d.ts +0 -1
- package/lib/esnext/strings/urljoin.test.js +0 -5
- package/lib/esnext/strings/urljoin.test.js.map +0 -1
- package/lib/esnext/validations/asserts.d.ts +0 -2
- package/lib/esnext/validations/asserts.js +0 -13
- package/lib/esnext/validations/asserts.js.map +0 -1
- package/lib/esnext/validations/index.d.ts +0 -4
- package/lib/esnext/validations/index.js +0 -5
- package/lib/esnext/validations/index.js.map +0 -1
- package/lib/esnext/validations/isClass.d.ts +0 -1
- package/lib/esnext/validations/isClass.js +0 -4
- package/lib/esnext/validations/isClass.js.map +0 -1
- package/lib/esnext/validations/isDefined.d.ts +0 -1
- package/lib/esnext/validations/isDefined.js +0 -4
- package/lib/esnext/validations/isDefined.js.map +0 -1
- package/lib/esnext/validations/isEmptyObject.d.ts +0 -1
- package/lib/esnext/validations/isEmptyObject.js +0 -7
- package/lib/esnext/validations/isEmptyObject.js.map +0 -1
- package/rollup.config.ts +0 -85
- package/src/envs/index.ts +0 -1
- package/src/envs/isDev.ts +0 -3
- package/src/isomorphics/index.ts +0 -1
- package/src/strings/urljoin.test.ts +0 -5
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# Daily use utils
|
|
2
2
|
|
|
3
|
-
* [Document](https://apis.wener.me/docs/@wener/utils/index.html)
|
|
4
|
-
|
|
5
|
-
|
|
6
3
|
<!-- LINK:BEGIN -->
|
|
7
4
|
|
|
8
5
|
# Links
|
|
@@ -15,6 +12,11 @@
|
|
|
15
12
|
* APIs playground with docs & stories
|
|
16
13
|
* Github [wenerme/apis](https://github.com/wenerme/apis)
|
|
17
14
|
* Library
|
|
15
|
+
* [@wener/reaction](https://www.npmjs.com/package/@wener/reaction) -  - 
|
|
16
|
+
* React hooks, render, logical components
|
|
17
|
+
* helpful typing
|
|
18
|
+
* some external minimal helpful utils
|
|
19
|
+
* reduce packages
|
|
18
20
|
* [@wener/utils](https://www.npmjs.com/package/@wener/utils) -  - 
|
|
19
21
|
* utils for daily use
|
|
20
22
|
* [Document](https://apis.wener.me/docs/@wener/utils/)
|
package/jest.config.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
const { pathsToModuleNameMapper } = require('ts-jest/utils');
|
|
2
|
-
const { compilerOptions } = require('./tsconfig');
|
|
1
|
+
// const { pathsToModuleNameMapper } = require('ts-jest/utils');
|
|
2
|
+
// const { compilerOptions } = require('./tsconfig');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
setupFiles: ['<rootDir>/jest.setup.js'],
|
|
6
6
|
transform: {
|
|
7
|
-
'^.+\\.(ts|tsx)$': 'ts-jest'
|
|
7
|
+
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
8
8
|
},
|
|
9
9
|
globals: {
|
|
10
10
|
'ts-jest': {
|
|
11
|
-
tsConfig: 'tsconfig.jest.json'
|
|
11
|
+
tsConfig: 'tsconfig.jest.json',
|
|
12
12
|
// tsConfig: 'tsconfig.json',
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
14
|
},
|
|
15
|
+
// roots: ['<rootDir>/src/', '<rootDir>/tests/'],
|
|
16
|
+
testMatch: ['<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
15
17
|
// moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' })
|
|
16
18
|
};
|
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var MaybeArray_exports = {};
|
|
19
|
+
__export(MaybeArray_exports, {
|
|
20
|
+
arrayOfMaybeArray: () => arrayOfMaybeArray,
|
|
21
|
+
firstOfMaybeArray: () => firstOfMaybeArray,
|
|
22
|
+
lastOfMaybeArray: () => lastOfMaybeArray,
|
|
23
|
+
objectOfMaybeArray: () => objectOfMaybeArray
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(MaybeArray_exports);
|
|
26
|
+
function objectOfMaybeArray(o, keys = null, picker = firstOfMaybeArray) {
|
|
27
|
+
if (keys === null) {
|
|
28
|
+
return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, picker(v)]));
|
|
29
|
+
}
|
|
30
|
+
return Object.fromEntries(keys.map((v) => [v, picker(v)]));
|
|
14
31
|
}
|
|
15
|
-
exports.objectOfMaybeArray = objectOfMaybeArray;
|
|
16
32
|
function firstOfMaybeArray(v) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
if (Array.isArray(v)) {
|
|
34
|
+
return v[0];
|
|
35
|
+
}
|
|
36
|
+
return v;
|
|
21
37
|
}
|
|
22
|
-
exports.firstOfMaybeArray = firstOfMaybeArray;
|
|
23
38
|
function lastOfMaybeArray(v) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
if (Array.isArray(v)) {
|
|
40
|
+
return v[v.length - 1];
|
|
41
|
+
}
|
|
42
|
+
return v;
|
|
28
43
|
}
|
|
29
|
-
exports.lastOfMaybeArray = lastOfMaybeArray;
|
|
30
44
|
function arrayOfMaybeArray(v) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
if (Array.isArray(v)) {
|
|
46
|
+
return v;
|
|
47
|
+
}
|
|
48
|
+
if (v === null || v === void 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return [v];
|
|
38
52
|
}
|
|
39
|
-
exports.arrayOfMaybeArray = arrayOfMaybeArray;
|
|
40
|
-
//# sourceMappingURL=MaybeArray.js.map
|
package/lib/cjs/arrays/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var arrays_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(arrays_exports);
|
|
17
|
+
__reExport(arrays_exports, require("./MaybeArray"), module.exports);
|
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var AsyncInterval_exports = {};
|
|
19
|
+
__export(AsyncInterval_exports, {
|
|
20
|
+
clearAsyncInterval: () => clearAsyncInterval,
|
|
21
|
+
setAsyncInterval: () => setAsyncInterval
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AsyncInterval_exports);
|
|
24
|
+
function setAsyncInterval(cb, interval, initial = interval) {
|
|
25
|
+
let id;
|
|
26
|
+
const handler = async () => {
|
|
27
|
+
await cb();
|
|
28
|
+
id = setTimeout(handler, interval);
|
|
29
|
+
};
|
|
30
|
+
id = setTimeout(handler, initial);
|
|
31
|
+
return () => id;
|
|
22
32
|
}
|
|
23
|
-
exports.setAsyncInterval = setAsyncInterval;
|
|
24
33
|
function clearAsyncInterval(v) {
|
|
25
|
-
|
|
34
|
+
clearTimeout(v == null ? void 0 : v());
|
|
26
35
|
}
|
|
27
|
-
exports.clearAsyncInterval = clearAsyncInterval;
|
|
28
|
-
//# sourceMappingURL=AsyncInterval.js.map
|
|
@@ -1,26 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var LazyPromise_exports = {};
|
|
19
|
+
__export(LazyPromise_exports, {
|
|
20
|
+
createLazyPromise: () => createLazyPromise
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(LazyPromise_exports);
|
|
4
23
|
function createLazyPromise() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const holder = {
|
|
25
|
+
resolve(_) {
|
|
26
|
+
throw new Error("pending resolve");
|
|
27
|
+
},
|
|
28
|
+
reject(_) {
|
|
29
|
+
throw new Error("pending reject");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return Object.assign(new Promise((resolve, reject) => {
|
|
33
|
+
holder.reject = reject;
|
|
34
|
+
holder.resolve = resolve;
|
|
35
|
+
}), {
|
|
36
|
+
resolve(v) {
|
|
37
|
+
holder.resolve(v);
|
|
38
|
+
},
|
|
39
|
+
reject(v) {
|
|
40
|
+
holder.resolve(v);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
24
43
|
}
|
|
25
|
-
exports.createLazyPromise = createLazyPromise;
|
|
26
|
-
//# sourceMappingURL=LazyPromise.js.map
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var MaybePromise_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(MaybePromise_exports);
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var generatorOfStream_exports = {};
|
|
19
|
+
__export(generatorOfStream_exports, {
|
|
20
|
+
generatorOfStream: () => generatorOfStream
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(generatorOfStream_exports);
|
|
23
|
+
function* generatorOfStream(stream) {
|
|
24
|
+
let done = false;
|
|
25
|
+
stream.on("end", () => {
|
|
26
|
+
done = true;
|
|
27
|
+
});
|
|
28
|
+
while (!done) {
|
|
29
|
+
yield new Promise((resolve, reject) => {
|
|
30
|
+
stream.once("data", resolve);
|
|
31
|
+
stream.once("end", resolve);
|
|
32
|
+
stream.once("error", reject);
|
|
27
33
|
});
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
|
-
exports.generatorOfStream = generatorOfStream;
|
|
30
|
-
//# sourceMappingURL=generatorOfStream.js.map
|
package/lib/cjs/asyncs/index.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var asyncs_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(asyncs_exports);
|
|
17
|
+
__reExport(asyncs_exports, require("./LazyPromise"), module.exports);
|
|
18
|
+
__reExport(asyncs_exports, require("./AsyncInterval"), module.exports);
|
|
19
|
+
__reExport(asyncs_exports, require("./MaybePromise"), module.exports);
|
|
20
|
+
__reExport(asyncs_exports, require("./sleep"), module.exports);
|
|
21
|
+
__reExport(asyncs_exports, require("./timeout"), module.exports);
|
|
22
|
+
__reExport(asyncs_exports, require("./isPromise"), module.exports);
|
|
23
|
+
__reExport(asyncs_exports, require("./promiseOfCallback"), module.exports);
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var isPromise_exports = {};
|
|
19
|
+
__export(isPromise_exports, {
|
|
20
|
+
isPromise: () => isPromise
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(isPromise_exports);
|
|
4
23
|
function isPromise(v) {
|
|
5
|
-
|
|
24
|
+
return v && (v instanceof Promise || v.then && v.catch);
|
|
6
25
|
}
|
|
7
|
-
exports.isPromise = isPromise;
|
|
8
|
-
//# sourceMappingURL=isPromise.js.map
|
|
@@ -1,22 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var promiseOfCallback_exports = {};
|
|
19
|
+
__export(promiseOfCallback_exports, {
|
|
20
|
+
promiseOfCallback: () => promiseOfCallback
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(promiseOfCallback_exports);
|
|
4
23
|
function promiseOfCallback(fun) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
resolve(v);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
try {
|
|
26
|
+
fun((e, v) => {
|
|
27
|
+
if (e) {
|
|
28
|
+
reject(e);
|
|
29
|
+
} else {
|
|
30
|
+
resolve(v);
|
|
15
31
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
32
|
+
});
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
20
37
|
}
|
|
21
|
-
exports.promiseOfCallback = promiseOfCallback;
|
|
22
|
-
//# sourceMappingURL=promiseOfCallback.js.map
|
package/lib/cjs/asyncs/sleep.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var sleep_exports = {};
|
|
19
|
+
__export(sleep_exports, {
|
|
20
|
+
sleep: () => sleep
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(sleep_exports);
|
|
23
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var timeout_exports = {};
|
|
19
|
+
__export(timeout_exports, {
|
|
20
|
+
TimeoutError: () => TimeoutError,
|
|
21
|
+
timeout: () => timeout
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(timeout_exports);
|
|
5
24
|
function timeout(v, ms) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const error = new TimeoutError();
|
|
26
|
+
let timeout2;
|
|
27
|
+
return Promise.race([
|
|
28
|
+
v,
|
|
29
|
+
new Promise((_, reject) => {
|
|
30
|
+
timeout2 = setTimeout(() => reject(error), ms);
|
|
31
|
+
})
|
|
32
|
+
]).then((v2) => {
|
|
33
|
+
clearTimeout(timeout2);
|
|
34
|
+
return v2;
|
|
35
|
+
}, (e) => {
|
|
36
|
+
clearTimeout(timeout2);
|
|
37
|
+
throw e;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
class TimeoutError extends Error {
|
|
41
|
+
constructor() {
|
|
42
|
+
super("TimeoutError");
|
|
43
|
+
}
|
|
20
44
|
}
|
|
21
|
-
exports.timeout = timeout;
|
|
22
|
-
var TimeoutError = /** @class */ (function (_super) {
|
|
23
|
-
tslib_1.__extends(TimeoutError, _super);
|
|
24
|
-
function TimeoutError() {
|
|
25
|
-
return _super.call(this, 'TimeoutError') || this;
|
|
26
|
-
}
|
|
27
|
-
return TimeoutError;
|
|
28
|
-
}(Error));
|
|
29
|
-
exports.TimeoutError = TimeoutError;
|
|
30
|
-
//# sourceMappingURL=timeout.js.map
|