@talismn/util 0.3.1 → 0.3.2
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/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/isNotNil.d.ts +9 -0
- package/dist/declarations/src/isTruthy.d.ts +1 -0
- package/dist/talismn-util.cjs.dev.js +14 -0
- package/dist/talismn-util.cjs.prod.js +14 -0
- package/dist/talismn-util.esm.js +13 -1
- package/package.json +3 -3
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
3
|
+
* ie: false and 0 are considered not nil
|
4
|
+
* Use isTruthy instead for a regular coercion check.
|
5
|
+
*
|
6
|
+
* @param value
|
7
|
+
* @returns whether the value is neither null nor undefined
|
8
|
+
*/
|
9
|
+
export declare const isNotNil: <T>(value: T | null | undefined) => value is T;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
@@ -303,6 +303,18 @@ const isAscii = str => {
|
|
303
303
|
return [...str].every(char => char.charCodeAt(0) <= 127);
|
304
304
|
};
|
305
305
|
|
306
|
+
/**
|
307
|
+
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
308
|
+
* ie: false and 0 are considered not nil
|
309
|
+
* Use isTruthy instead for a regular coercion check.
|
310
|
+
*
|
311
|
+
* @param value
|
312
|
+
* @returns whether the value is neither null nor undefined
|
313
|
+
*/
|
314
|
+
const isNotNil = value => value !== null && value !== undefined;
|
315
|
+
|
316
|
+
const isTruthy = value => Boolean(value);
|
317
|
+
|
306
318
|
exports.BigMath = BigMath;
|
307
319
|
exports.Deferred = Deferred;
|
308
320
|
exports.MAX_DECIMALS_FORMAT = MAX_DECIMALS_FORMAT;
|
@@ -323,6 +335,8 @@ exports.isAscii = isAscii;
|
|
323
335
|
exports.isBigInt = isBigInt;
|
324
336
|
exports.isBooleanTrue = isBooleanTrue;
|
325
337
|
exports.isEthereumAddress = isEthereumAddress;
|
338
|
+
exports.isNotNil = isNotNil;
|
339
|
+
exports.isTruthy = isTruthy;
|
326
340
|
exports.isValidSubstrateAddress = isValidSubstrateAddress;
|
327
341
|
exports.normalizeAddress = normalizeAddress;
|
328
342
|
exports.planckToTokens = planckToTokens;
|
@@ -303,6 +303,18 @@ const isAscii = str => {
|
|
303
303
|
return [...str].every(char => char.charCodeAt(0) <= 127);
|
304
304
|
};
|
305
305
|
|
306
|
+
/**
|
307
|
+
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
308
|
+
* ie: false and 0 are considered not nil
|
309
|
+
* Use isTruthy instead for a regular coercion check.
|
310
|
+
*
|
311
|
+
* @param value
|
312
|
+
* @returns whether the value is neither null nor undefined
|
313
|
+
*/
|
314
|
+
const isNotNil = value => value !== null && value !== undefined;
|
315
|
+
|
316
|
+
const isTruthy = value => Boolean(value);
|
317
|
+
|
306
318
|
exports.BigMath = BigMath;
|
307
319
|
exports.Deferred = Deferred;
|
308
320
|
exports.MAX_DECIMALS_FORMAT = MAX_DECIMALS_FORMAT;
|
@@ -323,6 +335,8 @@ exports.isAscii = isAscii;
|
|
323
335
|
exports.isBigInt = isBigInt;
|
324
336
|
exports.isBooleanTrue = isBooleanTrue;
|
325
337
|
exports.isEthereumAddress = isEthereumAddress;
|
338
|
+
exports.isNotNil = isNotNil;
|
339
|
+
exports.isTruthy = isTruthy;
|
326
340
|
exports.isValidSubstrateAddress = isValidSubstrateAddress;
|
327
341
|
exports.normalizeAddress = normalizeAddress;
|
328
342
|
exports.planckToTokens = planckToTokens;
|
package/dist/talismn-util.esm.js
CHANGED
@@ -297,4 +297,16 @@ const isAscii = str => {
|
|
297
297
|
return [...str].every(char => char.charCodeAt(0) <= 127);
|
298
298
|
};
|
299
299
|
|
300
|
-
|
300
|
+
/**
|
301
|
+
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
302
|
+
* ie: false and 0 are considered not nil
|
303
|
+
* Use isTruthy instead for a regular coercion check.
|
304
|
+
*
|
305
|
+
* @param value
|
306
|
+
* @returns whether the value is neither null nor undefined
|
307
|
+
*/
|
308
|
+
const isNotNil = value => value !== null && value !== undefined;
|
309
|
+
|
310
|
+
const isTruthy = value => Boolean(value);
|
311
|
+
|
312
|
+
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, addTrailingSlash, blake2Concat, classNames, convertAddress, decodeAnyAddress, decodeSs58Format, encodeAnyAddress, firstThenDebounce, formatDecimals, formatPrice, hasOwnProperty, isAddressEqual, isArrayOf, isAscii, isBigInt, isBooleanTrue, isEthereumAddress, isNotNil, isTruthy, isValidSubstrateAddress, normalizeAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat, validateHexString };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/util",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.2",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -34,8 +34,8 @@
|
|
34
34
|
"jest": "^29.7.0",
|
35
35
|
"ts-jest": "^29.2.5",
|
36
36
|
"typescript": "^5.6.3",
|
37
|
-
"@talismn/
|
38
|
-
"@talismn/
|
37
|
+
"@talismn/eslint-config": "0.0.3",
|
38
|
+
"@talismn/tsconfig": "0.0.2"
|
39
39
|
},
|
40
40
|
"peerDependencies": {
|
41
41
|
"@polkadot/keyring": "*",
|