@w3ux/utils 2.0.6 → 2.0.7-alpha.1

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/index.cjs CHANGED
@@ -17,8 +17,8 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
19
  // src/index.ts
20
- var src_exports = {};
21
- __export(src_exports, {
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
22
  addedTo: () => addedTo,
23
23
  appendOr: () => appendOr,
24
24
  appendOrEmpty: () => appendOrEmpty,
@@ -59,7 +59,7 @@ __export(src_exports, {
59
59
  varToUrlHash: () => varToUrlHash,
60
60
  withTimeout: () => withTimeout
61
61
  });
62
- module.exports = __toCommonJS(src_exports);
62
+ module.exports = __toCommonJS(index_exports);
63
63
 
64
64
  // src/base.ts
65
65
  var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
package/index.d.cts CHANGED
@@ -2,4 +2,3 @@ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58
2
2
  export { u8aConcat } from './convert.cjs';
3
3
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
4
4
  import 'react';
5
- import './types.cjs';
package/index.d.ts CHANGED
@@ -2,4 +2,3 @@ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58
2
2
  export { u8aConcat } from './convert.js';
3
3
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
4
4
  import 'react';
5
- import './types.js';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@w3ux/utils",
3
- "version": "2.0.6",
3
+ "version": "2.0.7-alpha.1",
4
4
  "license": "GPL-3.0-only",
5
5
  "dependencies": {
6
- "@polkadot-api/substrate-bindings": "^0.9.3"
6
+ "@polkadot-api/substrate-bindings": "^0.11.1"
7
7
  },
8
8
  "main": "index.cjs",
9
9
  "module": "index.js",
package/unit.cjs CHANGED
@@ -43,6 +43,7 @@ __export(unit_exports, {
43
43
  varToUrlHash: () => varToUrlHash
44
44
  });
45
45
  module.exports = __toCommonJS(unit_exports);
46
+ var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
46
47
 
47
48
  // src/base.ts
48
49
  var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
@@ -50,7 +51,6 @@ var rmCommas = (val) => val.replace(/,/g, "");
50
51
  var rmDecimals = (str) => str.split(".")[0];
51
52
 
52
53
  // src/unit.ts
53
- var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
54
54
  var planckToUnit = (val, units) => {
55
55
  try {
56
56
  units = Math.max(Math.round(units), 0);
package/unit.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { MutableRefObject, RefObject } from 'react';
2
- import { AnyObject } from './types.cjs';
1
+ import { RefObject } from 'react';
3
2
 
4
3
  /**
5
4
  * Converts an on-chain balance value from planck to a decimal value in token units.
@@ -44,7 +43,7 @@ declare const snakeToCamel: (str: string) => string;
44
43
  * @name setStateWithRef
45
44
  * @summary Synchronize React state and its reference with the provided value.
46
45
  */
47
- declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: MutableRefObject<T>) => void;
46
+ declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: RefObject<T>) => void;
48
47
  /**
49
48
  * @name localStorageOrDefault
50
49
  * @summary Retrieve the local stroage value with the key, return defult value if it is not
@@ -101,19 +100,19 @@ declare const inChrome: () => boolean;
101
100
  * @summary Given 2 objects and some keys, return items in the fresh object that do not exist in the
102
101
  * stale object by matching the given common key values of both objects.
103
102
  */
104
- declare const addedTo: (fresh: AnyObject[], stale: AnyObject[], keys: string[]) => AnyObject[];
103
+ declare const addedTo: (fresh: object[], stale: object[], keys: string[]) => object[];
105
104
  /**
106
105
  * @name removedFrom
107
106
  * @summary Given 2 objects and some keys, return items in the stale object that do not exist in the
108
107
  * fresh object by matching the given common key values of both objects.
109
108
  */
110
- declare const removedFrom: (fresh: AnyObject[], stale: AnyObject[], keys: string[]) => AnyObject[];
109
+ declare const removedFrom: (fresh: object[], stale: object[], keys: string[]) => object[];
111
110
  /**
112
111
  * @name matchedProperties
113
112
  * @summary Given 2 objects and some keys, return items in object 1 that also exist in object 2 by
114
113
  * matching the given common key values of both objects.
115
114
  */
116
- declare const matchedProperties: (objX: AnyObject[], objY: AnyObject[], keys: string[]) => AnyObject[];
115
+ declare const matchedProperties: (objX: object[], objY: object[], keys: string[]) => object[];
117
116
  /**
118
117
  * @name isValidHttpUrl
119
118
  * @summary Give a string, return whether it is a valid http URL.
@@ -125,7 +124,7 @@ declare const isValidHttpUrl: (string: string) => boolean;
125
124
  * @summary Makes a promise cancellable.
126
125
  * @param promise - The promise to make cancellable.
127
126
  */
128
- declare const makeCancelable: (promise: Promise<AnyObject>) => {
127
+ declare const makeCancelable: <T>(promise: Promise<T>) => {
129
128
  promise: Promise<unknown>;
130
129
  cancel: () => void;
131
130
  };
@@ -142,6 +141,6 @@ declare const unimplemented: ({ ...props }: {
142
141
  * @param target
143
142
  * @param ...sources
144
143
  */
145
- declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
144
+ declare const mergeDeep: (target: object, ...sources: object[]) => any;
146
145
 
147
146
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
package/unit.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { MutableRefObject, RefObject } from 'react';
2
- import { AnyObject } from './types.js';
1
+ import { RefObject } from 'react';
3
2
 
4
3
  /**
5
4
  * Converts an on-chain balance value from planck to a decimal value in token units.
@@ -44,7 +43,7 @@ declare const snakeToCamel: (str: string) => string;
44
43
  * @name setStateWithRef
45
44
  * @summary Synchronize React state and its reference with the provided value.
46
45
  */
47
- declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: MutableRefObject<T>) => void;
46
+ declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: RefObject<T>) => void;
48
47
  /**
49
48
  * @name localStorageOrDefault
50
49
  * @summary Retrieve the local stroage value with the key, return defult value if it is not
@@ -101,19 +100,19 @@ declare const inChrome: () => boolean;
101
100
  * @summary Given 2 objects and some keys, return items in the fresh object that do not exist in the
102
101
  * stale object by matching the given common key values of both objects.
103
102
  */
104
- declare const addedTo: (fresh: AnyObject[], stale: AnyObject[], keys: string[]) => AnyObject[];
103
+ declare const addedTo: (fresh: object[], stale: object[], keys: string[]) => object[];
105
104
  /**
106
105
  * @name removedFrom
107
106
  * @summary Given 2 objects and some keys, return items in the stale object that do not exist in the
108
107
  * fresh object by matching the given common key values of both objects.
109
108
  */
110
- declare const removedFrom: (fresh: AnyObject[], stale: AnyObject[], keys: string[]) => AnyObject[];
109
+ declare const removedFrom: (fresh: object[], stale: object[], keys: string[]) => object[];
111
110
  /**
112
111
  * @name matchedProperties
113
112
  * @summary Given 2 objects and some keys, return items in object 1 that also exist in object 2 by
114
113
  * matching the given common key values of both objects.
115
114
  */
116
- declare const matchedProperties: (objX: AnyObject[], objY: AnyObject[], keys: string[]) => AnyObject[];
115
+ declare const matchedProperties: (objX: object[], objY: object[], keys: string[]) => object[];
117
116
  /**
118
117
  * @name isValidHttpUrl
119
118
  * @summary Give a string, return whether it is a valid http URL.
@@ -125,7 +124,7 @@ declare const isValidHttpUrl: (string: string) => boolean;
125
124
  * @summary Makes a promise cancellable.
126
125
  * @param promise - The promise to make cancellable.
127
126
  */
128
- declare const makeCancelable: (promise: Promise<AnyObject>) => {
127
+ declare const makeCancelable: <T>(promise: Promise<T>) => {
129
128
  promise: Promise<unknown>;
130
129
  cancel: () => void;
131
130
  };
@@ -142,6 +141,6 @@ declare const unimplemented: ({ ...props }: {
142
141
  * @param target
143
142
  * @param ...sources
144
143
  */
145
- declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
144
+ declare const mergeDeep: (target: object, ...sources: object[]) => any;
146
145
 
147
146
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
package/unit.js CHANGED
@@ -1,10 +1,12 @@
1
+ // src/unit.ts
2
+ import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
3
+
1
4
  // src/base.ts
2
5
  import { AccountId } from "@polkadot-api/substrate-bindings";
3
6
  var rmCommas = (val) => val.replace(/,/g, "");
4
7
  var rmDecimals = (str) => str.split(".")[0];
5
8
 
6
9
  // src/unit.ts
7
- import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
8
10
  var planckToUnit = (val, units) => {
9
11
  try {
10
12
  units = Math.max(Math.round(units), 0);