@w3ux/utils 1.1.0 → 1.1.1-beta.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/base.cjs +9 -0
- package/base.d.cts +9 -1
- package/base.d.ts +9 -1
- package/base.js +8 -0
- package/index.cjs +11 -2
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +10 -2
- package/package.json +1 -9
package/base.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(base_exports, {
|
|
|
33
33
|
removeHexPrefix: () => removeHexPrefix,
|
|
34
34
|
rmCommas: () => rmCommas,
|
|
35
35
|
shuffle: () => shuffle,
|
|
36
|
+
stringToU8a: () => stringToU8a,
|
|
36
37
|
withTimeout: () => withTimeout
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(base_exports);
|
|
@@ -156,6 +157,13 @@ var isSuperset = (set, subset) => {
|
|
|
156
157
|
};
|
|
157
158
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
158
159
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
160
|
+
var stringToU8a = (input) => {
|
|
161
|
+
const u8a = new Uint8Array(input.length);
|
|
162
|
+
for (let i = 0; i < input.length; i++) {
|
|
163
|
+
u8a[i] = input.charCodeAt(i);
|
|
164
|
+
}
|
|
165
|
+
return u8a;
|
|
166
|
+
};
|
|
159
167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
160
168
|
0 && (module.exports = {
|
|
161
169
|
appendOr,
|
|
@@ -172,6 +180,7 @@ var minBigInt = (...values) => values.reduce((min, current) => current < min ? c
|
|
|
172
180
|
removeHexPrefix,
|
|
173
181
|
rmCommas,
|
|
174
182
|
shuffle,
|
|
183
|
+
stringToU8a,
|
|
175
184
|
withTimeout
|
|
176
185
|
});
|
|
177
186
|
/* @license Copyright 2024 w3ux authors & contributors
|
package/base.d.cts
CHANGED
|
@@ -100,5 +100,13 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
100
100
|
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
101
|
*/
|
|
102
102
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
|
+
/**
|
|
104
|
+
* Converts a string to a Uint8Array.
|
|
105
|
+
*
|
|
106
|
+
* @function stringToU8a
|
|
107
|
+
* @param {string} input - The string to convert.
|
|
108
|
+
* @returns {Uint8Array} The resulting Uint8Array.
|
|
109
|
+
*/
|
|
110
|
+
declare const stringToU8a: (input: string) => Uint8Array;
|
|
103
111
|
|
|
104
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
|
112
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, stringToU8a, withTimeout };
|
package/base.d.ts
CHANGED
|
@@ -100,5 +100,13 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
100
100
|
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
101
|
*/
|
|
102
102
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
|
+
/**
|
|
104
|
+
* Converts a string to a Uint8Array.
|
|
105
|
+
*
|
|
106
|
+
* @function stringToU8a
|
|
107
|
+
* @param {string} input - The string to convert.
|
|
108
|
+
* @returns {Uint8Array} The resulting Uint8Array.
|
|
109
|
+
*/
|
|
110
|
+
declare const stringToU8a: (input: string) => Uint8Array;
|
|
103
111
|
|
|
104
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
|
|
112
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, stringToU8a, withTimeout };
|
package/base.js
CHANGED
|
@@ -119,6 +119,13 @@ var isSuperset = (set, subset) => {
|
|
|
119
119
|
};
|
|
120
120
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
121
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
122
|
+
var stringToU8a = (input) => {
|
|
123
|
+
const u8a = new Uint8Array(input.length);
|
|
124
|
+
for (let i = 0; i < input.length; i++) {
|
|
125
|
+
u8a[i] = input.charCodeAt(i);
|
|
126
|
+
}
|
|
127
|
+
return u8a;
|
|
128
|
+
};
|
|
122
129
|
export {
|
|
123
130
|
appendOr,
|
|
124
131
|
appendOrEmpty,
|
|
@@ -134,6 +141,7 @@ export {
|
|
|
134
141
|
removeHexPrefix,
|
|
135
142
|
rmCommas,
|
|
136
143
|
shuffle,
|
|
144
|
+
stringToU8a,
|
|
137
145
|
withTimeout
|
|
138
146
|
};
|
|
139
147
|
/* @license Copyright 2024 w3ux authors & contributors
|
package/index.cjs
CHANGED
|
@@ -62,6 +62,7 @@ __export(src_exports, {
|
|
|
62
62
|
shuffle: () => shuffle,
|
|
63
63
|
snakeToCamel: () => snakeToCamel,
|
|
64
64
|
sortWithNull: () => sortWithNull,
|
|
65
|
+
stringToU8a: () => stringToU8a,
|
|
65
66
|
unescape: () => unescape,
|
|
66
67
|
unimplemented: () => unimplemented,
|
|
67
68
|
unitToPlanck: () => unitToPlanck,
|
|
@@ -191,6 +192,13 @@ var isSuperset = (set, subset) => {
|
|
|
191
192
|
};
|
|
192
193
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
193
194
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
195
|
+
var stringToU8a = (input) => {
|
|
196
|
+
const u8a = new Uint8Array(input.length);
|
|
197
|
+
for (let i = 0; i < input.length; i++) {
|
|
198
|
+
u8a[i] = input.charCodeAt(i);
|
|
199
|
+
}
|
|
200
|
+
return u8a;
|
|
201
|
+
};
|
|
194
202
|
|
|
195
203
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
196
204
|
var import_node_util = __toESM(require("util"), 1);
|
|
@@ -286,13 +294,13 @@ function isU8a(value) {
|
|
|
286
294
|
|
|
287
295
|
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
288
296
|
var encoder = new TextEncoder();
|
|
289
|
-
function
|
|
297
|
+
function stringToU8a2(value) {
|
|
290
298
|
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
294
302
|
function u8aToU8a(value) {
|
|
295
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) :
|
|
303
|
+
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a2(value);
|
|
296
304
|
}
|
|
297
305
|
|
|
298
306
|
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
@@ -583,6 +591,7 @@ var mergeDeep = (target, ...sources) => {
|
|
|
583
591
|
shuffle,
|
|
584
592
|
snakeToCamel,
|
|
585
593
|
sortWithNull,
|
|
594
|
+
stringToU8a,
|
|
586
595
|
unescape,
|
|
587
596
|
unimplemented,
|
|
588
597
|
unitToPlanck,
|
package/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, stringToU8a, withTimeout } from './base.cjs';
|
|
2
2
|
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
|
|
3
3
|
import '@w3ux/types';
|
|
4
4
|
import 'react';
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, stringToU8a, withTimeout } from './base.js';
|
|
2
2
|
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
|
|
3
3
|
import '@w3ux/types';
|
|
4
4
|
import 'react';
|
package/index.js
CHANGED
|
@@ -119,6 +119,13 @@ var isSuperset = (set, subset) => {
|
|
|
119
119
|
};
|
|
120
120
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
121
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
122
|
+
var stringToU8a = (input) => {
|
|
123
|
+
const u8a = new Uint8Array(input.length);
|
|
124
|
+
for (let i = 0; i < input.length; i++) {
|
|
125
|
+
u8a[i] = input.charCodeAt(i);
|
|
126
|
+
}
|
|
127
|
+
return u8a;
|
|
128
|
+
};
|
|
122
129
|
|
|
123
130
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
124
131
|
import util from "node:util";
|
|
@@ -214,13 +221,13 @@ function isU8a(value) {
|
|
|
214
221
|
|
|
215
222
|
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
216
223
|
var encoder = new TextEncoder();
|
|
217
|
-
function
|
|
224
|
+
function stringToU8a2(value) {
|
|
218
225
|
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
222
229
|
function u8aToU8a(value) {
|
|
223
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) :
|
|
230
|
+
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a2(value);
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
@@ -510,6 +517,7 @@ export {
|
|
|
510
517
|
shuffle,
|
|
511
518
|
snakeToCamel,
|
|
512
519
|
sortWithNull,
|
|
520
|
+
stringToU8a,
|
|
513
521
|
unescape,
|
|
514
522
|
unimplemented,
|
|
515
523
|
unitToPlanck,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w3ux/utils",
|
|
3
|
-
"version": "1.1.0",
|
|
3
|
+
"version": "1.1.1-beta.0",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@polkadot-api/substrate-bindings": "^0.9.3"
|
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
".": {
|
|
12
12
|
"import": "./index.js",
|
|
13
13
|
"require": "./index.cjs"
|
|
14
|
-
},
|
|
15
|
-
"./util": {
|
|
16
|
-
"import": "./util/index.js",
|
|
17
|
-
"require": "./util/index.cjs"
|
|
18
|
-
},
|
|
19
|
-
"./util-crypto": {
|
|
20
|
-
"import": "./util-crypto/index.js",
|
|
21
|
-
"require": "./util-crypto/index.cjs"
|
|
22
14
|
}
|
|
23
15
|
}
|
|
24
16
|
}
|