@yume-chan/struct 0.0.13 → 0.0.16

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.
Files changed (69) hide show
  1. package/CHANGELOG.json +33 -0
  2. package/CHANGELOG.md +21 -1
  3. package/LICENSE +21 -21
  4. package/README.md +767 -769
  5. package/esm/basic/definition.d.ts +3 -3
  6. package/esm/basic/definition.d.ts.map +1 -1
  7. package/esm/basic/definition.js +0 -1
  8. package/esm/basic/definition.js.map +1 -1
  9. package/esm/basic/field-value.d.ts +1 -0
  10. package/esm/basic/field-value.d.ts.map +1 -1
  11. package/esm/basic/field-value.js +4 -0
  12. package/esm/basic/field-value.js.map +1 -1
  13. package/esm/basic/stream.d.ts +2 -1
  14. package/esm/basic/stream.d.ts.map +1 -1
  15. package/esm/basic/struct-value.d.ts +7 -5
  16. package/esm/basic/struct-value.d.ts.map +1 -1
  17. package/esm/basic/struct-value.js +30 -14
  18. package/esm/basic/struct-value.js.map +1 -1
  19. package/esm/struct.d.ts +11 -11
  20. package/esm/struct.d.ts.map +1 -1
  21. package/esm/struct.js +55 -41
  22. package/esm/struct.js.map +1 -1
  23. package/esm/sync-promise.d.ts +13 -0
  24. package/esm/sync-promise.d.ts.map +1 -0
  25. package/esm/sync-promise.js +71 -0
  26. package/esm/sync-promise.js.map +1 -0
  27. package/esm/types/bigint.d.ts.map +1 -1
  28. package/esm/types/bigint.js +7 -5
  29. package/esm/types/bigint.js.map +1 -1
  30. package/esm/types/buffer/base.d.ts +4 -3
  31. package/esm/types/buffer/base.d.ts.map +1 -1
  32. package/esm/types/buffer/base.js +9 -7
  33. package/esm/types/buffer/base.js.map +1 -1
  34. package/esm/types/buffer/fixed-length.d.ts +1 -1
  35. package/esm/types/buffer/fixed-length.d.ts.map +1 -1
  36. package/esm/types/buffer/fixed-length.js.map +1 -1
  37. package/esm/types/buffer/variable-length.d.ts +2 -2
  38. package/esm/types/buffer/variable-length.d.ts.map +1 -1
  39. package/esm/types/buffer/variable-length.js.map +1 -1
  40. package/esm/types/number.d.ts +6 -5
  41. package/esm/types/number.d.ts.map +1 -1
  42. package/esm/types/number.js +25 -14
  43. package/esm/types/number.js.map +1 -1
  44. package/package.json +11 -11
  45. package/src/basic/definition.ts +68 -70
  46. package/src/basic/field-value.ts +72 -67
  47. package/src/basic/index.ts +5 -5
  48. package/src/basic/options.ts +19 -19
  49. package/src/basic/stream.ts +21 -19
  50. package/src/basic/struct-value.ts +61 -39
  51. package/src/index.ts +17 -17
  52. package/src/struct.ts +632 -609
  53. package/src/sync-promise.ts +114 -0
  54. package/src/types/bigint.ts +103 -102
  55. package/src/types/buffer/base.ts +179 -176
  56. package/src/types/buffer/fixed-length.ts +20 -17
  57. package/src/types/buffer/index.ts +3 -3
  58. package/src/types/buffer/variable-length.ts +158 -156
  59. package/src/types/index.ts +3 -3
  60. package/src/types/number.ts +127 -115
  61. package/src/utils.ts +70 -70
  62. package/tsconfig.build.json +3 -0
  63. package/tsconfig.build.tsbuildinfo +1 -0
  64. package/tsconfig.test.json +8 -0
  65. package/esm/syncbird.d.ts +0 -65
  66. package/esm/syncbird.d.ts.map +0 -1
  67. package/esm/syncbird.js +0 -38
  68. package/esm/syncbird.js.map +0 -1
  69. package/src/syncbird.ts +0 -131
package/src/utils.ts CHANGED
@@ -1,70 +1,70 @@
1
- /**
2
- * When evaluating a very complex generic type alias,
3
- * tell TypeScript to use `T`, instead of current type alias' name, as the result type name
4
- *
5
- * Example:
6
- *
7
- * ```ts
8
- * type WithIdentity<T> = Identity<SomeType<T>>;
9
- * type WithoutIdentity<T> = SomeType<T>;
10
- *
11
- * type WithIdentityResult = WithIdentity<number>;
12
- * // Hover on this one shows `SomeType<number>`
13
- *
14
- * type WithoutIdentityResult = WithoutIdentity<number>;
15
- * // Hover on this one shows `WithoutIdentity<number>`
16
- * ```
17
- */
18
- export type Identity<T> = T;
19
-
20
- /**
21
- * Collapse an intersection type (`{ foo: string } & { bar: number }`) to a simple type (`{ foo: string, bar: number }`)
22
- */
23
- export type Evaluate<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
24
-
25
- /**
26
- * Overwrite fields in `TBase` with fields in `TNew`
27
- */
28
- export type Overwrite<TBase extends object, TNew extends object> =
29
- Evaluate<Omit<TBase, keyof TNew> & TNew>;
30
-
31
- /**
32
- * Remove fields with `never` type
33
- */
34
- export type OmitNever<T> = Pick<T, { [K in keyof T]: [T[K]] extends [never] ? never : K }[keyof T]>;
35
-
36
- /**
37
- * Extract keys of fields in `T` that has type `TValue`
38
- */
39
- export type KeysOfType<T, TValue> =
40
- { [TKey in keyof T]: T[TKey] extends TValue ? TKey : never }[keyof T];
41
-
42
- export type ValueOrPromise<T> = T | PromiseLike<T>;
43
-
44
- /**
45
- * Returns a (fake) value of the given type.
46
- */
47
- export function placeholder<T>(): T {
48
- return undefined as unknown as T;
49
- }
50
-
51
- // This library can't use `@types/node` or `lib: dom`
52
- // because they will pollute the global scope
53
- // So `TextEncoder` and `TextDecoder` are not available
54
-
55
- // Node.js 8.3 ships `TextEncoder` and `TextDecoder` in `util` module.
56
- // But using top level await to load them requires Node.js 14.1.
57
- // So there is no point to do that. Let's just assume they exist in global.
58
-
59
- // @ts-expect-error
60
- const Utf8Encoder = new TextEncoder();
61
- // @ts-expect-error
62
- const Utf8Decoder = new TextDecoder();
63
-
64
- export function encodeUtf8(input: string): Uint8Array {
65
- return Utf8Encoder.encode(input);
66
- }
67
-
68
- export function decodeUtf8(buffer: ArrayBufferView | ArrayBuffer): string {
69
- return Utf8Decoder.decode(buffer);
70
- }
1
+ /**
2
+ * When evaluating a very complex generic type alias,
3
+ * tell TypeScript to use `T`, instead of current type alias' name, as the result type name
4
+ *
5
+ * Example:
6
+ *
7
+ * ```ts
8
+ * type WithIdentity<T> = Identity<SomeType<T>>;
9
+ * type WithoutIdentity<T> = SomeType<T>;
10
+ *
11
+ * type WithIdentityResult = WithIdentity<number>;
12
+ * // Hover on this one shows `SomeType<number>`
13
+ *
14
+ * type WithoutIdentityResult = WithoutIdentity<number>;
15
+ * // Hover on this one shows `WithoutIdentity<number>`
16
+ * ```
17
+ */
18
+ export type Identity<T> = T;
19
+
20
+ /**
21
+ * Collapse an intersection type (`{ foo: string } & { bar: number }`) to a simple type (`{ foo: string, bar: number }`)
22
+ */
23
+ export type Evaluate<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
24
+
25
+ /**
26
+ * Overwrite fields in `TBase` with fields in `TNew`
27
+ */
28
+ export type Overwrite<TBase extends object, TNew extends object> =
29
+ Evaluate<Omit<TBase, keyof TNew> & TNew>;
30
+
31
+ /**
32
+ * Remove fields with `never` type
33
+ */
34
+ export type OmitNever<T> = Pick<T, { [K in keyof T]: [T[K]] extends [never] ? never : K }[keyof T]>;
35
+
36
+ /**
37
+ * Extract keys of fields in `T` that has type `TValue`
38
+ */
39
+ export type KeysOfType<T, TValue> =
40
+ { [TKey in keyof T]: T[TKey] extends TValue ? TKey : never }[keyof T];
41
+
42
+ export type ValueOrPromise<T> = T | PromiseLike<T>;
43
+
44
+ /**
45
+ * Returns a (fake) value of the given type.
46
+ */
47
+ export function placeholder<T>(): T {
48
+ return undefined as unknown as T;
49
+ }
50
+
51
+ // This library can't use `@types/node` or `lib: dom`
52
+ // because they will pollute the global scope
53
+ // So `TextEncoder` and `TextDecoder` are not available
54
+
55
+ // Node.js 8.3 ships `TextEncoder` and `TextDecoder` in `util` module.
56
+ // But using top level await to load them requires Node.js 14.1.
57
+ // So there is no point to do that. Let's just assume they exist in global.
58
+
59
+ // @ts-expect-error
60
+ const Utf8Encoder = new TextEncoder();
61
+ // @ts-expect-error
62
+ const Utf8Decoder = new TextDecoder();
63
+
64
+ export function encodeUtf8(input: string): Uint8Array {
65
+ return Utf8Encoder.encode(input);
66
+ }
67
+
68
+ export function decodeUtf8(buffer: ArrayBufferView | ArrayBuffer): string {
69
+ return Utf8Decoder.decode(buffer);
70
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json"
3
+ }
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es5.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2016.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2019.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2021.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.esnext.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.7.2/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.4.0/node_modules/tslib/tslib.d.ts","./src/utils.ts","./src/basic/stream.ts","./src/basic/options.ts","./src/basic/struct-value.ts","./src/basic/field-value.ts","./src/basic/definition.ts","./src/basic/index.ts","./src/sync-promise.ts","../dataview-bigint-polyfill/esm/fallback.d.ts","./src/types/bigint.ts","./src/types/buffer/base.ts","./src/types/buffer/fixed-length.ts","./src/types/buffer/variable-length.ts","./src/types/buffer/index.ts","./src/types/number.ts","./src/types/index.ts","./src/struct.ts","./src/index.ts"],"fileInfos":[{"version":"f5c28122bee592cfaf5c72ed7bcc47f453b79778ffa6e301f45d21a0970719d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","impliedFormat":1},{"version":"7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","impliedFormat":1},{"version":"8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","impliedFormat":1},{"version":"5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","impliedFormat":1},{"version":"e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","impliedFormat":1},{"version":"1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","impliedFormat":1},{"version":"746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","impliedFormat":1},{"version":"3eb679a56cab01203a1ba7edeade937f6a2a4c718513b2cd930b579807fa9359","impliedFormat":1},{"version":"aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c","impliedFormat":1},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true,"impliedFormat":1},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true,"impliedFormat":1},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true,"impliedFormat":1},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true,"impliedFormat":1},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true,"impliedFormat":1},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true,"impliedFormat":1},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true,"impliedFormat":1},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true,"impliedFormat":1},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true,"impliedFormat":1},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true,"impliedFormat":1},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true,"impliedFormat":1},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true,"impliedFormat":1},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true,"impliedFormat":1},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true,"impliedFormat":1},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true,"impliedFormat":1},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true,"impliedFormat":1},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true,"impliedFormat":1},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true,"impliedFormat":1},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true,"impliedFormat":1},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true,"impliedFormat":1},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true,"impliedFormat":1},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true,"impliedFormat":1},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true,"impliedFormat":1},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true,"impliedFormat":1},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true,"impliedFormat":1},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd483c056da900716879771893a3c9772b66c3c88f8943b4205aec738a94b1d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true,"impliedFormat":1},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true,"impliedFormat":1},{"version":"ff667ee99e5a28c3dc5063a3cfd4d3436699e3fb035d4451037da7f567da542a","affectsGlobalScope":true,"impliedFormat":1},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true,"impliedFormat":1},{"version":"6ea9ab679ea030cf46c16a711a316078e9e02619ebaf07a7fcd16964aba88f2d","affectsGlobalScope":true,"impliedFormat":1},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true,"impliedFormat":1},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true,"impliedFormat":1},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true,"impliedFormat":1},{"version":"c37f8a49593a0030eecb51bbfa270e709bec9d79a6cc3bb851ef348d4e6b26f8","affectsGlobalScope":true,"impliedFormat":1},{"version":"14a84fbe4ec531dcbaf5d2594fd95df107258e60ae6c6a076404f13c3f66f28e","impliedFormat":1},{"version":"84ae1da8fdb0a3c1a41fc3a1322855ffe63ced25d6b7a7626c7edb2e489bc926","signature":"9a367dbb975a485bc8f9f1aaf6dba2cd760657b167deff50e804989dda198521","impliedFormat":99},{"version":"e615f41563708716a7dd4d98ac243acf546039d8172c300182b2edda94c5893f","signature":"b6e1d6be772cfd1f39b0fda2c5c93fbe01a226b23fa730926ed2d41db265680c","impliedFormat":99},{"version":"6827c0ba1bb152cd1a57c960babfdbfbd9bb8d6f2eff37c7b3567df511f707ac","signature":"40dd8fe07897a8ccb48ef6c2c1edfb352578cff37a6f9214771c581bdead4cc3","impliedFormat":99},{"version":"96f12f5af15656fbf0675cc429d7b6d58c8136d875f220519e5862e3f85400b1","signature":"1ecaa5a622c5692b35d88f170c636176c1951da34a2a7044f06ebf7d3cb74b64","impliedFormat":99},{"version":"67329a7bd86dbf2a1923ed2a130c176b412ba510589e2a33140b55b2651393d6","signature":"9a4ba630486c74e44ae747605622601d833afe65ccfff926640d9833245014ad","impliedFormat":99},{"version":"c2540ffc3cae06077ae60702e518e55e73534d11071f6483c650635d55239125","signature":"dd3bdf2b338a202726b240df8fcd9b169c4079072e7b9366e2a8ea62ef3226f5","impliedFormat":99},{"version":"fc2e47bddc5026267c39730648cbaa21105facf3731d044da086b0689ebb8b98","signature":"e838e92ee2b6d439178edac035a6661a136d2424d48927833752bfa151ff954f","impliedFormat":99},{"version":"0c27b21d435149d1eff5204b60df9be67d36be7520382fd4454712d47d5d0eba","signature":"dbff4204e72de7f717ea4165e39cf1c53a62568e2ff3df4d33d64fc01388d444","impliedFormat":99},{"version":"ea9a35cd9e4fc405c1e35f2ab6d2219205cc1d0a99338af5d462472ebcfbd855","impliedFormat":99},{"version":"814079c4435096c2a85d4e0fb9dbb556ad83210674afb9cbee82ab3a11d3fe85","signature":"d6e68df6272a5709eeae6be6fbd3aeb8078ffec2de47aab5c480402c09b65392","impliedFormat":99},{"version":"c8b32bb1a0e858b6852442e716c67e17a4d9d68d221a5aedb03d7151c0d43a00","signature":"6e59c001bc2ae860ce79d5abc859e8c9d60a4eb78bdfc13afad0a29cfdc1f3ce","impliedFormat":99},{"version":"6eee7b7361bffc8813c25534135f1bc6c0e59e6a19f8480a651026c4f9f6573f","signature":"01dcb3b2c75958a86a3c7edb7e36264dfb4c0283efe3379f8b88394d108c0fba","impliedFormat":99},{"version":"6eaf751d5cf1ec30941d84d75c58ee4cf74a231e6c39d91273ebd1363aa92c94","signature":"22474d3439161edb74e5e264bbddbeb0fd22721d02f779868d05aa6ae5ab8d12","impliedFormat":99},{"version":"5ea1325a998e722fffc89ff8c2d00eaf35e491f3fada16fb56c6360f63d16d79","signature":"02ca393ed379c3ac738e90a5be95e148ebf23aab5271b6a9df3c5626939b59f7","impliedFormat":99},{"version":"040db99c956e4a5c27c028d5e498f5ca650f66fcde2a122efcdef8f1b6baeb5e","signature":"88df10c66dd34f022467ea4ad515cf672942f328ee4d8d254a3c1021116ec1df","impliedFormat":99},{"version":"e24d67437856c921a9a40f7fbac38ac576439e6616eb698fb769279ecbc7802a","signature":"832c9c8fdcdcdc2f87d22997be7ab5d2a585fbc2d65e18deff0d19e5f1d91f7c","impliedFormat":99},{"version":"0c8b0b66a86100a320e49d3089a3536536d3972ed2a6f5299bae4c2661143c3a","signature":"ec337f65c1402596667f406cf4b26760aaf38863e8941675eff2a4950b027c2a","impliedFormat":99},{"version":"5aa8aa37aaa4023f13a2b0a9bbd17a93b4a14bd10034db59ff0c74a22311279b","signature":"34a143ee98281f548a93d76812182e6bd28efde9e79494e771d28149f852c709","affectsGlobalScope":true,"impliedFormat":99}],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"importHelpers":true,"importsNotUsedAsValues":2,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"outDir":"./esm","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":9},"fileIdsList":[[53,55,56,57,58],[53,56,57,59],[53,55,56,57,58,59],[53],[53,54],[53,58],[53,54,60,69,70],[53,54,60,61,69],[53,54,60,61,62],[53,54,60,61],[53,64],[53,64,65,66],[53,54,60,64],[53,63,67,68],[55,56,57,58],[56,57,59],[55,56,57,58,59],[54],[58],[54,60,69,70],[54,60,69],[60],[64],[64,65,66],[54,60,64],[63,67,68]],"referencedMap":[[59,1],[58,2],[60,3],[56,4],[55,5],[57,6],[71,7],[70,8],[61,4],[63,9],[64,10],[65,11],[67,12],[66,13],[69,14],[68,10],[54,4]],"exportedModulesMap":[[59,15],[58,16],[60,17],[55,18],[57,19],[71,20],[70,21],[63,22],[64,22],[65,23],[67,24],[66,25],[69,26],[68,22]],"semanticDiagnosticsPerFile":[53,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,36,41,42,37,38,39,40,8,46,43,44,45,47,9,48,49,50,51,1,10,52,62,59,58,60,56,55,57,71,70,61,63,64,65,67,66,69,68,54]},"version":"4.7.2"}
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "types": [
5
+ ],
6
+ },
7
+ "exclude": []
8
+ }
package/esm/syncbird.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import Bluebird from 'bluebird';
2
- export declare type Resolvable<R> = R | PromiseLike<R>;
3
- export declare type IterateFunction<T, R> = (item: T, index: number, arrayLength: number) => Resolvable<R>;
4
- export interface Syncbird<R> extends Bluebird<R> {
5
- valueOrPromise(): R | PromiseLike<R>;
6
- then<U>(onFulfill?: (value: R) => Resolvable<U>, onReject?: (error: any) => Resolvable<U>): Syncbird<U>;
7
- then<TResult1 = R, TResult2 = never>(onfulfilled?: ((value: R) => Resolvable<TResult1>) | null, onrejected?: ((reason: any) => Resolvable<TResult2>) | null): Syncbird<TResult1 | TResult2>;
8
- }
9
- interface SyncbirdStatic {
10
- /**
11
- * Iterate over an array, or a promise of an array,
12
- * which contains promises (or a mix of promises and values) with the given iterator function with the signature `(item, index, value)`
13
- * where item is the resolved value of a respective promise in the input array.
14
- * Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
15
- *
16
- * Resolves to the original array unmodified, this method is meant to be used for side effects.
17
- * If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
18
- */
19
- each<R>(values: Resolvable<Iterable<Resolvable<R>>>, iterator: IterateFunction<R, any>): Syncbird<R[]>;
20
- /**
21
- * Reduce an array, or a promise of an array,
22
- * which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)`
23
- * where `item` is the resolved value of a respective promise in the input array.
24
- * If any promise in the input array is rejected the returned promise is rejected as well.
25
- *
26
- * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
27
- *
28
- * *The original array is not modified. If no `initialValue` is given and the array doesn't contain at least 2 items,
29
- * the callback will not be called and `undefined` is returned.
30
- *
31
- * If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
32
- */
33
- reduce<R, U>(values: Resolvable<Iterable<Resolvable<R>>>, reducer: (total: U, current: R, index: number, arrayLength: number) => Resolvable<U>, initialValue?: U): Syncbird<U>;
34
- /**
35
- * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
36
- */
37
- resolve(): Syncbird<void>;
38
- resolve<R>(value: Resolvable<R>): Syncbird<R>;
39
- try<R>(fn: () => Resolvable<R>): Syncbird<R>;
40
- attempt<R>(fn: () => Resolvable<R>): Syncbird<R>;
41
- /**
42
- * Configure long stack traces, warnings, monitoring and cancellation.
43
- * Note that even though false is the default here, a development environment might be detected which automatically
44
- * enables long stack traces and warnings.
45
- */
46
- config(options: {
47
- /** Enable warnings */
48
- warnings?: boolean | {
49
- /** Enables all warnings except forgotten return statements. */
50
- wForgottenReturn: boolean;
51
- } | undefined;
52
- /** Enable long stack traces */
53
- longStackTraces?: boolean | undefined;
54
- /** Enable cancellation */
55
- cancellation?: boolean | undefined;
56
- /** Enable monitoring */
57
- monitoring?: boolean | undefined;
58
- /** Enable async hooks */
59
- asyncHooks?: boolean | undefined;
60
- }): void;
61
- new <R>(callback: (resolve: (thenableOrResult?: Resolvable<R>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Syncbird<R>;
62
- }
63
- export declare const Syncbird: SyncbirdStatic;
64
- export {};
65
- //# sourceMappingURL=syncbird.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncbird.d.ts","sourceRoot":"","sources":["../src/syncbird.ts"],"names":[],"mappings":"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"}
package/esm/syncbird.js DELETED
@@ -1,38 +0,0 @@
1
- // cspell: ignore syncbird
2
- import Bluebird from 'bluebird';
3
- export const Syncbird = Bluebird.getNewLibraryCopy();
4
- Syncbird.config({
5
- asyncHooks: false,
6
- cancellation: false,
7
- longStackTraces: false,
8
- monitoring: false,
9
- warnings: false,
10
- });
11
- // Bluebird uses `_then` internally.
12
- const _then = Syncbird.prototype._then;
13
- Syncbird.prototype._then = function (onfulfilled, onrejected, _, receiver, internalData) {
14
- if (this.isFulfilled()) {
15
- if (!onfulfilled) {
16
- return this;
17
- }
18
- else {
19
- // Synchronously call `onfulfilled`, and wrap the result in a new `Syncbird` object.
20
- return Syncbird.resolve(onfulfilled.call(receiver, this.value(),
21
- // Some Bluebird internal methods (for example `reduce`) need this `internalData`
22
- internalData));
23
- }
24
- }
25
- else {
26
- // Forward to Bluebird's `_then` method.
27
- return _then.call(this, onfulfilled, onrejected, _, receiver, internalData);
28
- }
29
- };
30
- Syncbird.prototype.valueOrPromise = function () {
31
- if (this.isFulfilled()) {
32
- return this.value();
33
- }
34
- else {
35
- return this;
36
- }
37
- };
38
- //# sourceMappingURL=syncbird.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncbird.js","sourceRoot":"","sources":["../src/syncbird.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAkFhC,MAAM,CAAC,MAAM,QAAQ,GAAmB,QAAQ,CAAC,iBAAiB,EAAS,CAAC;AAE5E,QAAQ,CAAC,MAAM,CAAC;IACZ,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAClB,CAAC,CAAC;AAEH,oCAAoC;AACpC,MAAM,KAAK,GAAI,QAAQ,CAAC,SAAiB,CAAC,KAAK,CAAC;AAChD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,UAEvB,WAA+E,EAC/E,UAAyD,EACzD,CAAQ,EACR,QAAiB,EACjB,YAAqB;IAErB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;QACpB,IAAI,CAAC,WAAW,EAAE;YACd,OAAO,IAAI,CAAC;SACf;aAAM;YACH,oFAAoF;YACpF,OAAO,QAAQ,CAAC,OAAO,CACnB,WAAW,CAAC,IAAI,CACZ,QAAQ,EACR,IAAI,CAAC,KAAK,EAAE;YACZ,iFAAiF;YACjF,YAAY,CACf,CACJ,CAAC;SACL;KACJ;SAAM;QACH,wCAAwC;QACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;KAC/E;AACL,CAAC,CAAC;AAED,QAAQ,CAAC,SAAiB,CAAC,cAAc,GAAG;IACzC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;QACpB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;KACvB;SAAM;QACH,OAAO,IAAkB,CAAC;KAC7B;AACL,CAAC,CAAC"}
package/src/syncbird.ts DELETED
@@ -1,131 +0,0 @@
1
- // cspell: ignore syncbird
2
-
3
- import Bluebird from 'bluebird';
4
-
5
- export type Resolvable<R> = R | PromiseLike<R>;
6
- export type IterateFunction<T, R> = (item: T, index: number, arrayLength: number) => Resolvable<R>;
7
-
8
- export interface Syncbird<R> extends Bluebird<R> {
9
- valueOrPromise(): R | PromiseLike<R>;
10
-
11
- then<U>(onFulfill?: (value: R) => Resolvable<U>, onReject?: (error: any) => Resolvable<U>): Syncbird<U>; // For simpler signature help.
12
- then<TResult1 = R, TResult2 = never>(
13
- onfulfilled?: ((value: R) => Resolvable<TResult1>) | null,
14
- onrejected?: ((reason: any) => Resolvable<TResult2>) | null
15
- ): Syncbird<TResult1 | TResult2>;
16
- }
17
-
18
- interface SyncbirdStatic {
19
- /**
20
- * Iterate over an array, or a promise of an array,
21
- * which contains promises (or a mix of promises and values) with the given iterator function with the signature `(item, index, value)`
22
- * where item is the resolved value of a respective promise in the input array.
23
- * Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
24
- *
25
- * Resolves to the original array unmodified, this method is meant to be used for side effects.
26
- * If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
27
- */
28
- each<R>(
29
- values: Resolvable<Iterable<Resolvable<R>>>,
30
- iterator: IterateFunction<R, any>
31
- ): Syncbird<R[]>;
32
-
33
- /**
34
- * Reduce an array, or a promise of an array,
35
- * which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)`
36
- * where `item` is the resolved value of a respective promise in the input array.
37
- * If any promise in the input array is rejected the returned promise is rejected as well.
38
- *
39
- * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
40
- *
41
- * *The original array is not modified. If no `initialValue` is given and the array doesn't contain at least 2 items,
42
- * the callback will not be called and `undefined` is returned.
43
- *
44
- * If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
45
- */
46
- reduce<R, U>(
47
- values: Resolvable<Iterable<Resolvable<R>>>,
48
- reducer: (total: U, current: R, index: number, arrayLength: number) => Resolvable<U>,
49
- initialValue?: U
50
- ): Syncbird<U>;
51
-
52
- /**
53
- * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
54
- */
55
- resolve(): Syncbird<void>;
56
- resolve<R>(value: Resolvable<R>): Syncbird<R>;
57
-
58
- try<R>(fn: () => Resolvable<R>): Syncbird<R>;
59
- attempt<R>(fn: () => Resolvable<R>): Syncbird<R>;
60
-
61
- /**
62
- * Configure long stack traces, warnings, monitoring and cancellation.
63
- * Note that even though false is the default here, a development environment might be detected which automatically
64
- * enables long stack traces and warnings.
65
- */
66
- config(options: {
67
- /** Enable warnings */
68
- warnings?: boolean | {
69
- /** Enables all warnings except forgotten return statements. */
70
- wForgottenReturn: boolean;
71
- } | undefined;
72
- /** Enable long stack traces */
73
- longStackTraces?: boolean | undefined;
74
- /** Enable cancellation */
75
- cancellation?: boolean | undefined;
76
- /** Enable monitoring */
77
- monitoring?: boolean | undefined;
78
- /** Enable async hooks */
79
- asyncHooks?: boolean | undefined;
80
- }): void;
81
-
82
- new <R>(callback: (resolve: (thenableOrResult?: Resolvable<R>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Syncbird<R>;
83
- }
84
-
85
- export const Syncbird: SyncbirdStatic = Bluebird.getNewLibraryCopy() as any;
86
-
87
- Syncbird.config({
88
- asyncHooks: false,
89
- cancellation: false,
90
- longStackTraces: false,
91
- monitoring: false,
92
- warnings: false,
93
- });
94
-
95
- // Bluebird uses `_then` internally.
96
- const _then = (Syncbird.prototype as any)._then;
97
- Syncbird.prototype._then = function <T, TResult1 = T, TResult2 = never>(
98
- this: Syncbird<T>,
99
- onfulfilled: ((value: T, internalData?: unknown) => unknown) | undefined | null,
100
- onrejected: ((reason: any) => unknown) | undefined | null,
101
- _: never,
102
- receiver: unknown,
103
- internalData: unknown,
104
- ): Syncbird<unknown> {
105
- if (this.isFulfilled()) {
106
- if (!onfulfilled) {
107
- return this;
108
- } else {
109
- // Synchronously call `onfulfilled`, and wrap the result in a new `Syncbird` object.
110
- return Syncbird.resolve(
111
- onfulfilled.call(
112
- receiver,
113
- this.value(),
114
- // Some Bluebird internal methods (for example `reduce`) need this `internalData`
115
- internalData
116
- )
117
- );
118
- }
119
- } else {
120
- // Forward to Bluebird's `_then` method.
121
- return _then.call(this, onfulfilled, onrejected, _, receiver, internalData);
122
- }
123
- };
124
-
125
- (Syncbird.prototype as any).valueOrPromise = function <T>(this: Bluebird<T>): T | PromiseLike<T> {
126
- if (this.isFulfilled()) {
127
- return this.value();
128
- } else {
129
- return this as Promise<T>;
130
- }
131
- };