@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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUrl = void 0;
4
+ const URL_REGEXP = /^(http|ws)s?:\/\/[a-z0-9]([a-z0-9.-]+)?(:[0-9]{1,5})?((\/)?(([a-z0-9-_])+(\/)?)+)$/i;
5
+ const isUrl = (value) => URL_REGEXP.test(value);
6
+ exports.isUrl = isUrl;
7
+ //# sourceMappingURL=isUrl.js.map
@@ -0,0 +1,32 @@
1
+ export type LogMessage = {
2
+ level: string;
3
+ prefix: string;
4
+ message: any[];
5
+ timestamp: number;
6
+ };
7
+ export type LogWriter = {
8
+ add: (message: LogMessage) => void;
9
+ };
10
+ export declare class Log {
11
+ prefix: string;
12
+ enabled: boolean;
13
+ css: string;
14
+ messages: LogMessage[];
15
+ logWriter: LogWriter | undefined;
16
+ MAX_ENTRIES: number;
17
+ constructor(prefix: string, enabled: boolean, logWriter?: LogWriter);
18
+ setColors(colors: Record<string, string>): void;
19
+ addMessage({ level, prefix, timestamp }: {
20
+ level: string;
21
+ prefix: string;
22
+ timestamp?: number;
23
+ }, ...args: any[]): void;
24
+ setWriter(logWriter: any): void;
25
+ log(...args: any[]): void;
26
+ error(...args: any[]): void;
27
+ info(...args: any[]): void;
28
+ warn(...args: any[]): void;
29
+ debug(...args: any[]): void;
30
+ getLog(): LogMessage[];
31
+ }
32
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Log = void 0;
4
+ class Log {
5
+ constructor(prefix, enabled, logWriter) {
6
+ this.css = '';
7
+ this.MAX_ENTRIES = 100;
8
+ this.prefix = prefix;
9
+ this.enabled = enabled;
10
+ this.messages = [];
11
+ if (logWriter) {
12
+ this.logWriter = logWriter;
13
+ }
14
+ }
15
+ setColors(colors) {
16
+ this.css = typeof window !== 'undefined' && colors[this.prefix] ? colors[this.prefix] : '';
17
+ }
18
+ addMessage({ level, prefix, timestamp }, ...args) {
19
+ const message = {
20
+ level,
21
+ prefix,
22
+ css: this.css,
23
+ message: args,
24
+ timestamp: timestamp || Date.now(),
25
+ };
26
+ this.messages.push(message);
27
+ if (this.logWriter) {
28
+ try {
29
+ this.logWriter.add(message);
30
+ }
31
+ catch (err) {
32
+ console.error('There was an error adding log message', err, message);
33
+ }
34
+ }
35
+ if (this.messages.length > this.MAX_ENTRIES) {
36
+ this.messages.shift();
37
+ }
38
+ }
39
+ setWriter(logWriter) {
40
+ this.logWriter = logWriter;
41
+ }
42
+ log(...args) {
43
+ this.addMessage({ level: 'log', prefix: this.prefix }, ...args);
44
+ if (this.enabled) {
45
+ console.log(`%c${this.prefix}`, this.css, ...args);
46
+ }
47
+ }
48
+ error(...args) {
49
+ this.addMessage({ level: 'error', prefix: this.prefix }, ...args);
50
+ if (this.enabled) {
51
+ console.error(`%c${this.prefix}`, this.css, ...args);
52
+ }
53
+ }
54
+ info(...args) {
55
+ this.addMessage({ level: 'info', prefix: this.prefix }, ...args);
56
+ if (this.enabled) {
57
+ console.info(`%c${this.prefix}`, this.css, ...args);
58
+ }
59
+ }
60
+ warn(...args) {
61
+ this.addMessage({ level: 'warn', prefix: this.prefix }, ...args);
62
+ if (this.enabled) {
63
+ console.warn(`%c${this.prefix}`, this.css, ...args);
64
+ }
65
+ }
66
+ debug(...args) {
67
+ this.addMessage({ level: 'debug', prefix: this.prefix }, ...args);
68
+ if (this.enabled) {
69
+ if (this.css) {
70
+ console.log(`%c${this.prefix}`, this.css, ...args);
71
+ }
72
+ else {
73
+ console.log(this.prefix, ...args);
74
+ }
75
+ }
76
+ }
77
+ getLog() {
78
+ return this.messages;
79
+ }
80
+ }
81
+ exports.Log = Log;
82
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1,17 @@
1
+ import { LogWriter, Log, LogMessage } from './logs';
2
+ export declare class LogsManager {
3
+ logs: {
4
+ [k: string]: Log;
5
+ };
6
+ writer: LogWriter | undefined;
7
+ colors?: Record<string, string>;
8
+ constructor({ colors }: {
9
+ colors?: Record<string, string>;
10
+ });
11
+ initLog(prefix: string, enabled?: boolean, logWriter?: LogWriter): Log;
12
+ setLogWriter(logWriterFactory: () => LogWriter | undefined): void;
13
+ enableLog(enabled?: boolean): void;
14
+ enableLogByPrefix(prefix: string, enabled: boolean): void;
15
+ getLog(): LogMessage[];
16
+ }
17
+ //# sourceMappingURL=logsManager.d.ts.map
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogsManager = void 0;
4
+ const logs_1 = require("./logs");
5
+ class LogsManager {
6
+ constructor({ colors }) {
7
+ this.logs = {};
8
+ this.colors = {};
9
+ this.colors = colors;
10
+ }
11
+ initLog(prefix, enabled, logWriter) {
12
+ const instanceWriter = logWriter || this.writer;
13
+ const instance = new logs_1.Log(prefix, !!enabled, instanceWriter);
14
+ if (this.colors) {
15
+ instance.setColors(this.colors);
16
+ }
17
+ this.logs[prefix] = instance;
18
+ return instance;
19
+ }
20
+ setLogWriter(logWriterFactory) {
21
+ Object.keys(this.logs).forEach(key => {
22
+ this.writer = logWriterFactory();
23
+ if (this.writer) {
24
+ this.logs[key].setWriter(this.writer);
25
+ const { messages } = this.logs[key];
26
+ messages.forEach(message => {
27
+ var _a;
28
+ (_a = this.writer) === null || _a === void 0 ? void 0 : _a.add(message);
29
+ });
30
+ }
31
+ });
32
+ }
33
+ enableLog(enabled) {
34
+ Object.keys(this.logs).forEach(key => {
35
+ this.logs[key].enabled = !!enabled;
36
+ });
37
+ }
38
+ enableLogByPrefix(prefix, enabled) {
39
+ if (this.logs[prefix]) {
40
+ this.logs[prefix].enabled = enabled;
41
+ }
42
+ }
43
+ getLog() {
44
+ let logs = [];
45
+ Object.keys(this.logs).forEach(key => {
46
+ logs = logs.concat(this.logs[key].messages);
47
+ });
48
+ logs.sort((a, b) => a.timestamp - b.timestamp);
49
+ return logs;
50
+ }
51
+ }
52
+ exports.LogsManager = LogsManager;
53
+ //# sourceMappingURL=logsManager.js.map
@@ -0,0 +1,26 @@
1
+ type TAllKeys<T> = T extends any ? keyof T : never;
2
+ type TIndexValue<T, K extends PropertyKey, D = never> = T extends any ? K extends keyof T ? T[K] : D : never;
3
+ type TPartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> extends infer O ? {
4
+ [P in keyof O]: O[P];
5
+ } : never;
6
+ type TFunction = (...a: any[]) => any;
7
+ type TPrimitives = string | number | boolean | bigint | symbol | Date | TFunction;
8
+ type TMerged<T> = [T] extends [Array<any>] ? {
9
+ [K in keyof T]: TMerged<T[K]>;
10
+ } : [T] extends [TPrimitives] ? T : [T] extends [object] ? TPartialKeys<{
11
+ [K in TAllKeys<T>]: TMerged<TIndexValue<T, K>>;
12
+ }, never> : T;
13
+ interface IObject {
14
+ [key: string]: any;
15
+ }
16
+ export declare const mergeDeepObject: {
17
+ <T extends IObject[]>(...objects: T): TMerged<T[number]>;
18
+ options: IOptions;
19
+ withOptions<T extends IObject[]>(options: Partial<IOptions>, ...objects: T): TMerged<T[number]>;
20
+ };
21
+ interface IOptions {
22
+ mergeArrays: boolean;
23
+ dotNotation: boolean;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=mergeDeepObject.d.ts.map
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeDeepObject = void 0;
4
+ const isObject = (obj) => {
5
+ if (typeof obj === 'object' && obj !== null) {
6
+ if (typeof Object.getPrototypeOf === 'function') {
7
+ const prototype = Object.getPrototypeOf(obj);
8
+ return prototype === Object.prototype || prototype === null;
9
+ }
10
+ return Object.prototype.toString.call(obj) === '[object Object]';
11
+ }
12
+ return false;
13
+ };
14
+ const mergeValuesWithPath = (target, value, [key, ...rest]) => {
15
+ if (key === undefined) {
16
+ return mergeValues(target, value);
17
+ }
18
+ else if (!isObject(target)) {
19
+ return { [key]: mergeValuesWithPath({}, value, rest) };
20
+ }
21
+ else {
22
+ return Object.assign(Object.assign({}, target), { [key]: mergeValuesWithPath(target[key], value, rest) });
23
+ }
24
+ };
25
+ const mergeValues = (target, value) => {
26
+ if (Array.isArray(target) && Array.isArray(value)) {
27
+ return exports.mergeDeepObject.options.mergeArrays
28
+ ? Array.from(new Set(target.concat(value)))
29
+ : value;
30
+ }
31
+ else if (isObject(target) && isObject(value)) {
32
+ return (0, exports.mergeDeepObject)(target, value);
33
+ }
34
+ else {
35
+ return value;
36
+ }
37
+ };
38
+ const mergeDeepObject = (...objects) => objects.reduce((result, current) => {
39
+ if (Array.isArray(current)) {
40
+ throw new TypeError('Arguments provided to ts-deepmerge must be objects, not arrays.');
41
+ }
42
+ Object.keys(current).forEach(key => {
43
+ if (['__proto__', 'constructor', 'prototype'].includes(key)) {
44
+ return;
45
+ }
46
+ if (exports.mergeDeepObject.options.dotNotation) {
47
+ const [first, ...rest] = key.split('.');
48
+ result[first] = mergeValuesWithPath(result[first], current[key], rest);
49
+ }
50
+ else {
51
+ result[key] = mergeValues(result[key], current[key]);
52
+ }
53
+ });
54
+ return result;
55
+ }, {});
56
+ exports.mergeDeepObject = mergeDeepObject;
57
+ const defaultOptions = {
58
+ mergeArrays: true,
59
+ dotNotation: false,
60
+ };
61
+ exports.mergeDeepObject.options = defaultOptions;
62
+ exports.mergeDeepObject.withOptions = (options, ...objects) => {
63
+ exports.mergeDeepObject.options = Object.assign(Object.assign({}, defaultOptions), options);
64
+ const result = (0, exports.mergeDeepObject)(...objects);
65
+ exports.mergeDeepObject.options = defaultOptions;
66
+ return result;
67
+ };
68
+ //# sourceMappingURL=mergeDeepObject.js.map
@@ -0,0 +1,6 @@
1
+ type Obj<T> = {
2
+ [key: string]: T;
3
+ };
4
+ export declare const objectPartition: <T>(obj: Obj<T>, keys: string[]) => [Obj<T>, Obj<T>];
5
+ export {};
6
+ //# sourceMappingURL=objectPartition.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectPartition = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const objectPartition = (obj, keys) => keys.reduce(([included, excluded], key) => {
6
+ const _a = excluded, _b = key, value = _a[_b], rest = tslib_1.__rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
7
+ return typeof value !== 'undefined'
8
+ ? [Object.assign(Object.assign({}, included), { [key]: value }), rest]
9
+ : [included, excluded];
10
+ }, [{}, obj]);
11
+ exports.objectPartition = objectPartition;
12
+ //# sourceMappingURL=objectPartition.js.map
@@ -0,0 +1,6 @@
1
+ export declare const parseElectrumUrl: (url: string) => {
2
+ host: string;
3
+ port: number;
4
+ protocol: "t" | "s";
5
+ } | undefined;
6
+ //# sourceMappingURL=parseElectrumUrl.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseElectrumUrl = void 0;
4
+ const ELECTRUM_URL_REGEX = /^(?:([a-zA-Z0-9.-]+)|\[([a-f0-9:]+)\]):([0-9]{1,5}):([ts])$/;
5
+ const parseElectrumUrl = (url) => {
6
+ var _a;
7
+ const match = url.match(ELECTRUM_URL_REGEX);
8
+ if (!match)
9
+ return undefined;
10
+ return {
11
+ host: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2],
12
+ port: Number.parseInt(match[3], 10),
13
+ protocol: match[4],
14
+ };
15
+ };
16
+ exports.parseElectrumUrl = parseElectrumUrl;
17
+ //# sourceMappingURL=parseElectrumUrl.js.map
@@ -0,0 +1,2 @@
1
+ export declare const parseHostname: (url: string) => string | undefined;
2
+ //# sourceMappingURL=parseHostname.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseHostname = void 0;
4
+ const HOSTNAME_REGEX = /^([a-z0-9.+-]+:\/\/)?([a-z0-9.-]+)([:/][^:/]+)*\/?$/i;
5
+ const parseHostname = (url) => { var _a, _b; return (_b = (_a = url.match(HOSTNAME_REGEX)) === null || _a === void 0 ? void 0 : _a[2]) === null || _b === void 0 ? void 0 : _b.toLowerCase(); };
6
+ exports.parseHostname = parseHostname;
7
+ //# sourceMappingURL=parseHostname.js.map
@@ -0,0 +1,2 @@
1
+ export declare const promiseAllSequence: <Fn extends () => PromiseLike<any>, R = Awaited<ReturnType<Fn>>>(actions: Fn[]) => Promise<R[]>;
2
+ //# sourceMappingURL=promiseAllSequence.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promiseAllSequence = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const promiseAllSequence = (actions) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
6
+ const results = [];
7
+ for (let i = 0; i < actions.length; ++i) {
8
+ const result = yield actions[i]();
9
+ results.push(result);
10
+ }
11
+ return results;
12
+ });
13
+ exports.promiseAllSequence = promiseAllSequence;
14
+ //# sourceMappingURL=promiseAllSequence.js.map
@@ -0,0 +1,3 @@
1
+ export declare const startOfUserPathRegex: RegExp;
2
+ export declare const redactUserPathFromString: (text: string) => string;
3
+ //# sourceMappingURL=redactUserPath.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.redactUserPathFromString = exports.startOfUserPathRegex = void 0;
4
+ exports.startOfUserPathRegex = /([/\\][Uu]sers[/\\]{1,4})([^"^'^[^\]^/^\\]*)/g;
5
+ const redactUserPathFromString = (text) => text.replace(exports.startOfUserPathRegex, '$1[*]');
6
+ exports.redactUserPathFromString = redactUserPathFromString;
7
+ //# sourceMappingURL=redactUserPath.js.map
@@ -0,0 +1,15 @@
1
+ export type ScheduledAction<T> = (signal?: AbortSignal) => Promise<T>;
2
+ type AttemptParams = {
3
+ timeout?: number;
4
+ gap?: number;
5
+ };
6
+ export type ScheduleActionParams = {
7
+ delay?: number;
8
+ deadline?: number;
9
+ attempts?: number | readonly AttemptParams[];
10
+ signal?: AbortSignal;
11
+ attemptFailureHandler?: (error: Error) => Error | void;
12
+ } & AttemptParams;
13
+ export declare const scheduleAction: <T>(action: ScheduledAction<T>, params: ScheduleActionParams) => Promise<T>;
14
+ export {};
15
+ //# sourceMappingURL=scheduleAction.d.ts.map
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scheduleAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const isArray = (attempts) => Array.isArray(attempts);
6
+ const abortedBySignal = () => new Error('Aborted by signal');
7
+ const abortedByDeadline = () => new Error('Aborted by deadline');
8
+ const abortedByTimeout = () => new Error('Aborted by timeout');
9
+ const resolveAfterMs = (ms, clear) => new Promise((resolve, reject) => {
10
+ if (clear.aborted)
11
+ return reject();
12
+ if (ms === undefined)
13
+ return resolve();
14
+ let timeout;
15
+ const onClear = () => {
16
+ clearTimeout(timeout);
17
+ clear.removeEventListener('abort', onClear);
18
+ reject();
19
+ };
20
+ timeout = setTimeout(() => {
21
+ clear.removeEventListener('abort', onClear);
22
+ resolve();
23
+ }, ms);
24
+ clear.addEventListener('abort', onClear);
25
+ });
26
+ const rejectAfterMs = (ms, reason, clear) => new Promise((_, reject) => {
27
+ if (clear.aborted)
28
+ return reject();
29
+ let timeout;
30
+ const onClear = () => {
31
+ clearTimeout(timeout);
32
+ clear.removeEventListener('abort', onClear);
33
+ reject();
34
+ };
35
+ timeout = setTimeout(() => {
36
+ clear.removeEventListener('abort', onClear);
37
+ reject(reason());
38
+ }, ms);
39
+ clear.addEventListener('abort', onClear);
40
+ });
41
+ const maybeRejectAfterMs = (ms, reason, clear) => ms === undefined ? [] : [rejectAfterMs(ms, reason, clear)];
42
+ const rejectWhenAborted = (signal, clear) => new Promise((_, reject) => {
43
+ if (clear.aborted)
44
+ return reject();
45
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted)
46
+ return reject(abortedBySignal());
47
+ const onAbort = () => reject(abortedBySignal());
48
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', onAbort);
49
+ const onClear = () => {
50
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', onAbort);
51
+ clear.removeEventListener('abort', onClear);
52
+ reject();
53
+ };
54
+ clear.addEventListener('abort', onClear);
55
+ });
56
+ const resolveAction = (action, clear) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ const aborter = new AbortController();
58
+ if (clear.aborted)
59
+ aborter.abort();
60
+ const onClear = () => {
61
+ clear.removeEventListener('abort', onClear);
62
+ aborter.abort();
63
+ };
64
+ clear.addEventListener('abort', onClear);
65
+ try {
66
+ return yield new Promise(resolve => resolve(action(aborter.signal)));
67
+ }
68
+ finally {
69
+ if (!clear.aborted)
70
+ clear.removeEventListener('abort', onClear);
71
+ }
72
+ });
73
+ const attemptLoop = (attempts, attempt, failure, clear) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
74
+ for (let a = 0; a < attempts - 1; a++) {
75
+ if (clear.aborted)
76
+ break;
77
+ const aborter = new AbortController();
78
+ const onClear = () => aborter.abort();
79
+ clear.addEventListener('abort', onClear);
80
+ try {
81
+ return yield attempt(a, aborter.signal);
82
+ }
83
+ catch (error) {
84
+ onClear();
85
+ yield failure(a, error);
86
+ }
87
+ finally {
88
+ clear.removeEventListener('abort', onClear);
89
+ }
90
+ }
91
+ return clear.aborted ? Promise.reject() : attempt(attempts - 1, clear);
92
+ });
93
+ const scheduleAction = (action, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
94
+ const { signal, delay, attempts, timeout, deadline, gap, attemptFailureHandler } = params;
95
+ const deadlineMs = deadline && deadline - Date.now();
96
+ const attemptCount = isArray(attempts)
97
+ ? attempts.length
98
+ : attempts !== null && attempts !== void 0 ? attempts : (deadline ? Infinity : 1);
99
+ const clearAborter = new AbortController();
100
+ const clear = clearAborter.signal;
101
+ const getParams = isArray(attempts)
102
+ ? (attempt) => attempts[attempt]
103
+ : () => ({ timeout, gap });
104
+ try {
105
+ return yield Promise.race([
106
+ rejectWhenAborted(signal, clear),
107
+ ...maybeRejectAfterMs(deadlineMs, abortedByDeadline, clear),
108
+ resolveAfterMs(delay, clear).then(() => attemptLoop(attemptCount, (attempt, abort) => Promise.race([
109
+ ...maybeRejectAfterMs(getParams(attempt).timeout, abortedByTimeout, clear),
110
+ resolveAction(action, abort),
111
+ ]), (attempt, error) => {
112
+ var _a;
113
+ const errorHandlerResult = attemptFailureHandler === null || attemptFailureHandler === void 0 ? void 0 : attemptFailureHandler(error);
114
+ return errorHandlerResult
115
+ ? Promise.reject(errorHandlerResult)
116
+ : resolveAfterMs((_a = getParams(attempt).gap) !== null && _a !== void 0 ? _a : 0, clear);
117
+ }, clear)),
118
+ ]);
119
+ }
120
+ finally {
121
+ clearAborter.abort();
122
+ }
123
+ });
124
+ exports.scheduleAction = scheduleAction;
125
+ //# sourceMappingURL=scheduleAction.js.map
@@ -0,0 +1,2 @@
1
+ export declare function splitStringEveryNCharacters(value: string, n: number): string[];
2
+ //# sourceMappingURL=splitStringEveryNCharacters.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitStringEveryNCharacters = splitStringEveryNCharacters;
4
+ function splitStringEveryNCharacters(value, n) {
5
+ var _a;
6
+ if (n === 0) {
7
+ return [];
8
+ }
9
+ const regex = new RegExp(`.{1,${n}}`, 'g');
10
+ return (_a = value.match(regex)) !== null && _a !== void 0 ? _a : [];
11
+ }
12
+ //# sourceMappingURL=splitStringEveryNCharacters.js.map
@@ -0,0 +1,11 @@
1
+ export declare class Throttler {
2
+ private readonly delay;
3
+ private readonly intervals;
4
+ private readonly callbacks;
5
+ constructor(delay: number);
6
+ throttle(id: string, callback: () => void): void;
7
+ private tick;
8
+ cancel(id: string): void;
9
+ dispose(): void;
10
+ }
11
+ //# sourceMappingURL=throttler.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Throttler = void 0;
4
+ class Throttler {
5
+ constructor(delay) {
6
+ this.delay = delay;
7
+ this.intervals = {};
8
+ this.callbacks = {};
9
+ }
10
+ throttle(id, callback) {
11
+ if (this.intervals[id]) {
12
+ this.callbacks[id] = callback;
13
+ }
14
+ else {
15
+ callback();
16
+ this.intervals[id] = setInterval(() => this.tick(id), this.delay);
17
+ }
18
+ }
19
+ tick(id) {
20
+ if (this.callbacks[id]) {
21
+ this.callbacks[id]();
22
+ delete this.callbacks[id];
23
+ }
24
+ else {
25
+ this.cancel(id);
26
+ }
27
+ }
28
+ cancel(id) {
29
+ clearInterval(this.intervals[id]);
30
+ delete this.intervals[id];
31
+ delete this.callbacks[id];
32
+ }
33
+ dispose() {
34
+ Object.keys(this.intervals).forEach(this.cancel, this);
35
+ }
36
+ }
37
+ exports.Throttler = Throttler;
38
+ //# sourceMappingURL=throttler.js.map
@@ -0,0 +1,2 @@
1
+ export declare const throwError: (reason: string) => never;
2
+ //# sourceMappingURL=throwError.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwError = void 0;
4
+ const throwError = (reason) => {
5
+ throw new Error(reason);
6
+ };
7
+ exports.throwError = throwError;
8
+ //# sourceMappingURL=throwError.js.map
@@ -0,0 +1,2 @@
1
+ export declare const topologicalSort: <T>(elements: T[], precedes: (pred: T, succ: T) => boolean, tie?: (a: T, b: T) => number) => T[];
2
+ //# sourceMappingURL=topologicalSort.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.topologicalSort = void 0;
4
+ const arrayPartition_1 = require("./arrayPartition");
5
+ const topologicalSort = (elements, precedes, tie) => {
6
+ const result = [];
7
+ const filterRoots = (verts) => (0, arrayPartition_1.arrayPartition)(verts, succ => !verts.some(pred => precedes(pred, succ)));
8
+ let elem = elements;
9
+ while (elem.length) {
10
+ const [roots, rest] = filterRoots(elem);
11
+ if (!roots.length)
12
+ throw new Error('Cycle detected');
13
+ result.push(...(tie ? roots.sort(tie) : roots));
14
+ elem = rest;
15
+ }
16
+ return result;
17
+ };
18
+ exports.topologicalSort = topologicalSort;
19
+ //# sourceMappingURL=topologicalSort.js.map
@@ -0,0 +1,2 @@
1
+ export declare const truncateMiddle: (text: string, startChars: number, endChars: number) => string;
2
+ //# sourceMappingURL=truncateMiddle.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateMiddle = void 0;
4
+ const truncateMiddle = (text, startChars, endChars) => {
5
+ if (text.length <= startChars + endChars)
6
+ return text;
7
+ const start = text.substring(0, startChars);
8
+ const end = text.substring(text.length - endChars, text.length);
9
+ return `${start}…${end}`;
10
+ };
11
+ exports.truncateMiddle = truncateMiddle;
12
+ //# sourceMappingURL=truncateMiddle.js.map