@salespark/toolkit 2.1.0 → 2.1.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/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -181,6 +181,24 @@ declare function flattenDepth<T = unknown>(array: readonly unknown[], depth?: nu
|
|
|
181
181
|
isStrict?: boolean;
|
|
182
182
|
}): T[];
|
|
183
183
|
|
|
184
|
+
/****************************************************
|
|
185
|
+
* ##: Boolean Parser
|
|
186
|
+
* Converts a value to boolean, supporting common string/number representations
|
|
187
|
+
*
|
|
188
|
+
* Notes:
|
|
189
|
+
* - Accepts "true", "yes", "1", "false", "no", "0" (case/whitespace-insensitive)
|
|
190
|
+
* - Returns default value if not recognized or on error
|
|
191
|
+
* @param {unknown} value - Input value (string | number | boolean | null | undefined)
|
|
192
|
+
* @param {Boolean} def - Default value if input cannot be parsed (default: false)
|
|
193
|
+
* History:
|
|
194
|
+
* 21-08-2025: Created
|
|
195
|
+
****************************************************/
|
|
196
|
+
declare const toBool: (value: unknown, def?: boolean) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Use `toBool` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare const parseToBool: (value: unknown, def?: boolean) => boolean;
|
|
201
|
+
|
|
184
202
|
/**
|
|
185
203
|
****************************************************
|
|
186
204
|
* ##: Object Property Picker
|
|
@@ -663,4 +681,4 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
|
663
681
|
declare const isBrowser: boolean;
|
|
664
682
|
declare const isNode: boolean;
|
|
665
683
|
|
|
666
|
-
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toInteger, toNumber, uniq, uniqBy };
|
|
684
|
+
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.d.ts
CHANGED
|
@@ -181,6 +181,24 @@ declare function flattenDepth<T = unknown>(array: readonly unknown[], depth?: nu
|
|
|
181
181
|
isStrict?: boolean;
|
|
182
182
|
}): T[];
|
|
183
183
|
|
|
184
|
+
/****************************************************
|
|
185
|
+
* ##: Boolean Parser
|
|
186
|
+
* Converts a value to boolean, supporting common string/number representations
|
|
187
|
+
*
|
|
188
|
+
* Notes:
|
|
189
|
+
* - Accepts "true", "yes", "1", "false", "no", "0" (case/whitespace-insensitive)
|
|
190
|
+
* - Returns default value if not recognized or on error
|
|
191
|
+
* @param {unknown} value - Input value (string | number | boolean | null | undefined)
|
|
192
|
+
* @param {Boolean} def - Default value if input cannot be parsed (default: false)
|
|
193
|
+
* History:
|
|
194
|
+
* 21-08-2025: Created
|
|
195
|
+
****************************************************/
|
|
196
|
+
declare const toBool: (value: unknown, def?: boolean) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Use `toBool` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare const parseToBool: (value: unknown, def?: boolean) => boolean;
|
|
201
|
+
|
|
184
202
|
/**
|
|
185
203
|
****************************************************
|
|
186
204
|
* ##: Object Property Picker
|
|
@@ -663,4 +681,4 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
|
663
681
|
declare const isBrowser: boolean;
|
|
664
682
|
declare const isNode: boolean;
|
|
665
683
|
|
|
666
|
-
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toInteger, toNumber, uniq, uniqBy };
|
|
684
|
+
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,33 @@ function flattenDepth(array, depth = 1, options) {
|
|
|
133
133
|
return flattenDepthBase(array, depth, predicate, isStrict);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
// src/utils/bool.ts
|
|
137
|
+
var toBool = (value, def = false) => {
|
|
138
|
+
try {
|
|
139
|
+
if (value === null || value === void 0) return def;
|
|
140
|
+
if (typeof value === "boolean") return value;
|
|
141
|
+
if (typeof value === "number") return value === 1;
|
|
142
|
+
if (typeof value === "string") {
|
|
143
|
+
switch (value.toLowerCase().trim()) {
|
|
144
|
+
case "true":
|
|
145
|
+
case "yes":
|
|
146
|
+
case "1":
|
|
147
|
+
return true;
|
|
148
|
+
case "false":
|
|
149
|
+
case "no":
|
|
150
|
+
case "0":
|
|
151
|
+
return false;
|
|
152
|
+
default:
|
|
153
|
+
return def;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return def;
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var parseToBool = toBool;
|
|
162
|
+
|
|
136
163
|
// src/utils/object.ts
|
|
137
164
|
function pick(obj, keys) {
|
|
138
165
|
const out = {};
|
|
@@ -1563,6 +1590,6 @@ var assessSecurityRisks = (risks) => {
|
|
|
1563
1590
|
var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
|
|
1564
1591
|
var isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
1565
1592
|
|
|
1566
|
-
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toInteger, toNumber, uniq, uniqBy };
|
|
1593
|
+
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
1567
1594
|
//# sourceMappingURL=index.js.map
|
|
1568
1595
|
//# sourceMappingURL=index.js.map
|