@w3ux/utils 2.0.3 → 2.0.5

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 CHANGED
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/base.ts
20
20
  var base_exports = {};
21
21
  __export(base_exports, {
22
+ appendOr: () => appendOr,
23
+ appendOrEmpty: () => appendOrEmpty,
22
24
  camelize: () => camelize,
23
25
  ellipsisFn: () => ellipsisFn,
24
26
  eqSet: () => eqSet,
@@ -134,6 +136,8 @@ var withTimeout = (ms, promise, options) => {
134
136
  );
135
137
  return Promise.race([promise, timeout]);
136
138
  };
139
+ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
140
+ var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
137
141
  var formatAccountSs58 = (address, ss58Prefix) => {
138
142
  try {
139
143
  const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
@@ -156,6 +160,8 @@ var maxBigInt = (...values) => values.reduce((max, current) => current > max ? c
156
160
  var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
157
161
  // Annotate the CommonJS export names for ESM import in node:
158
162
  0 && (module.exports = {
163
+ appendOr,
164
+ appendOrEmpty,
159
165
  camelize,
160
166
  ellipsisFn,
161
167
  eqSet,
package/base.d.cts CHANGED
@@ -55,10 +55,19 @@ declare const shuffle: <T>(array: T[]) => T[];
55
55
  * @name withTimeout
56
56
  * @summary Timeout a promise after a specified number of milliseconds.
57
57
  */
58
- declare const withTimeout: (ms: number, promise: Promise<() => void>, options?: {
58
+ declare const withTimeout: (ms: number, promise: Promise<() => unknown>, options?: {
59
59
  onTimeout?: () => void;
60
60
  }) => Promise<unknown>;
61
61
  /**
62
+ * @name appendOrEmpty
63
+ * @summary Returns ` value` if a condition is truthy, or an empty string otherwise.
64
+ */
65
+ declare const appendOrEmpty: (condition: boolean | string | undefined, value: string) => string;
66
+ /**
67
+ * @name appendOr
68
+ * @summary Returns ` value` if condition is truthy, or ` fallback` otherwise.
69
+ */
70
+ declare const appendOr: (condition: boolean | string | undefined, value: string, fallback: string) => string;
62
71
  /**
63
72
  * @name formatAccountSs58
64
73
  * @summary Formats an address with the supplied ss58 prefix, or returns null if invalid.
@@ -95,4 +104,4 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
95
104
  */
96
105
  declare const minBigInt: (...values: bigint[]) => bigint;
97
106
 
98
- export { camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
107
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
package/base.d.ts CHANGED
@@ -55,10 +55,19 @@ declare const shuffle: <T>(array: T[]) => T[];
55
55
  * @name withTimeout
56
56
  * @summary Timeout a promise after a specified number of milliseconds.
57
57
  */
58
- declare const withTimeout: (ms: number, promise: Promise<() => void>, options?: {
58
+ declare const withTimeout: (ms: number, promise: Promise<() => unknown>, options?: {
59
59
  onTimeout?: () => void;
60
60
  }) => Promise<unknown>;
61
61
  /**
62
+ * @name appendOrEmpty
63
+ * @summary Returns ` value` if a condition is truthy, or an empty string otherwise.
64
+ */
65
+ declare const appendOrEmpty: (condition: boolean | string | undefined, value: string) => string;
66
+ /**
67
+ * @name appendOr
68
+ * @summary Returns ` value` if condition is truthy, or ` fallback` otherwise.
69
+ */
70
+ declare const appendOr: (condition: boolean | string | undefined, value: string, fallback: string) => string;
62
71
  /**
63
72
  * @name formatAccountSs58
64
73
  * @summary Formats an address with the supplied ss58 prefix, or returns null if invalid.
@@ -95,4 +104,4 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
95
104
  */
96
105
  declare const minBigInt: (...values: bigint[]) => bigint;
97
106
 
98
- export { camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
107
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
package/base.js CHANGED
@@ -98,6 +98,8 @@ var withTimeout = (ms, promise, options) => {
98
98
  );
99
99
  return Promise.race([promise, timeout]);
100
100
  };
101
+ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
102
+ var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
101
103
  var formatAccountSs58 = (address, ss58Prefix) => {
102
104
  try {
103
105
  const codec = AccountId(ss58Prefix);
@@ -119,6 +121,8 @@ var isSuperset = (set, subset) => {
119
121
  var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
120
122
  var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
121
123
  export {
124
+ appendOr,
125
+ appendOrEmpty,
122
126
  camelize,
123
127
  ellipsisFn,
124
128
  eqSet,
package/index.cjs CHANGED
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
22
  addedTo: () => addedTo,
23
+ appendOr: () => appendOr,
24
+ appendOrEmpty: () => appendOrEmpty,
23
25
  applyWidthAsPadding: () => applyWidthAsPadding,
24
26
  camelize: () => camelize,
25
27
  capitalizeFirstLetter: () => capitalizeFirstLetter,
@@ -159,6 +161,8 @@ var withTimeout = (ms, promise, options) => {
159
161
  );
160
162
  return Promise.race([promise, timeout]);
161
163
  };
164
+ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
165
+ var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
162
166
  var formatAccountSs58 = (address, ss58Prefix) => {
163
167
  try {
164
168
  const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
@@ -393,6 +397,8 @@ var mergeDeep = (target, ...sources) => {
393
397
  // Annotate the CommonJS export names for ESM import in node:
394
398
  0 && (module.exports = {
395
399
  addedTo,
400
+ appendOr,
401
+ appendOrEmpty,
396
402
  applyWidthAsPadding,
397
403
  camelize,
398
404
  capitalizeFirstLetter,
package/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.cjs';
1
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.cjs';
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';
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.js';
1
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.js';
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';
package/index.js CHANGED
@@ -98,6 +98,8 @@ var withTimeout = (ms, promise, options) => {
98
98
  );
99
99
  return Promise.race([promise, timeout]);
100
100
  };
101
+ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
102
+ var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
101
103
  var formatAccountSs58 = (address, ss58Prefix) => {
102
104
  try {
103
105
  const codec = AccountId(ss58Prefix);
@@ -331,6 +333,8 @@ var mergeDeep = (target, ...sources) => {
331
333
  };
332
334
  export {
333
335
  addedTo,
336
+ appendOr,
337
+ appendOrEmpty,
334
338
  applyWidthAsPadding,
335
339
  camelize,
336
340
  capitalizeFirstLetter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w3ux/utils",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "license": "GPL-3.0-only",
5
5
  "dependencies": {
6
6
  "@polkadot-api/substrate-bindings": "^0.9.3"