@leather.io/utils 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.yml +4 -0
- package/.turbo/turbo-build.log +17 -0
- package/CHANGELOG.md +272 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +453 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
- package/src/counter.ts +17 -0
- package/src/extract-phrase-from-string/extract-phrase-from-string.spec.ts +79 -0
- package/src/extract-phrase-from-string/extract-phrase-from-string.ts +12 -0
- package/src/index.ts +160 -0
- package/src/math/calculate-averages.spec.ts +16 -0
- package/src/math/calculate-averages.ts +11 -0
- package/src/math/fibonacci.ts +11 -0
- package/src/math/helpers.spec.ts +26 -0
- package/src/math/helpers.ts +32 -0
- package/src/math/index.ts +3 -0
- package/src/money/calculate-money.spec.ts +71 -0
- package/src/money/calculate-money.ts +60 -0
- package/src/money/format-money.ts +89 -0
- package/src/money/index.ts +4 -0
- package/src/money/is-money.ts +15 -0
- package/src/money/unit-conversion.ts +30 -0
- package/src/sort-assets.ts +26 -0
- package/src/spam-filter/spam-filter.spec.ts +26 -0
- package/src/spam-filter/spam-filter.ts +24 -0
- package/src/truncate-middle.ts +23 -0
- package/tsconfig.json +10 -0
- package/tsup.config.ts +9 -0
- package/vitest.config.js +5 -0
package/.eslintrc.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
> @leather.io/utils@0.9.0 build /home/runner/work/mono/mono/packages/utils
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.1.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/mono/mono/packages/utils/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2022
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m13.25 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m25.31 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 20ms
|
|
15
|
+
[34mDTS[39m Build start
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1353ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.91 KB[39m
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### Dependencies
|
|
4
|
+
|
|
5
|
+
* The following workspace dependencies were updated
|
|
6
|
+
* dependencies
|
|
7
|
+
* @leather.io/models bumped to 0.6.2
|
|
8
|
+
* @leather.io/rpc bumped to 0.3.6
|
|
9
|
+
|
|
10
|
+
### Dependencies
|
|
11
|
+
|
|
12
|
+
* The following workspace dependencies were updated
|
|
13
|
+
* dependencies
|
|
14
|
+
* @leather.io/models bumped to 0.6.3
|
|
15
|
+
* @leather.io/rpc bumped to 0.3.7
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
* The following workspace dependencies were updated
|
|
20
|
+
* dependencies
|
|
21
|
+
* @leather.io/models bumped to 0.6.4
|
|
22
|
+
* @leather.io/rpc bumped to 0.3.8
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* The following workspace dependencies were updated
|
|
27
|
+
* dependencies
|
|
28
|
+
* @leather.io/models bumped to 0.6.5
|
|
29
|
+
* @leather.io/rpc bumped to 0.3.9
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
* The following workspace dependencies were updated
|
|
34
|
+
* dependencies
|
|
35
|
+
* @leather.io/models bumped to 0.8.0
|
|
36
|
+
* @leather.io/rpc bumped to 1.0.3
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
* The following workspace dependencies were updated
|
|
41
|
+
* dependencies
|
|
42
|
+
* @leather.io/constants bumped to 0.6.4
|
|
43
|
+
|
|
44
|
+
### Dependencies
|
|
45
|
+
|
|
46
|
+
* The following workspace dependencies were updated
|
|
47
|
+
* dependencies
|
|
48
|
+
* @leather.io/constants bumped to 0.7.0
|
|
49
|
+
* @leather.io/models bumped to 0.9.0
|
|
50
|
+
* @leather.io/rpc bumped to 1.0.4
|
|
51
|
+
|
|
52
|
+
## [0.9.0](https://github.com/leather-io/mono/compare/@leather.io/utils-v0.8.3...@leather.io/utils-v0.9.0) (2024-06-21)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Features
|
|
56
|
+
|
|
57
|
+
* add stacks queries ([ba0ab05](https://github.com/leather-io/mono/commit/ba0ab053cf99c4fa5875079e956cdf7f58deb810))
|
|
58
|
+
* add turborepo + watch dev mode ([d415d79](https://github.com/leather-io/mono/commit/d415d79394488c0cb74765d367b3af8db1d24772))
|
|
59
|
+
* add web and mobile design system with storybook ([0769902](https://github.com/leather-io/mono/commit/076990210312448d583905ac78448ff5068c1f1e))
|
|
60
|
+
* bootstrap release-please ([76b995a](https://github.com/leather-io/mono/commit/76b995a37ecfda0aa006b90ab21cadc57dae8e80))
|
|
61
|
+
* migrate extension components , ref leather-wallet/issues[#64](https://github.com/leather-io/mono/issues/64) ([5404b07](https://github.com/leather-io/mono/commit/5404b07a0ad48865d70a13b9801394f4fc577da3))
|
|
62
|
+
* move basic bitcoin queries from extension ([7ce5efe](https://github.com/leather-io/mono/commit/7ce5efe5e7383f2245ff3ec90ac429ba898a1410))
|
|
63
|
+
* move basics from extension ([eee8003](https://github.com/leather-io/mono/commit/eee80037a7e0eada5b3c013a74882ca88d1a3cd3))
|
|
64
|
+
* prepare monorepo packages for extension development ([4fb2dbc](https://github.com/leather-io/mono/commit/4fb2dbc786987d50800cb80329c5986a51bec4c2))
|
|
65
|
+
* reset to pnpm workspaces ([fa7de49](https://github.com/leather-io/mono/commit/fa7de49928ee099419db9ff3e91c7dc7b15a4ffa))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Bug Fixes
|
|
69
|
+
|
|
70
|
+
* [@leather-wallet](https://github.com/leather-wallet) sorting in prettier ([a44b063](https://github.com/leather-io/mono/commit/a44b0631b745c0ca4abe4d36eb5dfc34a33afce8))
|
|
71
|
+
* bundle packages so that those work in node envs too ([02b6347](https://github.com/leather-io/mono/commit/02b63476e4ea4a519718b31bcc1aeb53aae263f0))
|
|
72
|
+
* i18nFormatCurrency fn ([8c9c9a5](https://github.com/leather-io/mono/commit/8c9c9a5578013e8b22f1f57ae0e1cd51f4ad5c36))
|
|
73
|
+
* **tokens:** bundle pkg ([75c05e1](https://github.com/leather-io/mono/commit/75c05e1a7ebc4e8fa93254f3cb7e73ba760f76bb))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Dependencies
|
|
77
|
+
|
|
78
|
+
* The following workspace dependencies were updated
|
|
79
|
+
* dependencies
|
|
80
|
+
* @leather.io/constants bumped to 0.8.0
|
|
81
|
+
* @leather.io/models bumped to 0.10.0
|
|
82
|
+
* @leather.io/rpc bumped to 2.0.0
|
|
83
|
+
* devDependencies
|
|
84
|
+
* @leather.io/eslint-config bumped to 0.6.0
|
|
85
|
+
* @leather.io/prettier-config bumped to 0.5.0
|
|
86
|
+
* @leather.io/tsconfig-config bumped to 0.5.0
|
|
87
|
+
|
|
88
|
+
## [0.8.0](https://github.com/leather-io/mono/compare/utils-v0.7.0...utils-v0.8.0) (2024-06-07)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Features
|
|
92
|
+
|
|
93
|
+
* add stacks queries ([ba0ab05](https://github.com/leather-io/mono/commit/ba0ab053cf99c4fa5875079e956cdf7f58deb810))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Dependencies
|
|
97
|
+
|
|
98
|
+
* The following workspace dependencies were updated
|
|
99
|
+
* dependencies
|
|
100
|
+
* @leather.io/models bumped to 0.7.0
|
|
101
|
+
* @leather.io/rpc bumped to 1.0.2
|
|
102
|
+
|
|
103
|
+
## [0.7.0](https://github.com/leather-io/mono/compare/utils-v0.6.7...utils-v0.7.0) (2024-06-05)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Features
|
|
107
|
+
|
|
108
|
+
* migrate extension components , ref leather-io/issues[#64](https://github.com/leather-io/mono/issues/64) ([5404b07](https://github.com/leather-io/mono/commit/5404b07a0ad48865d70a13b9801394f4fc577da3))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Dependencies
|
|
112
|
+
|
|
113
|
+
* The following workspace dependencies were updated
|
|
114
|
+
* dependencies
|
|
115
|
+
* @leather.io/constants bumped to 0.6.3
|
|
116
|
+
* @leather.io/models bumped to 0.6.8
|
|
117
|
+
* @leather.io/rpc bumped to 1.0.1
|
|
118
|
+
* devDependencies
|
|
119
|
+
* @leather.io/eslint-config bumped to 0.5.0
|
|
120
|
+
|
|
121
|
+
## [0.6.7](https://github.com/leather-io/mono/compare/utils-v0.6.6...utils-v0.6.7) (2024-06-05)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* [@leather.io](https://github.com/leather-io) sorting in prettier ([a44b063](https://github.com/leather-io/mono/commit/a44b0631b745c0ca4abe4d36eb5dfc34a33afce8))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Dependencies
|
|
130
|
+
|
|
131
|
+
* The following workspace dependencies were updated
|
|
132
|
+
* dependencies
|
|
133
|
+
* @leather.io/constants bumped to 0.6.2
|
|
134
|
+
* @leather.io/models bumped to 0.6.7
|
|
135
|
+
* @leather.io/rpc bumped to 1.0.0
|
|
136
|
+
* devDependencies
|
|
137
|
+
* @leather.io/prettier-config bumped to 0.4.1
|
|
138
|
+
|
|
139
|
+
## [0.6.6](https://github.com/leather-io/mono/compare/utils-v0.6.5...utils-v0.6.6) (2024-05-30)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
### Bug Fixes
|
|
143
|
+
|
|
144
|
+
* i18nFormatCurrency fn ([8c9c9a5](https://github.com/leather-io/mono/commit/8c9c9a5578013e8b22f1f57ae0e1cd51f4ad5c36))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### Dependencies
|
|
148
|
+
|
|
149
|
+
* The following workspace dependencies were updated
|
|
150
|
+
* dependencies
|
|
151
|
+
* @leather.io/models bumped to 0.6.6
|
|
152
|
+
* @leather.io/rpc bumped to 0.3.10
|
|
153
|
+
|
|
154
|
+
## [0.6.1](https://github.com/leather-io/mono/compare/utils-v0.6.0...utils-v0.6.1) (2024-05-20)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### Bug Fixes
|
|
158
|
+
|
|
159
|
+
* bundle packages so that those work in node envs too ([02b6347](https://github.com/leather-io/mono/commit/02b63476e4ea4a519718b31bcc1aeb53aae263f0))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Dependencies
|
|
163
|
+
|
|
164
|
+
* The following workspace dependencies were updated
|
|
165
|
+
* dependencies
|
|
166
|
+
* @leather.io/constants bumped to 0.6.1
|
|
167
|
+
* @leather.io/models bumped to 0.6.1
|
|
168
|
+
* @leather.io/rpc bumped to 0.3.5
|
|
169
|
+
|
|
170
|
+
## [0.6.0](https://github.com/leather-io/mono/compare/utils-v0.5.1...utils-v0.6.0) (2024-05-17)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
### Features
|
|
174
|
+
|
|
175
|
+
* add turborepo + watch dev mode ([d415d79](https://github.com/leather-io/mono/commit/d415d79394488c0cb74765d367b3af8db1d24772))
|
|
176
|
+
* add web and mobile design system with storybook ([0769902](https://github.com/leather-io/mono/commit/076990210312448d583905ac78448ff5068c1f1e))
|
|
177
|
+
* bootstrap release-please ([76b995a](https://github.com/leather-io/mono/commit/76b995a37ecfda0aa006b90ab21cadc57dae8e80))
|
|
178
|
+
* move basic bitcoin queries from extension ([7ce5efe](https://github.com/leather-io/mono/commit/7ce5efe5e7383f2245ff3ec90ac429ba898a1410))
|
|
179
|
+
* move basics from extension ([eee8003](https://github.com/leather-io/mono/commit/eee80037a7e0eada5b3c013a74882ca88d1a3cd3))
|
|
180
|
+
* prepare monorepo packages for extension development ([4fb2dbc](https://github.com/leather-io/mono/commit/4fb2dbc786987d50800cb80329c5986a51bec4c2))
|
|
181
|
+
* reset to pnpm workspaces ([fa7de49](https://github.com/leather-io/mono/commit/fa7de49928ee099419db9ff3e91c7dc7b15a4ffa))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
### Bug Fixes
|
|
185
|
+
|
|
186
|
+
* **tokens:** bundle pkg ([75c05e1](https://github.com/leather-io/mono/commit/75c05e1a7ebc4e8fa93254f3cb7e73ba760f76bb))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
### Dependencies
|
|
190
|
+
|
|
191
|
+
* The following workspace dependencies were updated
|
|
192
|
+
* dependencies
|
|
193
|
+
* @leather.io/constants bumped to 0.6.0
|
|
194
|
+
* @leather.io/models bumped to 0.6.0
|
|
195
|
+
* @leather.io/rpc bumped to 0.3.4
|
|
196
|
+
* devDependencies
|
|
197
|
+
* @leather.io/eslint-config bumped to 0.4.0
|
|
198
|
+
* @leather.io/prettier-config bumped to 0.4.0
|
|
199
|
+
* @leather.io/tsconfig-config bumped to 0.4.0
|
|
200
|
+
|
|
201
|
+
## [0.5.0](https://github.com/leather-io/mono/compare/utils-v0.4.1...utils-v0.5.0) (2024-05-17)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Features
|
|
205
|
+
|
|
206
|
+
* add turborepo + watch dev mode ([d415d79](https://github.com/leather-io/mono/commit/d415d79394488c0cb74765d367b3af8db1d24772))
|
|
207
|
+
* add web and mobile design system with storybook ([0769902](https://github.com/leather-io/mono/commit/076990210312448d583905ac78448ff5068c1f1e))
|
|
208
|
+
* bootstrap release-please ([76b995a](https://github.com/leather-io/mono/commit/76b995a37ecfda0aa006b90ab21cadc57dae8e80))
|
|
209
|
+
* move basic bitcoin queries from extension ([7ce5efe](https://github.com/leather-io/mono/commit/7ce5efe5e7383f2245ff3ec90ac429ba898a1410))
|
|
210
|
+
* move basics from extension ([eee8003](https://github.com/leather-io/mono/commit/eee80037a7e0eada5b3c013a74882ca88d1a3cd3))
|
|
211
|
+
* prepare monorepo packages for extension development ([4fb2dbc](https://github.com/leather-io/mono/commit/4fb2dbc786987d50800cb80329c5986a51bec4c2))
|
|
212
|
+
* reset to pnpm workspaces ([fa7de49](https://github.com/leather-io/mono/commit/fa7de49928ee099419db9ff3e91c7dc7b15a4ffa))
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### Bug Fixes
|
|
216
|
+
|
|
217
|
+
* **tokens:** bundle pkg ([75c05e1](https://github.com/leather-io/mono/commit/75c05e1a7ebc4e8fa93254f3cb7e73ba760f76bb))
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
### Dependencies
|
|
221
|
+
|
|
222
|
+
* The following workspace dependencies were updated
|
|
223
|
+
* dependencies
|
|
224
|
+
* @leather.io/constants bumped to 0.5.0
|
|
225
|
+
* @leather.io/models bumped to 0.5.0
|
|
226
|
+
* @leather.io/rpc bumped to 0.3.2
|
|
227
|
+
* devDependencies
|
|
228
|
+
* @leather.io/eslint-config bumped to 0.3.0
|
|
229
|
+
* @leather.io/prettier-config bumped to 0.3.0
|
|
230
|
+
* @leather.io/tsconfig-config bumped to 0.3.0
|
|
231
|
+
|
|
232
|
+
## [0.4.0](https://github.com/leather-io/mono/compare/utils-v0.3.0...utils-v0.4.0) (2024-05-07)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
* refactor: pkg org and asset data models ([a46a82c](https://github.com/leather-io/mono/commit/4fb2dbc786987d50800cb80329c5986a51bec4c2))
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
## [0.3.0](https://github.com/leather-io/mono/compare/utils-v0.2.0...utils-v0.3.0) (2024-05-07)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### Features
|
|
242
|
+
|
|
243
|
+
* prepare monorepo packages for extension development ([4fb2dbc](https://github.com/leather-io/mono/commit/4fb2dbc786987d50800cb80329c5986a51bec4c2))
|
|
244
|
+
|
|
245
|
+
## [0.2.0](https://github.com/leather-io/mono/compare/utils-v0.1.0...utils-v0.2.0) (2024-04-23)
|
|
246
|
+
|
|
247
|
+
### Features
|
|
248
|
+
|
|
249
|
+
- add turborepo + watch dev mode ([d415d79](https://github.com/leather-io/mono/commit/d415d79394488c0cb74765d367b3af8db1d24772))
|
|
250
|
+
- add web and mobile design system with storybook ([0769902](https://github.com/leather-io/mono/commit/076990210312448d583905ac78448ff5068c1f1e))
|
|
251
|
+
- bootstrap release-please ([76b995a](https://github.com/leather-io/mono/commit/76b995a37ecfda0aa006b90ab21cadc57dae8e80))
|
|
252
|
+
- move basic bitcoin queries from extension ([7ce5efe](https://github.com/leather-io/mono/commit/7ce5efe5e7383f2245ff3ec90ac429ba898a1410))
|
|
253
|
+
- move basics from extension ([eee8003](https://github.com/leather-io/mono/commit/eee80037a7e0eada5b3c013a74882ca88d1a3cd3))
|
|
254
|
+
- reset to pnpm workspaces ([fa7de49](https://github.com/leather-io/mono/commit/fa7de49928ee099419db9ff3e91c7dc7b15a4ffa))
|
|
255
|
+
|
|
256
|
+
### Bug Fixes
|
|
257
|
+
|
|
258
|
+
- **tokens:** bundle pkg ([75c05e1](https://github.com/leather-io/mono/commit/75c05e1a7ebc4e8fa93254f3cb7e73ba760f76bb))
|
|
259
|
+
|
|
260
|
+
## [0.1.0](https://github.com/leather-io/mono/compare/utils-v0.0.2...utils-v0.1.0) (2024-04-23)
|
|
261
|
+
|
|
262
|
+
### Features
|
|
263
|
+
|
|
264
|
+
- add turborepo + watch dev mode ([d415d79](https://github.com/leather-io/mono/commit/d415d79394488c0cb74765d367b3af8db1d24772))
|
|
265
|
+
- add web and mobile design system with storybook ([0769902](https://github.com/leather-io/mono/commit/076990210312448d583905ac78448ff5068c1f1e))
|
|
266
|
+
- move basic bitcoin queries from extension ([7ce5efe](https://github.com/leather-io/mono/commit/7ce5efe5e7383f2245ff3ec90ac429ba898a1410))
|
|
267
|
+
- move basics from extension ([eee8003](https://github.com/leather-io/mono/commit/eee80037a7e0eada5b3c013a74882ca88d1a3cd3))
|
|
268
|
+
- reset to pnpm workspaces ([fa7de49](https://github.com/leather-io/mono/commit/fa7de49928ee099419db9ff3e91c7dc7b15a4ffa))
|
|
269
|
+
|
|
270
|
+
### Bug Fixes
|
|
271
|
+
|
|
272
|
+
- **tokens:** bundle pkg ([75c05e1](https://github.com/leather-io/mono/commit/75c05e1a7ebc4e8fa93254f3cb7e73ba760f76bb))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Leather Wallet LLC [a subsidiary of Nassau Machines]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @leather.io/utils
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
|
|
2
|
+
import { Money, MarketData, NumType, Currencies, NetworkModes } from '@leather.io/models';
|
|
3
|
+
|
|
4
|
+
declare function createCounter(startPosition?: number): {
|
|
5
|
+
getValue(): number;
|
|
6
|
+
increment(): number;
|
|
7
|
+
incrementBy(amount: number): number;
|
|
8
|
+
decrement(): number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare function calculateMeanAverage(numbers: BigNumber[] | number[]): BigNumber;
|
|
12
|
+
|
|
13
|
+
declare function fibonacciGenerator(startIndex?: number): IterableIterator<number>;
|
|
14
|
+
|
|
15
|
+
declare function initBigNumber(num: string | number | BigNumber | bigint): BigNumber;
|
|
16
|
+
declare function isEven(num: number): boolean;
|
|
17
|
+
declare function countDecimals(num: string | number | BigNumber): number;
|
|
18
|
+
declare function increaseValueByOneMicroStx(value: string | number | BigNumber): number;
|
|
19
|
+
|
|
20
|
+
declare function baseCurrencyAmountInQuote(quantity: Money, { pair, price }: MarketData): Money;
|
|
21
|
+
declare function convertAmountToFractionalUnit(num: Money | BigNumber$1, decimals?: number): BigNumber$1;
|
|
22
|
+
declare function convertToMoneyTypeWithDefaultOfZero(symbol: string, num?: NumType, decimals?: number): Money;
|
|
23
|
+
declare function convertAmountToBaseUnit(num: Money | BigNumber$1, decimals?: number): BigNumber$1;
|
|
24
|
+
declare function subtractMoney(xAmount: Money, yAmount: Money): Money;
|
|
25
|
+
declare function sumMoney(moneysArr: Money[]): Money;
|
|
26
|
+
|
|
27
|
+
declare function createMoneyFromDecimal(value: NumType, symbol: Currencies, resolution?: number): Money;
|
|
28
|
+
declare function createMoney(value: NumType, symbol: Currencies, resolution?: number): Money;
|
|
29
|
+
declare function formatMoney({ amount, symbol, decimals }: Money): string;
|
|
30
|
+
declare function formatMoneyWithoutSymbol({ amount, decimals }: Money): string;
|
|
31
|
+
declare function formatMoneyPadded({ amount, symbol, decimals }: Money): string;
|
|
32
|
+
declare function i18nFormatCurrency(quantity: Money, decimals?: number): string;
|
|
33
|
+
declare function formatDustUsdAmounts(value: string): string;
|
|
34
|
+
|
|
35
|
+
declare function isMoney(val: unknown): val is Money;
|
|
36
|
+
declare function isMoneyGreaterThanZero(money: Money): boolean | undefined;
|
|
37
|
+
|
|
38
|
+
declare function unitToFractionalUnit(decimals: number): (unit: number | string | BigNumber) => BigNumber;
|
|
39
|
+
declare const satToBtc: (unit: number | string | BigNumber) => BigNumber;
|
|
40
|
+
declare const btcToSat: (unit: number | string | BigNumber) => BigNumber;
|
|
41
|
+
declare const microStxToStx: (unit: number | string | BigNumber) => BigNumber;
|
|
42
|
+
declare const stxToMicroStx: (unit: number | string | BigNumber) => BigNumber;
|
|
43
|
+
declare function moneyToBaseUnit(sum: Money): BigNumber;
|
|
44
|
+
|
|
45
|
+
declare function sortAssetsByName<T extends {
|
|
46
|
+
name: string;
|
|
47
|
+
}[]>(assets: T): T;
|
|
48
|
+
declare function migratePositiveAssetBalancesToTop<T extends {
|
|
49
|
+
balance: Money;
|
|
50
|
+
}[]>(assets: T): T;
|
|
51
|
+
|
|
52
|
+
declare function truncateMiddle(input: string, offset?: number): string;
|
|
53
|
+
|
|
54
|
+
declare function spamFilter(input: string): string;
|
|
55
|
+
|
|
56
|
+
declare function extractPhraseFromString(value: string): string;
|
|
57
|
+
|
|
58
|
+
declare function isNumber(value: unknown): value is number;
|
|
59
|
+
declare function isString(value: unknown): value is string;
|
|
60
|
+
declare function isBigInt(value: unknown): value is bigint;
|
|
61
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
62
|
+
declare function isFunction(value: unknown): value is () => void;
|
|
63
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
64
|
+
declare function isObject(value: unknown): value is object;
|
|
65
|
+
declare function isError(value: unknown): value is Error;
|
|
66
|
+
declare function isEmpty(value: object): boolean;
|
|
67
|
+
declare function isDefined<T>(argument: T | undefined): argument is T;
|
|
68
|
+
declare function isTypedArray(val: unknown): val is Uint8Array;
|
|
69
|
+
declare function noop(): void;
|
|
70
|
+
declare function ensureArray<T>(value: T | T[]): T[];
|
|
71
|
+
declare function undefinedIfLengthZero<T extends any[]>(arr: T): T | undefined;
|
|
72
|
+
type NetworkMap<T> = Record<NetworkModes, T>;
|
|
73
|
+
declare function whenNetwork(mode: NetworkModes): <T extends NetworkMap<unknown>>(networkMap: T) => T["mainnet" | "testnet"];
|
|
74
|
+
declare function isEmptyArray(data: unknown[]): boolean;
|
|
75
|
+
declare const defaultWalletKeyId: "default";
|
|
76
|
+
declare function reverseBytes(bytes: Buffer): Buffer;
|
|
77
|
+
declare function reverseBytes(bytes: Uint8Array): Uint8Array;
|
|
78
|
+
declare function makeNumberRange(num: number): number[];
|
|
79
|
+
declare function createNumArrayOfRange(fromIndex: number, toIndex: number): number[];
|
|
80
|
+
declare function delay(ms: number): Promise<unknown>;
|
|
81
|
+
declare function sumNumbers(nums: number[]): BigNumber$1;
|
|
82
|
+
declare function isFulfilled<T>(p: PromiseSettledResult<T>): p is PromiseFulfilledResult<T>;
|
|
83
|
+
declare function isRejected<T>(p: PromiseSettledResult<T>): p is PromiseRejectedResult;
|
|
84
|
+
declare function getPrincipalFromContractId(identifier: string): string;
|
|
85
|
+
declare function formatContractId(address: string, name: string): string;
|
|
86
|
+
declare function createNullArrayOfLength(length: number): any[];
|
|
87
|
+
declare function safelyFormatHexTxid(id: string): string;
|
|
88
|
+
declare function getTicker(value: string): string;
|
|
89
|
+
declare function propIfDefined(prop: string, value: any): {
|
|
90
|
+
[x: string]: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { baseCurrencyAmountInQuote, btcToSat, calculateMeanAverage, convertAmountToBaseUnit, convertAmountToFractionalUnit, convertToMoneyTypeWithDefaultOfZero, countDecimals, createCounter, createMoney, createMoneyFromDecimal, createNullArrayOfLength, createNumArrayOfRange, defaultWalletKeyId, delay, ensureArray, extractPhraseFromString, fibonacciGenerator, formatContractId, formatDustUsdAmounts, formatMoney, formatMoneyPadded, formatMoneyWithoutSymbol, getPrincipalFromContractId, getTicker, i18nFormatCurrency, increaseValueByOneMicroStx, initBigNumber, isBigInt, isBoolean, isDefined, isEmpty, isEmptyArray, isError, isEven, isFulfilled, isFunction, isMoney, isMoneyGreaterThanZero, isNumber, isObject, isRejected, isString, isTypedArray, isUndefined, makeNumberRange, microStxToStx, migratePositiveAssetBalancesToTop, moneyToBaseUnit, noop, propIfDefined, reverseBytes, safelyFormatHexTxid, satToBtc, sortAssetsByName, spamFilter, stxToMicroStx, subtractMoney, sumMoney, sumNumbers, truncateMiddle, undefinedIfLengthZero, unitToFractionalUnit, whenNetwork };
|