@salespark/toolkit 2.1.22 → 2.1.23
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 +53 -0
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +38 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1102,8 +1102,95 @@ type SmsLengthResult = {
|
|
|
1102
1102
|
****************************************************/
|
|
1103
1103
|
declare const smsLength: (text: string, singleOverrides?: Partial<Record<SmsEncoding, number>>, multiOverrides?: Partial<Record<SmsEncoding, number>>) => SmsLengthResult;
|
|
1104
1104
|
|
|
1105
|
+
/******************************************************************
|
|
1106
|
+
* ##: Generate Random Number (non-crypto)
|
|
1107
|
+
* Returns a floating-point value in the range [0, 1) using Math.random().
|
|
1108
|
+
* @returns {number} - Random float between 0 (inclusive) and 1 (exclusive)
|
|
1109
|
+
* History:
|
|
1110
|
+
* 28-03-2026: Created
|
|
1111
|
+
******************************************************************/
|
|
1112
|
+
declare const random: () => number;
|
|
1113
|
+
/******************************************************************
|
|
1114
|
+
* ##: Pick Random Array Item
|
|
1115
|
+
* Selects a random element from the provided array using Math.random().
|
|
1116
|
+
* @param {unknown[]} array - Source array to pick from
|
|
1117
|
+
* @returns {unknown} - Random element (undefined if array is empty)
|
|
1118
|
+
* History:
|
|
1119
|
+
* 28-03-2026: Created
|
|
1120
|
+
******************************************************************/
|
|
1121
|
+
declare const randFromArray: (array: unknown[]) => unknown;
|
|
1122
|
+
/******************************************************************
|
|
1123
|
+
* ##: Random Integer From Interval
|
|
1124
|
+
* Generates an integer in the range [min, max) using Math.random().
|
|
1125
|
+
* @param {number} min - Inclusive lower bound
|
|
1126
|
+
* @param {number} max - Exclusive upper bound
|
|
1127
|
+
* @returns {number} - Random integer within the interval
|
|
1128
|
+
* History:
|
|
1129
|
+
* 28-03-2026: Created
|
|
1130
|
+
******************************************************************/
|
|
1131
|
+
declare const randIntFromInterval: (min: number, max: number) => number;
|
|
1132
|
+
/******************************************************************
|
|
1133
|
+
* ##: Shuffle Array In Place
|
|
1134
|
+
* Applies the Durstenfeld shuffle to randomize the array order in place.
|
|
1135
|
+
* @param {T[]} array - Array to shuffle (mutated)
|
|
1136
|
+
* @returns {T[]} - The same array instance, shuffled
|
|
1137
|
+
* History:
|
|
1138
|
+
* 28-03-2026: Created
|
|
1139
|
+
******************************************************************/
|
|
1140
|
+
declare function shuffleArrayMutate<T>(array: T[]): T[];
|
|
1141
|
+
/******************************************************************
|
|
1142
|
+
* ##: Shuffle Array Copy
|
|
1143
|
+
* Returns a shuffled copy of the input array without mutating the original.
|
|
1144
|
+
* @param {T[]} array - Array to shuffle (not mutated)
|
|
1145
|
+
* @returns {T[]} - New array with randomized order
|
|
1146
|
+
* History:
|
|
1147
|
+
* 28-03-2026: Created
|
|
1148
|
+
******************************************************************/
|
|
1149
|
+
declare const shuffleArray: <T>(array: T[]) => T[];
|
|
1150
|
+
/******************************************************************
|
|
1151
|
+
* ##: Shuffle String Parts
|
|
1152
|
+
* Shuffles a string by splitting on a delimiter and rejoining after shuffle.
|
|
1153
|
+
* @param {string} str - Input string to shuffle
|
|
1154
|
+
* @param {string} delimiter - Split/join delimiter (default: empty string)
|
|
1155
|
+
* @returns {string} - Shuffled string
|
|
1156
|
+
* History:
|
|
1157
|
+
* 28-03-2026: Created
|
|
1158
|
+
******************************************************************/
|
|
1159
|
+
declare const shuffleString: (str: string, delimiter?: string) => string;
|
|
1160
|
+
/******************************************************************
|
|
1161
|
+
* ##: Create Random Token (non-crypto)
|
|
1162
|
+
* Builds a token string from a configurable alphabet and shuffles it.
|
|
1163
|
+
* Notes: This uses Math.random() and is NOT cryptographically secure.
|
|
1164
|
+
* @param {object} options - Token generation options
|
|
1165
|
+
* @param {boolean} options.withUppercase - Include A-Z (default: true)
|
|
1166
|
+
* @param {boolean} options.withLowercase - Include a-z (default: true)
|
|
1167
|
+
* @param {boolean} options.withNumbers - Include 0-9 (default: true)
|
|
1168
|
+
* @param {boolean} options.withSymbols - Include symbols (default: false)
|
|
1169
|
+
* @param {number} options.length - Token length (default: 64)
|
|
1170
|
+
* @param {string} options.alphabet - Custom alphabet (overrides flags)
|
|
1171
|
+
* @returns {string} - Generated token
|
|
1172
|
+
* History:
|
|
1173
|
+
* 28-03-2026: Created
|
|
1174
|
+
******************************************************************/
|
|
1175
|
+
declare function createToken({ withUppercase, withLowercase, withNumbers, withSymbols, length, alphabet, }?: {
|
|
1176
|
+
withUppercase?: boolean;
|
|
1177
|
+
withLowercase?: boolean;
|
|
1178
|
+
withNumbers?: boolean;
|
|
1179
|
+
withSymbols?: boolean;
|
|
1180
|
+
length?: number;
|
|
1181
|
+
alphabet?: string;
|
|
1182
|
+
}): string;
|
|
1183
|
+
/******************************************************************
|
|
1184
|
+
* ##: Generate Random ID String
|
|
1185
|
+
* Builds a short id with a base36 random segment prefixed by "id-".
|
|
1186
|
+
* @returns {string} - Random id string
|
|
1187
|
+
* History:
|
|
1188
|
+
* 28-03-2026: Created
|
|
1189
|
+
******************************************************************/
|
|
1190
|
+
declare const generateRandomId: () => string;
|
|
1191
|
+
|
|
1105
1192
|
/** Environment helpers (runtime-agnostic checks) */
|
|
1106
1193
|
declare const isBrowser: boolean;
|
|
1107
1194
|
declare const isNode: boolean;
|
|
1108
1195
|
|
|
1109
|
-
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
1196
|
+
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, createToken, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, generateRandomId, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randFromArray, randIntFromInterval, random, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, shuffleArray, shuffleArrayMutate, shuffleString, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.d.ts
CHANGED
|
@@ -1102,8 +1102,95 @@ type SmsLengthResult = {
|
|
|
1102
1102
|
****************************************************/
|
|
1103
1103
|
declare const smsLength: (text: string, singleOverrides?: Partial<Record<SmsEncoding, number>>, multiOverrides?: Partial<Record<SmsEncoding, number>>) => SmsLengthResult;
|
|
1104
1104
|
|
|
1105
|
+
/******************************************************************
|
|
1106
|
+
* ##: Generate Random Number (non-crypto)
|
|
1107
|
+
* Returns a floating-point value in the range [0, 1) using Math.random().
|
|
1108
|
+
* @returns {number} - Random float between 0 (inclusive) and 1 (exclusive)
|
|
1109
|
+
* History:
|
|
1110
|
+
* 28-03-2026: Created
|
|
1111
|
+
******************************************************************/
|
|
1112
|
+
declare const random: () => number;
|
|
1113
|
+
/******************************************************************
|
|
1114
|
+
* ##: Pick Random Array Item
|
|
1115
|
+
* Selects a random element from the provided array using Math.random().
|
|
1116
|
+
* @param {unknown[]} array - Source array to pick from
|
|
1117
|
+
* @returns {unknown} - Random element (undefined if array is empty)
|
|
1118
|
+
* History:
|
|
1119
|
+
* 28-03-2026: Created
|
|
1120
|
+
******************************************************************/
|
|
1121
|
+
declare const randFromArray: (array: unknown[]) => unknown;
|
|
1122
|
+
/******************************************************************
|
|
1123
|
+
* ##: Random Integer From Interval
|
|
1124
|
+
* Generates an integer in the range [min, max) using Math.random().
|
|
1125
|
+
* @param {number} min - Inclusive lower bound
|
|
1126
|
+
* @param {number} max - Exclusive upper bound
|
|
1127
|
+
* @returns {number} - Random integer within the interval
|
|
1128
|
+
* History:
|
|
1129
|
+
* 28-03-2026: Created
|
|
1130
|
+
******************************************************************/
|
|
1131
|
+
declare const randIntFromInterval: (min: number, max: number) => number;
|
|
1132
|
+
/******************************************************************
|
|
1133
|
+
* ##: Shuffle Array In Place
|
|
1134
|
+
* Applies the Durstenfeld shuffle to randomize the array order in place.
|
|
1135
|
+
* @param {T[]} array - Array to shuffle (mutated)
|
|
1136
|
+
* @returns {T[]} - The same array instance, shuffled
|
|
1137
|
+
* History:
|
|
1138
|
+
* 28-03-2026: Created
|
|
1139
|
+
******************************************************************/
|
|
1140
|
+
declare function shuffleArrayMutate<T>(array: T[]): T[];
|
|
1141
|
+
/******************************************************************
|
|
1142
|
+
* ##: Shuffle Array Copy
|
|
1143
|
+
* Returns a shuffled copy of the input array without mutating the original.
|
|
1144
|
+
* @param {T[]} array - Array to shuffle (not mutated)
|
|
1145
|
+
* @returns {T[]} - New array with randomized order
|
|
1146
|
+
* History:
|
|
1147
|
+
* 28-03-2026: Created
|
|
1148
|
+
******************************************************************/
|
|
1149
|
+
declare const shuffleArray: <T>(array: T[]) => T[];
|
|
1150
|
+
/******************************************************************
|
|
1151
|
+
* ##: Shuffle String Parts
|
|
1152
|
+
* Shuffles a string by splitting on a delimiter and rejoining after shuffle.
|
|
1153
|
+
* @param {string} str - Input string to shuffle
|
|
1154
|
+
* @param {string} delimiter - Split/join delimiter (default: empty string)
|
|
1155
|
+
* @returns {string} - Shuffled string
|
|
1156
|
+
* History:
|
|
1157
|
+
* 28-03-2026: Created
|
|
1158
|
+
******************************************************************/
|
|
1159
|
+
declare const shuffleString: (str: string, delimiter?: string) => string;
|
|
1160
|
+
/******************************************************************
|
|
1161
|
+
* ##: Create Random Token (non-crypto)
|
|
1162
|
+
* Builds a token string from a configurable alphabet and shuffles it.
|
|
1163
|
+
* Notes: This uses Math.random() and is NOT cryptographically secure.
|
|
1164
|
+
* @param {object} options - Token generation options
|
|
1165
|
+
* @param {boolean} options.withUppercase - Include A-Z (default: true)
|
|
1166
|
+
* @param {boolean} options.withLowercase - Include a-z (default: true)
|
|
1167
|
+
* @param {boolean} options.withNumbers - Include 0-9 (default: true)
|
|
1168
|
+
* @param {boolean} options.withSymbols - Include symbols (default: false)
|
|
1169
|
+
* @param {number} options.length - Token length (default: 64)
|
|
1170
|
+
* @param {string} options.alphabet - Custom alphabet (overrides flags)
|
|
1171
|
+
* @returns {string} - Generated token
|
|
1172
|
+
* History:
|
|
1173
|
+
* 28-03-2026: Created
|
|
1174
|
+
******************************************************************/
|
|
1175
|
+
declare function createToken({ withUppercase, withLowercase, withNumbers, withSymbols, length, alphabet, }?: {
|
|
1176
|
+
withUppercase?: boolean;
|
|
1177
|
+
withLowercase?: boolean;
|
|
1178
|
+
withNumbers?: boolean;
|
|
1179
|
+
withSymbols?: boolean;
|
|
1180
|
+
length?: number;
|
|
1181
|
+
alphabet?: string;
|
|
1182
|
+
}): string;
|
|
1183
|
+
/******************************************************************
|
|
1184
|
+
* ##: Generate Random ID String
|
|
1185
|
+
* Builds a short id with a base36 random segment prefixed by "id-".
|
|
1186
|
+
* @returns {string} - Random id string
|
|
1187
|
+
* History:
|
|
1188
|
+
* 28-03-2026: Created
|
|
1189
|
+
******************************************************************/
|
|
1190
|
+
declare const generateRandomId: () => string;
|
|
1191
|
+
|
|
1105
1192
|
/** Environment helpers (runtime-agnostic checks) */
|
|
1106
1193
|
declare const isBrowser: boolean;
|
|
1107
1194
|
declare const isNode: boolean;
|
|
1108
1195
|
|
|
1109
|
-
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
1196
|
+
export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, createToken, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, generateRandomId, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randFromArray, randIntFromInterval, random, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, shuffleArray, shuffleArrayMutate, shuffleString, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.js
CHANGED
|
@@ -2675,10 +2675,47 @@ var smsLength = (text, singleOverrides, multiOverrides) => {
|
|
|
2675
2675
|
};
|
|
2676
2676
|
};
|
|
2677
2677
|
|
|
2678
|
+
// src/utils/random.ts
|
|
2679
|
+
var random = () => Math.random();
|
|
2680
|
+
var randFromArray = (array) => array[Math.floor(random() * array.length)];
|
|
2681
|
+
var randIntFromInterval = (min, max) => Math.floor(random() * (max - min) + min);
|
|
2682
|
+
function shuffleArrayMutate(array) {
|
|
2683
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
2684
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
2685
|
+
[array[i], array[j]] = [array[j], array[i]];
|
|
2686
|
+
}
|
|
2687
|
+
return array;
|
|
2688
|
+
}
|
|
2689
|
+
var shuffleArray = (array) => shuffleArrayMutate([...array]);
|
|
2690
|
+
var shuffleString = (str, delimiter = "") => shuffleArrayMutate(str.split(delimiter)).join(delimiter);
|
|
2691
|
+
function createToken({
|
|
2692
|
+
withUppercase = true,
|
|
2693
|
+
withLowercase = true,
|
|
2694
|
+
withNumbers = true,
|
|
2695
|
+
withSymbols = false,
|
|
2696
|
+
length = 64,
|
|
2697
|
+
alphabet
|
|
2698
|
+
} = {}) {
|
|
2699
|
+
const allAlphabet = alphabet ?? [
|
|
2700
|
+
withUppercase ? "ABCDEFGHIJKLMOPQRSTUVWXYZ" : "",
|
|
2701
|
+
withLowercase ? "abcdefghijklmopqrstuvwxyz" : "",
|
|
2702
|
+
withNumbers ? "0123456789" : "",
|
|
2703
|
+
withSymbols ? `.,;:!?./-"'#{([-|\\@)]=}*+` : ""
|
|
2704
|
+
].join("");
|
|
2705
|
+
const safeLength = Number.isFinite(length) ? Math.max(0, Math.floor(length)) : 0;
|
|
2706
|
+
if (!allAlphabet || safeLength === 0) return "";
|
|
2707
|
+
let token = "";
|
|
2708
|
+
for (let i = 0; i < safeLength; i++) {
|
|
2709
|
+
token += allAlphabet[Math.floor(random() * allAlphabet.length)];
|
|
2710
|
+
}
|
|
2711
|
+
return token;
|
|
2712
|
+
}
|
|
2713
|
+
var generateRandomId = () => `id-${random().toString(36).substring(2, 12)}`;
|
|
2714
|
+
|
|
2678
2715
|
// src/index.ts
|
|
2679
2716
|
var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
|
|
2680
2717
|
var isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
2681
2718
|
|
|
2682
|
-
export { GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
2719
|
+
export { GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, createToken, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, generateRandomId, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randFromArray, randIntFromInterval, random, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, shuffleArray, shuffleArrayMutate, shuffleString, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
|
2683
2720
|
//# sourceMappingURL=index.js.map
|
|
2684
2721
|
//# sourceMappingURL=index.js.map
|