@w3ux/utils 2.0.9 → 2.1.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/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Base
2
+
3
+ A collection of reusable utilities for manipulating data
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @w3ux/utils
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ yarn add @w3ux/utils
15
+ ```
16
+
17
+ or
18
+
19
+ ```bash
20
+ pnpm add @w3ux/utils
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { /* your imports */ } from '@w3ux/utils'
27
+ ```
28
+
29
+ ### Utility Functions
30
+
31
+ This package provides utility functions that can be used in any JavaScript/TypeScript project:
32
+
33
+ ```typescript
34
+ import { /* specific function */ } from '@w3ux/utils'
35
+
36
+ // Use the utility functions
37
+ const result = /* call your function */
38
+ ```
39
+
40
+ ## Documentation
41
+
42
+ For comprehensive documentation and examples, visit the [w3ux documentation](https://w3ux.org/library/utils).
43
+
44
+ ## Keywords
45
+
46
+ `w3ux`, `polkadot`, `web3`, `utilities`, `typescript`, `data-manipulation`
47
+
48
+ ## Repository
49
+
50
+ - **Source**: [GitHub](https://github.com/w3ux/w3ux-library)
51
+ - **Package**: [npm](https://www.npmjs.com/package/@w3ux/utils)
52
+ - **Issues**: [GitHub Issues](https://github.com/w3ux/w3ux-library/issues)
53
+
54
+ ## License
55
+
56
+ This package is licensed under the GPL-3.0-only.
57
+
58
+ ---
59
+
60
+ Part of the [w3ux library](https://github.com/w3ux/w3ux-library) - A collection of packages for building Web3 applications.
package/base.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -78,7 +79,7 @@ var camelize = (str) => {
78
79
  return result;
79
80
  };
80
81
  const w = toWords(str)?.map((a) => a.toLowerCase());
81
- return simpleCamelCase(w);
82
+ return simpleCamelCase(w || []);
82
83
  };
83
84
  var ellipsisFn = (str, amount = 6, position = "center") => {
84
85
  const half = str.length / 2;
package/base.d.cts CHANGED
@@ -45,7 +45,7 @@ declare const rmCommas: (val: string) => string;
45
45
  * @name rmDecimals
46
46
  * @summary Removes the decimal point and decimals from a string.
47
47
  */
48
- declare const rmDecimals: (str: any) => any;
48
+ declare const rmDecimals: (str: string) => string;
49
49
  /**
50
50
  * @name shuffle
51
51
  * @summary Shuffle a set of objects.
package/base.d.ts CHANGED
@@ -45,7 +45,7 @@ declare const rmCommas: (val: string) => string;
45
45
  * @name rmDecimals
46
46
  * @summary Removes the decimal point and decimals from a string.
47
47
  */
48
- declare const rmDecimals: (str: any) => any;
48
+ declare const rmDecimals: (str: string) => string;
49
49
  /**
50
50
  * @name shuffle
51
51
  * @summary Shuffle a set of objects.
package/base.js CHANGED
@@ -39,7 +39,7 @@ var camelize = (str) => {
39
39
  return result;
40
40
  };
41
41
  const w = toWords(str)?.map((a) => a.toLowerCase());
42
- return simpleCamelCase(w);
42
+ return simpleCamelCase(w || []);
43
43
  };
44
44
  var ellipsisFn = (str, amount = 6, position = "center") => {
45
45
  const half = str.length / 2;
package/convert.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -103,7 +104,7 @@ var camelize = (str) => {
103
104
  return result;
104
105
  };
105
106
  const w = toWords(str)?.map((a) => a.toLowerCase());
106
- return simpleCamelCase(w);
107
+ return simpleCamelCase(w || []);
107
108
  };
108
109
  var ellipsisFn = (str, amount = 6, position = "center") => {
109
110
  const half = str.length / 2;
@@ -301,6 +302,12 @@ var removeVarFromUrlHash = (key) => {
301
302
  window.location.hash = `${page}${paramsAsStr ? `?${paramsAsStr}` : ``}`;
302
303
  };
303
304
  var sortWithNull = (ascending) => (a, b) => {
305
+ if (typeof a === "undefined" && typeof b === "undefined") {
306
+ return 0;
307
+ }
308
+ if (typeof a === "undefined" || typeof b === "undefined") {
309
+ return typeof a === "undefined" ? 1 : -1;
310
+ }
304
311
  if (a === b) {
305
312
  return 0;
306
313
  }
package/index.js CHANGED
@@ -39,7 +39,7 @@ var camelize = (str) => {
39
39
  return result;
40
40
  };
41
41
  const w = toWords(str)?.map((a) => a.toLowerCase());
42
- return simpleCamelCase(w);
42
+ return simpleCamelCase(w || []);
43
43
  };
44
44
  var ellipsisFn = (str, amount = 6, position = "center") => {
45
45
  const half = str.length / 2;
@@ -237,6 +237,12 @@ var removeVarFromUrlHash = (key) => {
237
237
  window.location.hash = `${page}${paramsAsStr ? `?${paramsAsStr}` : ``}`;
238
238
  };
239
239
  var sortWithNull = (ascending) => (a, b) => {
240
+ if (typeof a === "undefined" && typeof b === "undefined") {
241
+ return 0;
242
+ }
243
+ if (typeof a === "undefined" || typeof b === "undefined") {
244
+ return typeof a === "undefined" ? 1 : -1;
245
+ }
240
246
  if (a === b) {
241
247
  return 0;
242
248
  }
package/package.json CHANGED
@@ -1,16 +1,33 @@
1
1
  {
2
2
  "name": "@w3ux/utils",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "license": "GPL-3.0-only",
5
- "dependencies": {
6
- "dedot": "^0.8.1"
5
+ "type": "module",
6
+ "description": "A collection of reusable utilities for manipulating data",
7
+ "keywords": [
8
+ "w3ux",
9
+ "polkadot",
10
+ "web3",
11
+ "utilities",
12
+ "typescript",
13
+ "data-manipulation"
14
+ ],
15
+ "homepage": "https://w3ux.org/library/utils",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/w3ux/w3ux-library.git",
19
+ "directory": "library/utils"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/w3ux/w3ux-library/issues"
7
23
  },
8
- "main": "index.cjs",
9
- "module": "index.js",
10
24
  "exports": {
11
25
  ".": {
12
26
  "import": "./index.js",
13
27
  "require": "./index.cjs"
14
28
  }
29
+ },
30
+ "dependencies": {
31
+ "dedot": "^0.13.0"
15
32
  }
16
33
  }
package/types.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/unit.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -143,6 +144,12 @@ var removeVarFromUrlHash = (key) => {
143
144
  window.location.hash = `${page}${paramsAsStr ? `?${paramsAsStr}` : ``}`;
144
145
  };
145
146
  var sortWithNull = (ascending) => (a, b) => {
147
+ if (typeof a === "undefined" && typeof b === "undefined") {
148
+ return 0;
149
+ }
150
+ if (typeof a === "undefined" || typeof b === "undefined") {
151
+ return typeof a === "undefined" ? 1 : -1;
152
+ }
146
153
  if (a === b) {
147
154
  return 0;
148
155
  }
package/unit.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, RefObject } from 'react';
1
+ import { RefObject } from 'react';
2
2
  import { AnyObject } from './types.cjs';
3
3
 
4
4
  /**
@@ -44,7 +44,7 @@ declare const snakeToCamel: (str: string) => string;
44
44
  * @name setStateWithRef
45
45
  * @summary Synchronize React state and its reference with the provided value.
46
46
  */
47
- declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: MutableRefObject<T>) => void;
47
+ declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: RefObject<T>) => void;
48
48
  /**
49
49
  * @name localStorageOrDefault
50
50
  * @summary Retrieve the local stroage value with the key, return defult value if it is not
@@ -60,7 +60,7 @@ declare const isValidAddress: (address: string) => boolean;
60
60
  * @name extractUrlValue
61
61
  * @summary Extracts a URL value from a URL string.
62
62
  */
63
- declare const extractUrlValue: (key: string, url?: string) => string;
63
+ declare const extractUrlValue: (key: string, url?: string) => string | null;
64
64
  /**
65
65
  * @name varToUrlHash
66
66
  * @summary Puts a variable into the URL hash as a param.
package/unit.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, RefObject } from 'react';
1
+ import { RefObject } from 'react';
2
2
  import { AnyObject } from './types.js';
3
3
 
4
4
  /**
@@ -44,7 +44,7 @@ declare const snakeToCamel: (str: string) => string;
44
44
  * @name setStateWithRef
45
45
  * @summary Synchronize React state and its reference with the provided value.
46
46
  */
47
- declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: MutableRefObject<T>) => void;
47
+ declare const setStateWithRef: <T>(value: T, setState: (_state: T) => void, ref: RefObject<T>) => void;
48
48
  /**
49
49
  * @name localStorageOrDefault
50
50
  * @summary Retrieve the local stroage value with the key, return defult value if it is not
@@ -60,7 +60,7 @@ declare const isValidAddress: (address: string) => boolean;
60
60
  * @name extractUrlValue
61
61
  * @summary Extracts a URL value from a URL string.
62
62
  */
63
- declare const extractUrlValue: (key: string, url?: string) => string;
63
+ declare const extractUrlValue: (key: string, url?: string) => string | null;
64
64
  /**
65
65
  * @name varToUrlHash
66
66
  * @summary Puts a variable into the URL hash as a param.
package/unit.js CHANGED
@@ -99,6 +99,12 @@ var removeVarFromUrlHash = (key) => {
99
99
  window.location.hash = `${page}${paramsAsStr ? `?${paramsAsStr}` : ``}`;
100
100
  };
101
101
  var sortWithNull = (ascending) => (a, b) => {
102
+ if (typeof a === "undefined" && typeof b === "undefined") {
103
+ return 0;
104
+ }
105
+ if (typeof a === "undefined" || typeof b === "undefined") {
106
+ return typeof a === "undefined" ? 1 : -1;
107
+ }
102
108
  if (a === b) {
103
109
  return 0;
104
110
  }