@w3ux/utils 1.1.1-beta.6 → 1.1.1-beta.7
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/convert.cjs +1 -58
- package/convert.d.cts +1 -24
- package/convert.d.ts +1 -24
- package/convert.js +1 -32
- package/index.cjs +4 -36
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +4 -33
- package/package.json +1 -1
package/convert.cjs
CHANGED
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/convert.ts
|
|
20
|
-
var convert_exports = {};
|
|
21
|
-
__export(convert_exports, {
|
|
22
|
-
stringToU8a: () => stringToU8a,
|
|
23
|
-
u8aConcat: () => u8aConcat,
|
|
24
|
-
u8aToString: () => u8aToString
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(convert_exports);
|
|
27
|
-
var stringToU8a = (input) => {
|
|
28
|
-
const u8a = new Uint8Array(input.length);
|
|
29
|
-
for (let i = 0; i < input.length; i++) {
|
|
30
|
-
u8a[i] = input.charCodeAt(i);
|
|
31
|
-
}
|
|
32
|
-
return u8a;
|
|
33
|
-
};
|
|
34
|
-
var u8aToString = (u8a) => {
|
|
35
|
-
const chars = new Array(u8a.length);
|
|
36
|
-
for (let i = 0; i < u8a.length; i++) {
|
|
37
|
-
chars[i] = String.fromCharCode(u8a[i]);
|
|
38
|
-
}
|
|
39
|
-
return chars.join("");
|
|
40
|
-
};
|
|
41
|
-
var u8aConcat = (...u8as) => {
|
|
42
|
-
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
43
|
-
const result = new Uint8Array(totalLength);
|
|
44
|
-
let offset = 0;
|
|
45
|
-
for (const u8a of u8as) {
|
|
46
|
-
result.set(u8a, offset);
|
|
47
|
-
offset += u8a.length;
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
stringToU8a,
|
|
54
|
-
u8aConcat,
|
|
55
|
-
u8aToString
|
|
56
|
-
});
|
|
57
|
-
/* @license Copyright 2024 w3ux authors & contributors
|
|
58
|
-
SPDX-License-Identifier: GPL-3.0-only */
|
|
1
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/convert.d.cts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string to a Uint8Array.
|
|
3
|
-
*
|
|
4
|
-
* @function stringToU8a
|
|
5
|
-
* @param {string} input - The string to convert.
|
|
6
|
-
* @returns {Uint8Array} The resulting Uint8Array.
|
|
7
|
-
*/
|
|
8
|
-
declare const stringToU8a: (input: string) => Uint8Array;
|
|
9
|
-
/**
|
|
10
|
-
* Converts a Uint8Array to a string.
|
|
11
|
-
*
|
|
12
|
-
* @function u8aToString
|
|
13
|
-
* @param {Uint8Array} u8a - The Uint8Array to convert.
|
|
14
|
-
* @returns {string} The resulting string.
|
|
15
|
-
*/
|
|
16
|
-
declare const u8aToString: (u8a: Uint8Array) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Concatenates multiple Uint8Array instances into a single Uint8Array.
|
|
19
|
-
*
|
|
20
|
-
* @param {Uint8Array[]} u8as - An array of Uint8Array instances to concatenate.
|
|
21
|
-
* @returns {Uint8Array} A new Uint8Array containing all the input arrays concatenated.
|
|
22
|
-
*/
|
|
23
|
-
declare const u8aConcat: (...u8as: Uint8Array[]) => Uint8Array;
|
|
24
1
|
|
|
25
|
-
export {
|
|
2
|
+
export { }
|
package/convert.d.ts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string to a Uint8Array.
|
|
3
|
-
*
|
|
4
|
-
* @function stringToU8a
|
|
5
|
-
* @param {string} input - The string to convert.
|
|
6
|
-
* @returns {Uint8Array} The resulting Uint8Array.
|
|
7
|
-
*/
|
|
8
|
-
declare const stringToU8a: (input: string) => Uint8Array;
|
|
9
|
-
/**
|
|
10
|
-
* Converts a Uint8Array to a string.
|
|
11
|
-
*
|
|
12
|
-
* @function u8aToString
|
|
13
|
-
* @param {Uint8Array} u8a - The Uint8Array to convert.
|
|
14
|
-
* @returns {string} The resulting string.
|
|
15
|
-
*/
|
|
16
|
-
declare const u8aToString: (u8a: Uint8Array) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Concatenates multiple Uint8Array instances into a single Uint8Array.
|
|
19
|
-
*
|
|
20
|
-
* @param {Uint8Array[]} u8as - An array of Uint8Array instances to concatenate.
|
|
21
|
-
* @returns {Uint8Array} A new Uint8Array containing all the input arrays concatenated.
|
|
22
|
-
*/
|
|
23
|
-
declare const u8aConcat: (...u8as: Uint8Array[]) => Uint8Array;
|
|
24
1
|
|
|
25
|
-
export {
|
|
2
|
+
export { }
|
package/convert.js
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
//
|
|
2
|
-
var stringToU8a = (input) => {
|
|
3
|
-
const u8a = new Uint8Array(input.length);
|
|
4
|
-
for (let i = 0; i < input.length; i++) {
|
|
5
|
-
u8a[i] = input.charCodeAt(i);
|
|
6
|
-
}
|
|
7
|
-
return u8a;
|
|
8
|
-
};
|
|
9
|
-
var u8aToString = (u8a) => {
|
|
10
|
-
const chars = new Array(u8a.length);
|
|
11
|
-
for (let i = 0; i < u8a.length; i++) {
|
|
12
|
-
chars[i] = String.fromCharCode(u8a[i]);
|
|
13
|
-
}
|
|
14
|
-
return chars.join("");
|
|
15
|
-
};
|
|
16
|
-
var u8aConcat = (...u8as) => {
|
|
17
|
-
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
18
|
-
const result = new Uint8Array(totalLength);
|
|
19
|
-
let offset = 0;
|
|
20
|
-
for (const u8a of u8as) {
|
|
21
|
-
result.set(u8a, offset);
|
|
22
|
-
offset += u8a.length;
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
stringToU8a,
|
|
28
|
-
u8aConcat,
|
|
29
|
-
u8aToString
|
|
30
|
-
};
|
|
31
|
-
/* @license Copyright 2024 w3ux authors & contributors
|
|
32
|
-
SPDX-License-Identifier: GPL-3.0-only */
|
|
1
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/index.cjs
CHANGED
|
@@ -62,9 +62,6 @@ __export(src_exports, {
|
|
|
62
62
|
shuffle: () => shuffle,
|
|
63
63
|
snakeToCamel: () => snakeToCamel,
|
|
64
64
|
sortWithNull: () => sortWithNull,
|
|
65
|
-
stringToU8a: () => stringToU8a,
|
|
66
|
-
u8aConcat: () => u8aConcat,
|
|
67
|
-
u8aToString: () => u8aToString,
|
|
68
65
|
unescape: () => unescape,
|
|
69
66
|
unimplemented: () => unimplemented,
|
|
70
67
|
unitToPlanck: () => unitToPlanck,
|
|
@@ -195,32 +192,6 @@ var isSuperset = (set, subset) => {
|
|
|
195
192
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
196
193
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
197
194
|
|
|
198
|
-
// src/convert.ts
|
|
199
|
-
var stringToU8a = (input) => {
|
|
200
|
-
const u8a = new Uint8Array(input.length);
|
|
201
|
-
for (let i = 0; i < input.length; i++) {
|
|
202
|
-
u8a[i] = input.charCodeAt(i);
|
|
203
|
-
}
|
|
204
|
-
return u8a;
|
|
205
|
-
};
|
|
206
|
-
var u8aToString = (u8a) => {
|
|
207
|
-
const chars = new Array(u8a.length);
|
|
208
|
-
for (let i = 0; i < u8a.length; i++) {
|
|
209
|
-
chars[i] = String.fromCharCode(u8a[i]);
|
|
210
|
-
}
|
|
211
|
-
return chars.join("");
|
|
212
|
-
};
|
|
213
|
-
var u8aConcat = (...u8as) => {
|
|
214
|
-
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
215
|
-
const result = new Uint8Array(totalLength);
|
|
216
|
-
let offset = 0;
|
|
217
|
-
for (const u8a of u8as) {
|
|
218
|
-
result.set(u8a, offset);
|
|
219
|
-
offset += u8a.length;
|
|
220
|
-
}
|
|
221
|
-
return result;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
195
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
225
196
|
var import_node_util = __toESM(require("util"), 1);
|
|
226
197
|
|
|
@@ -315,13 +286,13 @@ function isU8a(value) {
|
|
|
315
286
|
|
|
316
287
|
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
317
288
|
var encoder = new TextEncoder();
|
|
318
|
-
function
|
|
289
|
+
function stringToU8a(value) {
|
|
319
290
|
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
320
291
|
}
|
|
321
292
|
|
|
322
293
|
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
323
294
|
function u8aToU8a(value) {
|
|
324
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) :
|
|
295
|
+
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a(value);
|
|
325
296
|
}
|
|
326
297
|
|
|
327
298
|
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
@@ -350,7 +321,7 @@ function u8aEq(a, b) {
|
|
|
350
321
|
|
|
351
322
|
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
352
323
|
var decoder = new TextDecoder("utf-8");
|
|
353
|
-
function
|
|
324
|
+
function u8aToString(value) {
|
|
354
325
|
return value ? decoder.decode(value) : "";
|
|
355
326
|
}
|
|
356
327
|
|
|
@@ -436,7 +407,7 @@ var isValidAddress = (address) => {
|
|
|
436
407
|
var determinePoolDisplay = (address, batchItem) => {
|
|
437
408
|
const defaultDisplay = ellipsisFn(address, 6);
|
|
438
409
|
let display = batchItem ?? defaultDisplay;
|
|
439
|
-
const displayAsBytes =
|
|
410
|
+
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
440
411
|
if (displayAsBytes !== "") {
|
|
441
412
|
display = displayAsBytes;
|
|
442
413
|
}
|
|
@@ -612,9 +583,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
612
583
|
shuffle,
|
|
613
584
|
snakeToCamel,
|
|
614
585
|
sortWithNull,
|
|
615
|
-
stringToU8a,
|
|
616
|
-
u8aConcat,
|
|
617
|
-
u8aToString,
|
|
618
586
|
unescape,
|
|
619
587
|
unimplemented,
|
|
620
588
|
unitToPlanck,
|
package/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
|
|
2
|
-
export { stringToU8a, u8aConcat, u8aToString } from './convert.cjs';
|
|
3
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';
|
|
4
3
|
import '@w3ux/types';
|
|
5
4
|
import 'react';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
|
|
2
|
-
export { stringToU8a, u8aConcat, u8aToString } from './convert.js';
|
|
3
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';
|
|
4
3
|
import '@w3ux/types';
|
|
5
4
|
import 'react';
|
package/index.js
CHANGED
|
@@ -120,32 +120,6 @@ var isSuperset = (set, subset) => {
|
|
|
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
122
|
|
|
123
|
-
// src/convert.ts
|
|
124
|
-
var stringToU8a = (input) => {
|
|
125
|
-
const u8a = new Uint8Array(input.length);
|
|
126
|
-
for (let i = 0; i < input.length; i++) {
|
|
127
|
-
u8a[i] = input.charCodeAt(i);
|
|
128
|
-
}
|
|
129
|
-
return u8a;
|
|
130
|
-
};
|
|
131
|
-
var u8aToString = (u8a) => {
|
|
132
|
-
const chars = new Array(u8a.length);
|
|
133
|
-
for (let i = 0; i < u8a.length; i++) {
|
|
134
|
-
chars[i] = String.fromCharCode(u8a[i]);
|
|
135
|
-
}
|
|
136
|
-
return chars.join("");
|
|
137
|
-
};
|
|
138
|
-
var u8aConcat = (...u8as) => {
|
|
139
|
-
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
140
|
-
const result = new Uint8Array(totalLength);
|
|
141
|
-
let offset = 0;
|
|
142
|
-
for (const u8a of u8as) {
|
|
143
|
-
result.set(u8a, offset);
|
|
144
|
-
offset += u8a.length;
|
|
145
|
-
}
|
|
146
|
-
return result;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
123
|
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
150
124
|
import util from "node:util";
|
|
151
125
|
|
|
@@ -240,13 +214,13 @@ function isU8a(value) {
|
|
|
240
214
|
|
|
241
215
|
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
242
216
|
var encoder = new TextEncoder();
|
|
243
|
-
function
|
|
217
|
+
function stringToU8a(value) {
|
|
244
218
|
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
245
219
|
}
|
|
246
220
|
|
|
247
221
|
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
248
222
|
function u8aToU8a(value) {
|
|
249
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) :
|
|
223
|
+
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a(value);
|
|
250
224
|
}
|
|
251
225
|
|
|
252
226
|
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
@@ -275,7 +249,7 @@ function u8aEq(a, b) {
|
|
|
275
249
|
|
|
276
250
|
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
277
251
|
var decoder = new TextDecoder("utf-8");
|
|
278
|
-
function
|
|
252
|
+
function u8aToString(value) {
|
|
279
253
|
return value ? decoder.decode(value) : "";
|
|
280
254
|
}
|
|
281
255
|
|
|
@@ -361,7 +335,7 @@ var isValidAddress = (address) => {
|
|
|
361
335
|
var determinePoolDisplay = (address, batchItem) => {
|
|
362
336
|
const defaultDisplay = ellipsisFn(address, 6);
|
|
363
337
|
let display = batchItem ?? defaultDisplay;
|
|
364
|
-
const displayAsBytes =
|
|
338
|
+
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
365
339
|
if (displayAsBytes !== "") {
|
|
366
340
|
display = displayAsBytes;
|
|
367
341
|
}
|
|
@@ -536,9 +510,6 @@ export {
|
|
|
536
510
|
shuffle,
|
|
537
511
|
snakeToCamel,
|
|
538
512
|
sortWithNull,
|
|
539
|
-
stringToU8a,
|
|
540
|
-
u8aConcat,
|
|
541
|
-
u8aToString,
|
|
542
513
|
unescape,
|
|
543
514
|
unimplemented,
|
|
544
515
|
unitToPlanck,
|