@onetokenfe/coinselect 3.1.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 (229) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/accumulative.js +38 -0
  4. package/blackjack.js +35 -0
  5. package/break.js +34 -0
  6. package/index.js +21 -0
  7. package/package.json +82 -0
  8. package/split.js +45 -0
  9. package/third-party/utils/addDashesToSpaces.d.ts +2 -0
  10. package/third-party/utils/addDashesToSpaces.js +6 -0
  11. package/third-party/utils/arrayDistinct.d.ts +2 -0
  12. package/third-party/utils/arrayDistinct.js +6 -0
  13. package/third-party/utils/arrayPartition.d.ts +7 -0
  14. package/third-party/utils/arrayPartition.js +6 -0
  15. package/third-party/utils/arrayShuffle.d.ts +4 -0
  16. package/third-party/utils/arrayShuffle.js +13 -0
  17. package/third-party/utils/arrayToDictionary.d.ts +10 -0
  18. package/third-party/utils/arrayToDictionary.js +27 -0
  19. package/third-party/utils/asciiUtils.d.ts +3 -0
  20. package/third-party/utils/asciiUtils.js +16 -0
  21. package/third-party/utils/bigNumber.d.ts +5 -0
  22. package/third-party/utils/bigNumber.js +9 -0
  23. package/third-party/utils/bufferUtils.d.ts +3 -0
  24. package/third-party/utils/bufferUtils.js +23 -0
  25. package/third-party/utils/bytesToHumanReadable.d.ts +2 -0
  26. package/third-party/utils/bytesToHumanReadable.js +15 -0
  27. package/third-party/utils/capitalizeFirstLetter.d.ts +2 -0
  28. package/third-party/utils/capitalizeFirstLetter.js +6 -0
  29. package/third-party/utils/cloneObject.d.ts +2 -0
  30. package/third-party/utils/cloneObject.js +32 -0
  31. package/third-party/utils/countBytesInString.d.ts +2 -0
  32. package/third-party/utils/countBytesInString.js +6 -0
  33. package/third-party/utils/createCooldown.d.ts +2 -0
  34. package/third-party/utils/createCooldown.js +16 -0
  35. package/third-party/utils/createDeferred.d.ts +14 -0
  36. package/third-party/utils/createDeferred.js +19 -0
  37. package/third-party/utils/createDeferredManager.d.ts +19 -0
  38. package/third-party/utils/createDeferredManager.js +67 -0
  39. package/third-party/utils/createLazy.d.ts +7 -0
  40. package/third-party/utils/createLazy.js +42 -0
  41. package/third-party/utils/createTimeoutPromise.d.ts +2 -0
  42. package/third-party/utils/createTimeoutPromise.js +6 -0
  43. package/third-party/utils/enumUtils.d.ts +6 -0
  44. package/third-party/utils/enumUtils.js +12 -0
  45. package/third-party/utils/extractUrlsFromText.d.ts +5 -0
  46. package/third-party/utils/extractUrlsFromText.js +28 -0
  47. package/third-party/utils/getLocaleSeparators.d.ts +5 -0
  48. package/third-party/utils/getLocaleSeparators.js +13 -0
  49. package/third-party/utils/getLocaleSeparators.native.d.ts +5 -0
  50. package/third-party/utils/getLocaleSeparators.native.js +17 -0
  51. package/third-party/utils/getMutex.d.ts +2 -0
  52. package/third-party/utils/getMutex.js +22 -0
  53. package/third-party/utils/getNumberFromPixelString.d.ts +2 -0
  54. package/third-party/utils/getNumberFromPixelString.js +6 -0
  55. package/third-party/utils/getRandomInt.d.ts +2 -0
  56. package/third-party/utils/getRandomInt.js +56 -0
  57. package/third-party/utils/getSynchronize.d.ts +4 -0
  58. package/third-party/utils/getSynchronize.js +10 -0
  59. package/third-party/utils/getWeakRandomId.d.ts +2 -0
  60. package/third-party/utils/getWeakRandomId.js +13 -0
  61. package/third-party/utils/getWeakRandomInt.d.ts +2 -0
  62. package/third-party/utils/getWeakRandomInt.js +11 -0
  63. package/third-party/utils/getWeakRandomNumberInRange.d.ts +2 -0
  64. package/third-party/utils/getWeakRandomNumberInRange.js +6 -0
  65. package/third-party/utils/hasUppercaseLetter.d.ts +2 -0
  66. package/third-party/utils/hasUppercaseLetter.js +7 -0
  67. package/third-party/utils/index.d.ts +52 -0
  68. package/third-party/utils/index.js +56 -0
  69. package/third-party/utils/isArrayMember.d.ts +2 -0
  70. package/third-party/utils/isArrayMember.js +6 -0
  71. package/third-party/utils/isFullPath.d.ts +2 -0
  72. package/third-party/utils/isFullPath.js +9 -0
  73. package/third-party/utils/isHex.d.ts +2 -0
  74. package/third-party/utils/isHex.js +9 -0
  75. package/third-party/utils/isNotUndefined.d.ts +2 -0
  76. package/third-party/utils/isNotUndefined.js +6 -0
  77. package/third-party/utils/isUrl.d.ts +2 -0
  78. package/third-party/utils/isUrl.js +7 -0
  79. package/third-party/utils/logs.d.ts +32 -0
  80. package/third-party/utils/logs.js +82 -0
  81. package/third-party/utils/logsManager.d.ts +17 -0
  82. package/third-party/utils/logsManager.js +53 -0
  83. package/third-party/utils/mergeDeepObject.d.ts +26 -0
  84. package/third-party/utils/mergeDeepObject.js +68 -0
  85. package/third-party/utils/objectPartition.d.ts +6 -0
  86. package/third-party/utils/objectPartition.js +12 -0
  87. package/third-party/utils/parseElectrumUrl.d.ts +6 -0
  88. package/third-party/utils/parseElectrumUrl.js +17 -0
  89. package/third-party/utils/parseHostname.d.ts +2 -0
  90. package/third-party/utils/parseHostname.js +7 -0
  91. package/third-party/utils/promiseAllSequence.d.ts +2 -0
  92. package/third-party/utils/promiseAllSequence.js +14 -0
  93. package/third-party/utils/redactUserPath.d.ts +3 -0
  94. package/third-party/utils/redactUserPath.js +7 -0
  95. package/third-party/utils/scheduleAction.d.ts +15 -0
  96. package/third-party/utils/scheduleAction.js +125 -0
  97. package/third-party/utils/splitStringEveryNCharacters.d.ts +2 -0
  98. package/third-party/utils/splitStringEveryNCharacters.js +12 -0
  99. package/third-party/utils/throttler.d.ts +11 -0
  100. package/third-party/utils/throttler.js +38 -0
  101. package/third-party/utils/throwError.d.ts +2 -0
  102. package/third-party/utils/throwError.js +8 -0
  103. package/third-party/utils/topologicalSort.d.ts +2 -0
  104. package/third-party/utils/topologicalSort.js +19 -0
  105. package/third-party/utils/truncateMiddle.d.ts +2 -0
  106. package/third-party/utils/truncateMiddle.js +12 -0
  107. package/third-party/utils/typedEventEmitter.d.ts +23 -0
  108. package/third-party/utils/typedEventEmitter.js +11 -0
  109. package/third-party/utils/urlToOnion.d.ts +4 -0
  110. package/third-party/utils/urlToOnion.js +12 -0
  111. package/third-party/utils/versionUtils.d.ts +9 -0
  112. package/third-party/utils/versionUtils.js +28 -0
  113. package/third-party/utils/xssFilters.d.ts +4 -0
  114. package/third-party/utils/xssFilters.js +13 -0
  115. package/third-party/utxo-lib/address.d.ts +17 -0
  116. package/third-party/utxo-lib/address.js +174 -0
  117. package/third-party/utxo-lib/bip32.d.ts +28 -0
  118. package/third-party/utxo-lib/bip32.js +253 -0
  119. package/third-party/utxo-lib/bs58check.d.ts +12 -0
  120. package/third-party/utxo-lib/bs58check.js +92 -0
  121. package/third-party/utxo-lib/bufferutils.d.ts +59 -0
  122. package/third-party/utxo-lib/bufferutils.js +219 -0
  123. package/third-party/utxo-lib/coinselect/coinselectUtils.d.ts +53 -0
  124. package/third-party/utxo-lib/coinselect/coinselectUtils.js +232 -0
  125. package/third-party/utxo-lib/coinselect/index.d.ts +3 -0
  126. package/third-party/utxo-lib/coinselect/index.js +19 -0
  127. package/third-party/utxo-lib/coinselect/inputs/accumulative.d.ts +3 -0
  128. package/third-party/utxo-lib/coinselect/inputs/accumulative.js +55 -0
  129. package/third-party/utxo-lib/coinselect/inputs/branchAndBound.d.ts +3 -0
  130. package/third-party/utxo-lib/coinselect/inputs/branchAndBound.js +123 -0
  131. package/third-party/utxo-lib/coinselect/outputs/split.d.ts +3 -0
  132. package/third-party/utxo-lib/coinselect/outputs/split.js +35 -0
  133. package/third-party/utxo-lib/coinselect/tryconfirmed.d.ts +3 -0
  134. package/third-party/utxo-lib/coinselect/tryconfirmed.js +65 -0
  135. package/third-party/utxo-lib/compose/index.d.ts +3 -0
  136. package/third-party/utxo-lib/compose/index.js +20 -0
  137. package/third-party/utxo-lib/compose/request.d.ts +5 -0
  138. package/third-party/utxo-lib/compose/request.js +168 -0
  139. package/third-party/utxo-lib/compose/result.d.ts +4 -0
  140. package/third-party/utxo-lib/compose/result.js +64 -0
  141. package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.d.ts +3 -0
  142. package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.js +32 -0
  143. package/third-party/utxo-lib/compose/sorting/convertOutput.d.ts +13 -0
  144. package/third-party/utxo-lib/compose/sorting/convertOutput.js +14 -0
  145. package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.d.ts +3 -0
  146. package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.js +19 -0
  147. package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.d.ts +3 -0
  148. package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.js +28 -0
  149. package/third-party/utxo-lib/compose/sorting/sortingStrategy.d.ts +9 -0
  150. package/third-party/utxo-lib/compose/sorting/sortingStrategy.js +3 -0
  151. package/third-party/utxo-lib/compose/transaction.d.ts +3 -0
  152. package/third-party/utxo-lib/compose/transaction.js +16 -0
  153. package/third-party/utxo-lib/crypto.d.ts +9 -0
  154. package/third-party/utxo-lib/crypto.js +44 -0
  155. package/third-party/utxo-lib/derivation.d.ts +24 -0
  156. package/third-party/utxo-lib/derivation.js +121 -0
  157. package/third-party/utxo-lib/discovery.d.ts +9 -0
  158. package/third-party/utxo-lib/discovery.js +30 -0
  159. package/third-party/utxo-lib/global.d.ts +62 -0
  160. package/third-party/utxo-lib/global.js +2 -0
  161. package/third-party/utxo-lib/index.d.ts +18 -0
  162. package/third-party/utxo-lib/index.js +28 -0
  163. package/third-party/utxo-lib/networks.d.ts +45 -0
  164. package/third-party/utxo-lib/networks.js +250 -0
  165. package/third-party/utxo-lib/payments/embed.d.ts +3 -0
  166. package/third-party/utxo-lib/payments/embed.js +49 -0
  167. package/third-party/utxo-lib/payments/index.d.ts +13 -0
  168. package/third-party/utxo-lib/payments/index.js +28 -0
  169. package/third-party/utxo-lib/payments/lazy.d.ts +3 -0
  170. package/third-party/utxo-lib/payments/lazy.js +33 -0
  171. package/third-party/utxo-lib/payments/p2ms.d.ts +3 -0
  172. package/third-party/utxo-lib/payments/p2ms.js +139 -0
  173. package/third-party/utxo-lib/payments/p2pk.d.ts +3 -0
  174. package/third-party/utxo-lib/payments/p2pk.js +72 -0
  175. package/third-party/utxo-lib/payments/p2pkh.d.ts +3 -0
  176. package/third-party/utxo-lib/payments/p2pkh.js +132 -0
  177. package/third-party/utxo-lib/payments/p2sh.d.ts +3 -0
  178. package/third-party/utxo-lib/payments/p2sh.js +171 -0
  179. package/third-party/utxo-lib/payments/p2tr.d.ts +3 -0
  180. package/third-party/utxo-lib/payments/p2tr.js +123 -0
  181. package/third-party/utxo-lib/payments/p2wpkh.d.ts +3 -0
  182. package/third-party/utxo-lib/payments/p2wpkh.js +137 -0
  183. package/third-party/utxo-lib/payments/p2wsh.d.ts +3 -0
  184. package/third-party/utxo-lib/payments/p2wsh.js +183 -0
  185. package/third-party/utxo-lib/payments/sstxchange.d.ts +3 -0
  186. package/third-party/utxo-lib/payments/sstxchange.js +79 -0
  187. package/third-party/utxo-lib/payments/sstxcommitment.d.ts +3 -0
  188. package/third-party/utxo-lib/payments/sstxcommitment.js +74 -0
  189. package/third-party/utxo-lib/payments/sstxpkh.d.ts +3 -0
  190. package/third-party/utxo-lib/payments/sstxpkh.js +79 -0
  191. package/third-party/utxo-lib/payments/sstxsh.d.ts +3 -0
  192. package/third-party/utxo-lib/payments/sstxsh.js +70 -0
  193. package/third-party/utxo-lib/script/index.d.ts +17 -0
  194. package/third-party/utxo-lib/script/index.js +167 -0
  195. package/third-party/utxo-lib/script/ops.d.ts +4 -0
  196. package/third-party/utxo-lib/script/ops.js +13 -0
  197. package/third-party/utxo-lib/script/scriptNumber.d.ts +3 -0
  198. package/third-party/utxo-lib/script/scriptNumber.js +62 -0
  199. package/third-party/utxo-lib/script/scriptSignature.d.ts +8 -0
  200. package/third-party/utxo-lib/script/scriptSignature.js +55 -0
  201. package/third-party/utxo-lib/transaction/base.d.ts +56 -0
  202. package/third-party/utxo-lib/transaction/base.js +108 -0
  203. package/third-party/utxo-lib/transaction/bitcoin.d.ts +4 -0
  204. package/third-party/utxo-lib/transaction/bitcoin.js +109 -0
  205. package/third-party/utxo-lib/transaction/dash.d.ts +8 -0
  206. package/third-party/utxo-lib/transaction/dash.js +105 -0
  207. package/third-party/utxo-lib/transaction/decred.d.ts +4 -0
  208. package/third-party/utxo-lib/transaction/decred.js +149 -0
  209. package/third-party/utxo-lib/transaction/index.d.ts +15 -0
  210. package/third-party/utxo-lib/transaction/index.js +44 -0
  211. package/third-party/utxo-lib/transaction/peercoin.d.ts +4 -0
  212. package/third-party/utxo-lib/transaction/peercoin.js +64 -0
  213. package/third-party/utxo-lib/transaction/zcash.d.ts +66 -0
  214. package/third-party/utxo-lib/transaction/zcash.js +451 -0
  215. package/third-party/utxo-lib/types/coinselect.d.ts +61 -0
  216. package/third-party/utxo-lib/types/coinselect.js +3 -0
  217. package/third-party/utxo-lib/types/compose.d.ts +98 -0
  218. package/third-party/utxo-lib/types/compose.js +10 -0
  219. package/third-party/utxo-lib/types/index.d.ts +5 -0
  220. package/third-party/utxo-lib/types/index.js +8 -0
  221. package/third-party/utxo-lib/types/payments.d.ts +30 -0
  222. package/third-party/utxo-lib/types/payments.js +3 -0
  223. package/third-party/utxo-lib/types/typeforce.d.ts +8 -0
  224. package/third-party/utxo-lib/types/typeforce.js +16 -0
  225. package/third-party/utxo-lib/vsize.d.ts +13 -0
  226. package/third-party/utxo-lib/vsize.js +50 -0
  227. package/utils.js +78 -0
  228. package/witness.d.ts +70 -0
  229. package/witness.js +30 -0
@@ -0,0 +1,14 @@
1
+ export interface Deferred<Resolve = void, Arg = string | number | undefined> {
2
+ id: Arg;
3
+ promise: Promise<Resolve>;
4
+ resolve: (t: Resolve) => void;
5
+ reject: (e: Error) => void;
6
+ }
7
+ export type DeferredResponse<D> = D extends Deferred<infer R> ? R : never;
8
+ interface CreateDeferred {
9
+ <Resolve = void, Arg = undefined>(id?: Arg): Deferred<Resolve, Arg>;
10
+ <Resolve = void, Arg = string | number>(id: Arg): Deferred<Resolve, Arg>;
11
+ }
12
+ export declare const createDeferred: CreateDeferred;
13
+ export {};
14
+ //# sourceMappingURL=createDeferred.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDeferred = void 0;
4
+ const createDeferred = (id) => {
5
+ let localResolve = () => { };
6
+ let localReject = () => { };
7
+ const promise = new Promise((resolve, reject) => {
8
+ localResolve = resolve;
9
+ localReject = reject;
10
+ });
11
+ return {
12
+ id,
13
+ resolve: localResolve,
14
+ reject: localReject,
15
+ promise,
16
+ };
17
+ };
18
+ exports.createDeferred = createDeferred;
19
+ //# sourceMappingURL=createDeferred.js.map
@@ -0,0 +1,19 @@
1
+ type DeferredManagerOptions = {
2
+ timeout?: number;
3
+ onTimeout?: (promiseId: number) => void;
4
+ initialId?: number;
5
+ };
6
+ export type DeferredManager<T> = {
7
+ length: () => number;
8
+ nextId: () => number;
9
+ create: (timeout?: number) => {
10
+ promiseId: number;
11
+ promise: Promise<T>;
12
+ };
13
+ resolve: (promiseId: number, value: T) => boolean;
14
+ reject: (promiseId: number, error: Error) => boolean;
15
+ rejectAll: (error: Error) => void;
16
+ };
17
+ export declare const createDeferredManager: <T = any>(options?: DeferredManagerOptions) => DeferredManager<T>;
18
+ export {};
19
+ //# sourceMappingURL=createDeferredManager.d.ts.map
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDeferredManager = void 0;
4
+ const createDeferred_1 = require("./createDeferred");
5
+ const createDeferredManager = (options) => {
6
+ const { initialId = 0, timeout: defaultTimeout = 0, onTimeout } = options !== null && options !== void 0 ? options : {};
7
+ const promises = [];
8
+ let ID = initialId;
9
+ let timeoutHandle;
10
+ const length = () => promises.length;
11
+ const nextId = () => ID;
12
+ const replanTimeout = () => {
13
+ const now = Date.now();
14
+ const nearestDeadline = promises.reduce((prev, { deadline }) => (prev && deadline ? Math.min : Math.max)(prev, deadline), 0);
15
+ if (timeoutHandle)
16
+ clearTimeout(timeoutHandle);
17
+ timeoutHandle = nearestDeadline
18
+ ?
19
+ setTimeout(timeoutCallback, Math.max(nearestDeadline - now, 0))
20
+ : undefined;
21
+ };
22
+ const timeoutCallback = () => {
23
+ const now = Date.now();
24
+ promises
25
+ .filter(promise => promise.deadline && promise.deadline <= now)
26
+ .forEach(promise => {
27
+ onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout(promise.id);
28
+ promise.deadline = 0;
29
+ });
30
+ replanTimeout();
31
+ };
32
+ const create = (timeout = defaultTimeout) => {
33
+ const promiseId = ID++;
34
+ const deferred = (0, createDeferred_1.createDeferred)(promiseId);
35
+ const deadline = timeout && Date.now() + timeout;
36
+ promises.push(Object.assign(Object.assign({}, deferred), { deadline }));
37
+ if (timeout)
38
+ replanTimeout();
39
+ return { promiseId, promise: deferred.promise };
40
+ };
41
+ const extract = (promiseId) => {
42
+ const index = promises.findIndex(({ id }) => id === promiseId);
43
+ const [promise] = index >= 0 ? promises.splice(index, 1) : [undefined];
44
+ if (promise === null || promise === void 0 ? void 0 : promise.deadline)
45
+ replanTimeout();
46
+ return promise;
47
+ };
48
+ const resolve = (promiseId, value) => {
49
+ const promise = extract(promiseId);
50
+ promise === null || promise === void 0 ? void 0 : promise.resolve(value);
51
+ return !!promise;
52
+ };
53
+ const reject = (promiseId, error) => {
54
+ const promise = extract(promiseId);
55
+ promise === null || promise === void 0 ? void 0 : promise.reject(error);
56
+ return !!promise;
57
+ };
58
+ const rejectAll = (error) => {
59
+ promises.forEach(promise => promise.reject(error));
60
+ const deleted = promises.splice(0, promises.length);
61
+ if (deleted.length)
62
+ replanTimeout();
63
+ };
64
+ return { length, nextId, create, resolve, reject, rejectAll };
65
+ };
66
+ exports.createDeferredManager = createDeferredManager;
67
+ //# sourceMappingURL=createDeferredManager.js.map
@@ -0,0 +1,7 @@
1
+ export declare const createLazy: <T, TArgs extends Array<any>>(initLazy: (...args: TArgs) => Promise<T>, disposeLazy?: (t: T) => void) => {
2
+ get: () => T | undefined;
3
+ getPending: () => Promise<T> | undefined;
4
+ getOrInit: (...args: TArgs) => Promise<T>;
5
+ dispose: () => void;
6
+ };
7
+ //# sourceMappingURL=createLazy.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLazy = void 0;
4
+ const createDeferred_1 = require("./createDeferred");
5
+ const createLazy = (initLazy, disposeLazy) => {
6
+ let value;
7
+ let valuePromise;
8
+ const get = () => value;
9
+ const getPending = () => valuePromise === null || valuePromise === void 0 ? void 0 : valuePromise.promise;
10
+ const dispose = () => {
11
+ if (valuePromise) {
12
+ valuePromise.reject(new Error('Disposed during initialization'));
13
+ valuePromise = undefined;
14
+ }
15
+ if (value !== undefined) {
16
+ disposeLazy === null || disposeLazy === void 0 ? void 0 : disposeLazy(value);
17
+ value = undefined;
18
+ }
19
+ };
20
+ const getOrInit = (...args) => {
21
+ if (value !== undefined)
22
+ return Promise.resolve(value);
23
+ if (!valuePromise) {
24
+ const deferred = (0, createDeferred_1.createDeferred)();
25
+ valuePromise = deferred;
26
+ initLazy(...args)
27
+ .then(val => {
28
+ value = val;
29
+ valuePromise = undefined;
30
+ deferred.resolve(val);
31
+ })
32
+ .catch(err => {
33
+ valuePromise = undefined;
34
+ deferred.reject(err);
35
+ });
36
+ }
37
+ return valuePromise.promise;
38
+ };
39
+ return { get, getPending, getOrInit, dispose };
40
+ };
41
+ exports.createLazy = createLazy;
42
+ //# sourceMappingURL=createLazy.js.map
@@ -0,0 +1,2 @@
1
+ export declare const createTimeoutPromise: (timeout: number) => Promise<unknown>;
2
+ //# sourceMappingURL=createTimeoutPromise.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTimeoutPromise = void 0;
4
+ const createTimeoutPromise = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
5
+ exports.createTimeoutPromise = createTimeoutPromise;
6
+ //# sourceMappingURL=createTimeoutPromise.js.map
@@ -0,0 +1,6 @@
1
+ type EnumValue = string | number;
2
+ type EnumObject = Record<string, EnumValue>;
3
+ export declare function getKeyByValue<E extends EnumObject>(obj: E, value: E[keyof E]): keyof E | undefined;
4
+ export declare function getValueByKey<E extends EnumObject>(obj: E, enumKey: keyof E): E[keyof E] | undefined;
5
+ export {};
6
+ //# sourceMappingURL=enumUtils.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getKeyByValue = getKeyByValue;
4
+ exports.getValueByKey = getValueByKey;
5
+ function getKeyByValue(obj, value) {
6
+ return obj && Object.keys(obj).find(x => obj[x] === value);
7
+ }
8
+ function getValueByKey(obj, enumKey) {
9
+ const key = obj && Object.keys(obj).find(x => x === enumKey);
10
+ return key && obj[key];
11
+ }
12
+ //# sourceMappingURL=enumUtils.js.map
@@ -0,0 +1,5 @@
1
+ export declare const extractUrlsFromText: (text: string) => {
2
+ textParts: string[];
3
+ urls: string[];
4
+ };
5
+ //# sourceMappingURL=extractUrlsFromText.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractUrlsFromText = void 0;
4
+ const URL_REGEX = /\b(?:https?:\/\/|www\.)[a-zA-Z0-9-._~:/?#[\]@!$&'()*+,;=%]+\b|(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(?=\b|\s|$|\])/gi;
5
+ const extractUrlsFromText = (text) => {
6
+ const urls = [];
7
+ const textParts = [];
8
+ let lastIndex = 0;
9
+ const matches = [...text.matchAll(URL_REGEX)];
10
+ matches.forEach(match => {
11
+ const url = match[0];
12
+ const index = match.index !== undefined ? match.index : -1;
13
+ if (lastIndex < index) {
14
+ textParts.push(text.slice(lastIndex, index));
15
+ }
16
+ urls.push(url);
17
+ lastIndex = index + url.length;
18
+ });
19
+ if (lastIndex < text.length) {
20
+ textParts.push(text.slice(lastIndex));
21
+ }
22
+ if (textParts.length === 0 && urls.length > 0) {
23
+ textParts.push('');
24
+ }
25
+ return { textParts, urls };
26
+ };
27
+ exports.extractUrlsFromText = extractUrlsFromText;
28
+ //# sourceMappingURL=extractUrlsFromText.js.map
@@ -0,0 +1,5 @@
1
+ export declare const getLocaleSeparators: (locale: string) => {
2
+ decimalSeparator: string;
3
+ thousandsSeparator: string;
4
+ };
5
+ //# sourceMappingURL=getLocaleSeparators.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLocaleSeparators = void 0;
4
+ const getLocaleSeparators = (locale) => {
5
+ var _a, _b;
6
+ const numberFormat = new Intl.NumberFormat(locale);
7
+ const parts = numberFormat.formatToParts(10000.1);
8
+ const decimalSeparator = (_a = parts.find(({ type }) => type === 'decimal')) === null || _a === void 0 ? void 0 : _a.value;
9
+ const thousandsSeparator = (_b = parts.find(({ type }) => type === 'group')) === null || _b === void 0 ? void 0 : _b.value;
10
+ return { decimalSeparator, thousandsSeparator };
11
+ };
12
+ exports.getLocaleSeparators = getLocaleSeparators;
13
+ //# sourceMappingURL=getLocaleSeparators.js.map
@@ -0,0 +1,5 @@
1
+ export declare function getLocaleSeparators(locale: string): {
2
+ decimalSeparator: string;
3
+ thousandsSeparator: string;
4
+ };
5
+ //# sourceMappingURL=getLocaleSeparators.native.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLocaleSeparators = getLocaleSeparators;
4
+ function getLocaleSeparators(locale) {
5
+ const formattedNumber = new Intl.NumberFormat(locale).format(1234567.89);
6
+ let thousandsSeparator = ' ';
7
+ let decimalSeparator = '.';
8
+ for (let i = 0; i < formattedNumber.length; i++) {
9
+ if (!/\d/.test(formattedNumber[i])) {
10
+ thousandsSeparator = formattedNumber[i];
11
+ break;
12
+ }
13
+ }
14
+ decimalSeparator = formattedNumber[formattedNumber.length - 3];
15
+ return { decimalSeparator, thousandsSeparator };
16
+ }
17
+ //# sourceMappingURL=getLocaleSeparators.native.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getMutex: () => (lockId?: keyof any) => Promise<() => void>;
2
+ //# sourceMappingURL=getMutex.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMutex = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const getMutex = () => {
6
+ const DEFAULT_ID = Symbol();
7
+ const locks = {};
8
+ return (...args_1) => tslib_1.__awaiter(void 0, [...args_1], void 0, function* (lockId = DEFAULT_ID) {
9
+ while (locks[lockId]) {
10
+ yield locks[lockId];
11
+ }
12
+ let resolve = () => { };
13
+ locks[lockId] = new Promise(res => {
14
+ resolve = res;
15
+ }).finally(() => {
16
+ delete locks[lockId];
17
+ });
18
+ return resolve;
19
+ });
20
+ };
21
+ exports.getMutex = getMutex;
22
+ //# sourceMappingURL=getMutex.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getNumberFromPixelString: (size: string) => number;
2
+ //# sourceMappingURL=getNumberFromPixelString.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNumberFromPixelString = void 0;
4
+ const getNumberFromPixelString = (size) => parseInt(size.replace('px', ''), 10);
5
+ exports.getNumberFromPixelString = getNumberFromPixelString;
6
+ //# sourceMappingURL=getNumberFromPixelString.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getRandomInt: (min: number, max: number) => number;
2
+ //# sourceMappingURL=getRandomInt.d.ts.map
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandomInt = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const getRandomInt = (min, max) => {
6
+ if (!Number.isSafeInteger(min)) {
7
+ throw new RangeError(`The "min" argument must be a safe integer. Received type ${typeof min} (${min})`);
8
+ }
9
+ if (!Number.isSafeInteger(max)) {
10
+ throw new RangeError(`The "max" argument must be a safe integer. Received type ${typeof max} (${max})`);
11
+ }
12
+ if (min >= max) {
13
+ throw new RangeError(`The value of "max" is out of range. It must be greater than the value of "min" (${min}). Received ${max}`);
14
+ }
15
+ const MAX_RANGE_32_BITS = 0xffffffff + 1;
16
+ const range = max - min;
17
+ if (range > MAX_RANGE_32_BITS) {
18
+ throw new RangeError(`This function only provide 32 bits of entropy, therefore range cannot be more then 2^32.`);
19
+ }
20
+ const getRandomValues = typeof window !== 'undefined'
21
+ ? (array) => {
22
+ try {
23
+ return window.crypto.getRandomValues(array);
24
+ } catch (e) {
25
+ console.error('Window crypto error:', e);
26
+ throw e;
27
+ }
28
+ }
29
+ : typeof self !== 'undefined'
30
+ ? (array) => {
31
+ try {
32
+ return self.crypto.getRandomValues(array);
33
+ } catch (e) {
34
+ console.error('Self crypto error:', e);
35
+ throw e;
36
+ }
37
+ }
38
+ : (array) => {
39
+ try {
40
+ return (0, crypto_1.getRandomValues)(array);
41
+ } catch (e) {
42
+ console.error('Node crypto error:', e);
43
+ throw e;
44
+ }
45
+ };
46
+ const array = new Uint32Array(1);
47
+ const maxRange = MAX_RANGE_32_BITS - (MAX_RANGE_32_BITS % range);
48
+ let randomValue;
49
+ do {
50
+ getRandomValues(array);
51
+ randomValue = array[0];
52
+ } while (randomValue >= maxRange);
53
+ return min + (randomValue % range);
54
+ };
55
+ exports.getRandomInt = getRandomInt;
56
+ //# sourceMappingURL=getRandomInt.js.map
@@ -0,0 +1,4 @@
1
+ import { getMutex } from './getMutex';
2
+ export declare const getSynchronize: (mutex?: ReturnType<typeof getMutex>) => <T>(action: () => T, lockId?: keyof any) => T extends Promise<unknown> ? T : Promise<T>;
3
+ export type Synchronize = ReturnType<typeof getSynchronize>;
4
+ //# sourceMappingURL=getSynchronize.d.ts.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSynchronize = void 0;
4
+ const getMutex_1 = require("./getMutex");
5
+ const getSynchronize = (mutex) => {
6
+ const lock = mutex !== null && mutex !== void 0 ? mutex : (0, getMutex_1.getMutex)();
7
+ return (action, lockId) => lock(lockId).then(unlock => Promise.resolve().then(action).finally(unlock));
8
+ };
9
+ exports.getSynchronize = getSynchronize;
10
+ //# sourceMappingURL=getSynchronize.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getWeakRandomId: (length: number) => string;
2
+ //# sourceMappingURL=getWeakRandomId.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWeakRandomId = void 0;
4
+ const getWeakRandomId = (length) => {
5
+ let id = '';
6
+ const list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
7
+ for (let i = 0; i < length; i++) {
8
+ id += list.charAt(Math.floor(Math.random() * list.length));
9
+ }
10
+ return id;
11
+ };
12
+ exports.getWeakRandomId = getWeakRandomId;
13
+ //# sourceMappingURL=getWeakRandomId.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getWeakRandomInt: (min: number, max: number) => number;
2
+ //# sourceMappingURL=getWeakRandomInt.d.ts.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWeakRandomInt = void 0;
4
+ const getWeakRandomInt = (min, max) => {
5
+ if (min >= max) {
6
+ throw new RangeError(`The value of "max" is out of range. It must be greater than the value of "min" (${min}). Received ${max}`);
7
+ }
8
+ return Math.floor(Math.random() * (max - min) + min);
9
+ };
10
+ exports.getWeakRandomInt = getWeakRandomInt;
11
+ //# sourceMappingURL=getWeakRandomInt.js.map
@@ -0,0 +1,2 @@
1
+ export declare const getWeakRandomNumberInRange: (min: number, max: number) => number;
2
+ //# sourceMappingURL=getWeakRandomNumberInRange.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWeakRandomNumberInRange = void 0;
4
+ const getWeakRandomNumberInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
5
+ exports.getWeakRandomNumberInRange = getWeakRandomNumberInRange;
6
+ //# sourceMappingURL=getWeakRandomNumberInRange.js.map
@@ -0,0 +1,2 @@
1
+ export declare const hasUppercaseLetter: (value: string) => boolean;
2
+ //# sourceMappingURL=hasUppercaseLetter.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasUppercaseLetter = void 0;
4
+ const HAS_UPPERCASE_LATER_REGEXP = new RegExp('^(.*[A-Z].*)$');
5
+ const hasUppercaseLetter = (value) => HAS_UPPERCASE_LATER_REGEXP.test(value);
6
+ exports.hasUppercaseLetter = hasUppercaseLetter;
7
+ //# sourceMappingURL=hasUppercaseLetter.js.map
@@ -0,0 +1,52 @@
1
+ export * as bufferUtils from './bufferUtils';
2
+ export * as enumUtils from './enumUtils';
3
+ export * as versionUtils from './versionUtils';
4
+ export * as xssFilters from './xssFilters';
5
+ export * from './addDashesToSpaces';
6
+ export * from './arrayDistinct';
7
+ export * from './arrayPartition';
8
+ export * from './arrayShuffle';
9
+ export * from './arrayToDictionary';
10
+ export * from './bytesToHumanReadable';
11
+ export * from './capitalizeFirstLetter';
12
+ export * from './cloneObject';
13
+ export * from './countBytesInString';
14
+ export * from './createCooldown';
15
+ export * from './createDeferred';
16
+ export * from './createDeferredManager';
17
+ export * from './createLazy';
18
+ export * from './createTimeoutPromise';
19
+ export * from './getLocaleSeparators';
20
+ export * from './getMutex';
21
+ export * from './getNumberFromPixelString';
22
+ export * from './getWeakRandomNumberInRange';
23
+ export * from './getSynchronize';
24
+ export * from './getRandomInt';
25
+ export * from './getWeakRandomId';
26
+ export * from './getWeakRandomInt';
27
+ export * from './hasUppercaseLetter';
28
+ export * from './isArrayMember';
29
+ export * from './isHex';
30
+ export * from './isNotUndefined';
31
+ export * from './isUrl';
32
+ export * from './mergeDeepObject';
33
+ export * from './objectPartition';
34
+ export * from './parseElectrumUrl';
35
+ export * from './parseHostname';
36
+ export * from './promiseAllSequence';
37
+ export * from './redactUserPath';
38
+ export * from './scheduleAction';
39
+ export * from './splitStringEveryNCharacters';
40
+ export * from './throwError';
41
+ export * from './topologicalSort';
42
+ export * from './truncateMiddle';
43
+ export * from './typedEventEmitter';
44
+ export * from './urlToOnion';
45
+ export * from './logs';
46
+ export * from './logsManager';
47
+ export * from './bigNumber';
48
+ export * from './throttler';
49
+ export * from './extractUrlsFromText';
50
+ export * from './isFullPath';
51
+ export * from './asciiUtils';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xssFilters = exports.versionUtils = exports.enumUtils = exports.bufferUtils = void 0;
4
+ const tslib_1 = require("tslib");
5
+ exports.bufferUtils = tslib_1.__importStar(require("./bufferUtils"));
6
+ exports.enumUtils = tslib_1.__importStar(require("./enumUtils"));
7
+ exports.versionUtils = tslib_1.__importStar(require("./versionUtils"));
8
+ exports.xssFilters = tslib_1.__importStar(require("./xssFilters"));
9
+ tslib_1.__exportStar(require("./addDashesToSpaces"), exports);
10
+ tslib_1.__exportStar(require("./arrayDistinct"), exports);
11
+ tslib_1.__exportStar(require("./arrayPartition"), exports);
12
+ tslib_1.__exportStar(require("./arrayShuffle"), exports);
13
+ tslib_1.__exportStar(require("./arrayToDictionary"), exports);
14
+ tslib_1.__exportStar(require("./bytesToHumanReadable"), exports);
15
+ tslib_1.__exportStar(require("./capitalizeFirstLetter"), exports);
16
+ tslib_1.__exportStar(require("./cloneObject"), exports);
17
+ tslib_1.__exportStar(require("./countBytesInString"), exports);
18
+ tslib_1.__exportStar(require("./createCooldown"), exports);
19
+ tslib_1.__exportStar(require("./createDeferred"), exports);
20
+ tslib_1.__exportStar(require("./createDeferredManager"), exports);
21
+ tslib_1.__exportStar(require("./createLazy"), exports);
22
+ tslib_1.__exportStar(require("./createTimeoutPromise"), exports);
23
+ tslib_1.__exportStar(require("./getLocaleSeparators"), exports);
24
+ tslib_1.__exportStar(require("./getMutex"), exports);
25
+ tslib_1.__exportStar(require("./getNumberFromPixelString"), exports);
26
+ tslib_1.__exportStar(require("./getWeakRandomNumberInRange"), exports);
27
+ tslib_1.__exportStar(require("./getSynchronize"), exports);
28
+ tslib_1.__exportStar(require("./getRandomInt"), exports);
29
+ tslib_1.__exportStar(require("./getWeakRandomId"), exports);
30
+ tslib_1.__exportStar(require("./getWeakRandomInt"), exports);
31
+ tslib_1.__exportStar(require("./hasUppercaseLetter"), exports);
32
+ tslib_1.__exportStar(require("./isArrayMember"), exports);
33
+ tslib_1.__exportStar(require("./isHex"), exports);
34
+ tslib_1.__exportStar(require("./isNotUndefined"), exports);
35
+ tslib_1.__exportStar(require("./isUrl"), exports);
36
+ tslib_1.__exportStar(require("./mergeDeepObject"), exports);
37
+ tslib_1.__exportStar(require("./objectPartition"), exports);
38
+ tslib_1.__exportStar(require("./parseElectrumUrl"), exports);
39
+ tslib_1.__exportStar(require("./parseHostname"), exports);
40
+ tslib_1.__exportStar(require("./promiseAllSequence"), exports);
41
+ tslib_1.__exportStar(require("./redactUserPath"), exports);
42
+ tslib_1.__exportStar(require("./scheduleAction"), exports);
43
+ tslib_1.__exportStar(require("./splitStringEveryNCharacters"), exports);
44
+ tslib_1.__exportStar(require("./throwError"), exports);
45
+ tslib_1.__exportStar(require("./topologicalSort"), exports);
46
+ tslib_1.__exportStar(require("./truncateMiddle"), exports);
47
+ tslib_1.__exportStar(require("./typedEventEmitter"), exports);
48
+ tslib_1.__exportStar(require("./urlToOnion"), exports);
49
+ tslib_1.__exportStar(require("./logs"), exports);
50
+ tslib_1.__exportStar(require("./logsManager"), exports);
51
+ tslib_1.__exportStar(require("./bigNumber"), exports);
52
+ tslib_1.__exportStar(require("./throttler"), exports);
53
+ tslib_1.__exportStar(require("./extractUrlsFromText"), exports);
54
+ tslib_1.__exportStar(require("./isFullPath"), exports);
55
+ tslib_1.__exportStar(require("./asciiUtils"), exports);
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare const isArrayMember: <Value extends string, Subset extends Value>(value: Value, arr: readonly Subset[]) => value is Subset;
2
+ //# sourceMappingURL=isArrayMember.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArrayMember = void 0;
4
+ const isArrayMember = (value, arr) => arr.some(v => v === value);
5
+ exports.isArrayMember = isArrayMember;
6
+ //# sourceMappingURL=isArrayMember.js.map
@@ -0,0 +1,2 @@
1
+ export declare const isFullPath: (path: string) => boolean;
2
+ //# sourceMappingURL=isFullPath.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFullPath = void 0;
4
+ const isFullPath = (path) => {
5
+ const fullPathPattern = /^(\/|([a-zA-Z]:\\))/;
6
+ return fullPathPattern.test(path);
7
+ };
8
+ exports.isFullPath = isFullPath;
9
+ //# sourceMappingURL=isFullPath.js.map
@@ -0,0 +1,2 @@
1
+ export declare const isHex: (str: string) => boolean;
2
+ //# sourceMappingURL=isHex.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHex = void 0;
4
+ const isHex = (str) => {
5
+ const regExp = /^(0x|0X)?[0-9A-Fa-f]+$/g;
6
+ return regExp.test(str);
7
+ };
8
+ exports.isHex = isHex;
9
+ //# sourceMappingURL=isHex.js.map
@@ -0,0 +1,2 @@
1
+ export declare const isNotUndefined: <T>(item?: T) => item is T;
2
+ //# sourceMappingURL=isNotUndefined.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNotUndefined = void 0;
4
+ const isNotUndefined = (item) => typeof item !== 'undefined';
5
+ exports.isNotUndefined = isNotUndefined;
6
+ //# sourceMappingURL=isNotUndefined.js.map
@@ -0,0 +1,2 @@
1
+ export declare const isUrl: (value: string) => boolean;
2
+ //# sourceMappingURL=isUrl.d.ts.map