foreslash 0.3.7 → 0.3.8
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/CHANGELOG.md +11 -1
- package/lib/index.cmn.cjs +17 -7
- package/lib/index.d.ts +35 -1
- package/lib/index.mjs +16 -8
- package/lib/index.umd.js +17 -7
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## Version 0.3.8 - 2026-01-25
|
|
4
|
+
|
|
5
|
+
- Feat 🥥 Function(s) added: `constantCase`
|
|
6
|
+
- Feat 🥥 Function(s) exposed: `transferNumberToSupUniCode`
|
|
7
|
+
- Other fixes and improvements
|
|
8
|
+
|
|
9
|
+
- 功能 🥥 添加函数: `constantCase`
|
|
10
|
+
- 功能 🥥 公开函数: `transferNumberToSupUniCode`
|
|
11
|
+
- 其他修复与优化
|
|
12
|
+
|
|
3
13
|
## Version 0.3.7 - 2026-01-24
|
|
4
14
|
|
|
5
15
|
Add a method to convert numbers to Chinese numerals
|
|
6
16
|
|
|
7
|
-
- Feat 🥥
|
|
17
|
+
- Feat 🥥 Function(s) added: `chinaNumerals`
|
|
8
18
|
|
|
9
19
|
添加了将数字转换为中文的方法
|
|
10
20
|
|
package/lib/index.cmn.cjs
CHANGED
|
@@ -451,7 +451,7 @@ function decimalNotation(num) {
|
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
function chinaNumerals(num, options) {
|
|
454
|
-
var _a, _b
|
|
454
|
+
var _a, _b;
|
|
455
455
|
const str = decimalNotation(num);
|
|
456
456
|
if (/NaN|Inf/.test(str))
|
|
457
457
|
return str;
|
|
@@ -530,15 +530,15 @@ function chinaNumerals(num, options) {
|
|
|
530
530
|
const result = parts.join('').replace(zeroRegex, zeroChar).replace(trailingZeroRegex, '');
|
|
531
531
|
integerPart = result === '' ? numberChar[0] : result;
|
|
532
532
|
}
|
|
533
|
+
integerPart += (_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '';
|
|
533
534
|
return fractional
|
|
534
535
|
? integerPart +
|
|
535
|
-
((_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '') +
|
|
536
536
|
((_b = options === null || options === void 0 ? void 0 : options.dot) !== null && _b !== void 0 ? _b : '点') +
|
|
537
537
|
fractional
|
|
538
538
|
.split('')
|
|
539
539
|
.map((d, i) => { var _a, _b; return numberChar[Number(d)] + ((_b = (_a = options === null || options === void 0 ? void 0 : options.fractionalUnits) === null || _a === void 0 ? void 0 : _a[i]) !== null && _b !== void 0 ? _b : ''); })
|
|
540
540
|
.join('')
|
|
541
|
-
: integerPart
|
|
541
|
+
: integerPart;
|
|
542
542
|
}
|
|
543
543
|
function getNormalUnits(units, index) {
|
|
544
544
|
if (index === 0)
|
|
@@ -913,13 +913,13 @@ function scientificNotation(num, options) {
|
|
|
913
913
|
return `{"number":"${n}","exp":${exp}}`;
|
|
914
914
|
case 'unicode':
|
|
915
915
|
default:
|
|
916
|
-
return `${n}×10${
|
|
916
|
+
return `${n}×10${transferNumberToSupUniCode(String(exp))}`;
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
|
-
|
|
920
|
-
|
|
919
|
+
const supMap = Object.assign(Object.assign({}, Array.from('⁰¹²³⁴⁵⁶⁷⁸⁹')), { '-': '⁻', '+': '⁺' });
|
|
920
|
+
function transferNumberToSupUniCode(n) {
|
|
921
921
|
return Array.from(n)
|
|
922
|
-
.map((s) => (
|
|
922
|
+
.map((s) => (supMap[s] ? supMap[s] : s))
|
|
923
923
|
.join('');
|
|
924
924
|
}
|
|
925
925
|
|
|
@@ -1827,6 +1827,14 @@ function camelCase(str, options) {
|
|
|
1827
1827
|
});
|
|
1828
1828
|
}
|
|
1829
1829
|
|
|
1830
|
+
function constantCase(str, options) {
|
|
1831
|
+
const { keepNumber = true } = options || {};
|
|
1832
|
+
let tokens = _splitVar(str);
|
|
1833
|
+
if (!keepNumber)
|
|
1834
|
+
tokens = tokens.filter(({ number }) => !number);
|
|
1835
|
+
return _caseConvert(tokens, '_', ({ code }) => code.toUpperCase());
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1830
1838
|
function kebabCase(str, options) {
|
|
1831
1839
|
const { keepLetterCase = false, keepNumber = true } = options || {};
|
|
1832
1840
|
let tokens = _splitVar(str);
|
|
@@ -2771,6 +2779,7 @@ exports.chinaNumerals = chinaNumerals;
|
|
|
2771
2779
|
exports.chunk = chunk;
|
|
2772
2780
|
exports.clamp = clamp;
|
|
2773
2781
|
exports.compose = compose;
|
|
2782
|
+
exports.constantCase = constantCase;
|
|
2774
2783
|
exports.curry = _curryMore;
|
|
2775
2784
|
exports.dataUrlToBlob = dataUrlToBlob;
|
|
2776
2785
|
exports.debounce = debounce;
|
|
@@ -2878,6 +2887,7 @@ exports.snakeCase = snakeCase;
|
|
|
2878
2887
|
exports.splitWords = splitWords;
|
|
2879
2888
|
exports.throttle = throttle;
|
|
2880
2889
|
exports.titleCase = titleCase;
|
|
2890
|
+
exports.transferNumberToSupUniCode = transferNumberToSupUniCode;
|
|
2881
2891
|
exports.tryit = tryit;
|
|
2882
2892
|
exports.ulid = ulid;
|
|
2883
2893
|
exports.uncapitalize = uncapitalize;
|
package/lib/index.d.ts
CHANGED
|
@@ -1321,6 +1321,22 @@ declare function scientificNotation(num: string | number, options?: {
|
|
|
1321
1321
|
precision?: number;
|
|
1322
1322
|
round?: 'round' | 'banker' | 'floor' | 'ceil';
|
|
1323
1323
|
}): string;
|
|
1324
|
+
/**
|
|
1325
|
+
* 将数字字符串转换为上标 Unicode 字符串\
|
|
1326
|
+
* 无法处理的字符将原样返回\
|
|
1327
|
+
* 此方法在 0.3.3 版本就已存在, 但直到 0.3.8 版本才对外公开
|
|
1328
|
+
* @param n 数字字符串(可以带加减号)
|
|
1329
|
+
* @returns 上标 Unicode 字符串
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```js
|
|
1332
|
+
* transferNumberToSupUniCode("123") // "¹²³"
|
|
1333
|
+
* transferNumberToSupUniCode("-45") // "⁻⁴⁵"
|
|
1334
|
+
* transferNumberToSupUniCode("+67") // "⁺⁶⁷"
|
|
1335
|
+
* transferNumberToSupUniCode("123 + 456") // "¹²³ ⁺ ⁴⁵⁶"
|
|
1336
|
+
* ```
|
|
1337
|
+
* @version 0.3.8
|
|
1338
|
+
*/
|
|
1339
|
+
declare function transferNumberToSupUniCode(n: ArrayLike<string>): string;
|
|
1324
1340
|
|
|
1325
1341
|
/**
|
|
1326
1342
|
* 根据文件名称判断是否匹配支持的文件类型,需要注意 `.C` 与 `.c` 的区别
|
|
@@ -1578,6 +1594,24 @@ declare function camelCase(str: string, options?: {
|
|
|
1578
1594
|
keepNumber?: boolean;
|
|
1579
1595
|
}): string;
|
|
1580
1596
|
|
|
1597
|
+
/**
|
|
1598
|
+
* 将输入的字符串处理成常量格式(全大写下划线分割)
|
|
1599
|
+
* @param str 想要转换的字符串
|
|
1600
|
+
* @param options.keepNumber 是否保留数字, 默认保留
|
|
1601
|
+
* @returns 转换为常量格式的字符串
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```js
|
|
1604
|
+
* // 默认情况 保留数字
|
|
1605
|
+
* constantCase("getTestUuid1234") // "GET_TEST_UUID_1234"
|
|
1606
|
+
* // 不保留数字
|
|
1607
|
+
* constantCase("getTestUuid1234", { keepNumber: false }) // "GET_TEST_UUID"
|
|
1608
|
+
* ```
|
|
1609
|
+
* @version 0.3.8
|
|
1610
|
+
*/
|
|
1611
|
+
declare function constantCase(str: string, options?: {
|
|
1612
|
+
keepNumber?: boolean;
|
|
1613
|
+
}): string;
|
|
1614
|
+
|
|
1581
1615
|
/**
|
|
1582
1616
|
* 将输入的字符串处理成串行格式(短横线分割)
|
|
1583
1617
|
* @param str 想要转换的字符串
|
|
@@ -2623,5 +2657,5 @@ declare function throttle<T extends any[]>(fn: (...args: T) => any, delay: numbe
|
|
|
2623
2657
|
reset: () => void;
|
|
2624
2658
|
};
|
|
2625
2659
|
|
|
2626
|
-
export { $$Empty, _, acceptableFileName, acceptableFileType, base64ToBlob, blobToBase64, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chinaNumerals, chunk, clamp, compose, _curryMore as curry, dataUrlToBlob, debounce, decimalNotation, decodeBase64, dedent, deepClone, deepMerge, defer, deprecate, encodeBase64, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, uuidV7, withResolvers };
|
|
2660
|
+
export { $$Empty, _, acceptableFileName, acceptableFileType, base64ToBlob, blobToBase64, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chinaNumerals, chunk, clamp, compose, constantCase, _curryMore as curry, dataUrlToBlob, debounce, decimalNotation, decodeBase64, dedent, deepClone, deepMerge, defer, deprecate, encodeBase64, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, transferNumberToSupUniCode, tryit, ulid, uncapitalize, uuidNil, uuidV4, uuidV7, withResolvers };
|
|
2627
2661
|
export type { BaseMargeType, CastArray, Chunked, CloneOptions, CustomCloner, IsNegative, IsPositive, IsZero, MergeOption, MergeStrategy, MergeStrategyFunction, MergeType, MergeTypeStrategy, Not, RangeOptions, SourceMergeType, Stringify, TargetMergeType, TypedArray };
|
package/lib/index.mjs
CHANGED
|
@@ -449,7 +449,7 @@ function decimalNotation(num) {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
function chinaNumerals(num, options) {
|
|
452
|
-
var _a, _b
|
|
452
|
+
var _a, _b;
|
|
453
453
|
const str = decimalNotation(num);
|
|
454
454
|
if (/NaN|Inf/.test(str))
|
|
455
455
|
return str;
|
|
@@ -528,15 +528,15 @@ function chinaNumerals(num, options) {
|
|
|
528
528
|
const result = parts.join('').replace(zeroRegex, zeroChar).replace(trailingZeroRegex, '');
|
|
529
529
|
integerPart = result === '' ? numberChar[0] : result;
|
|
530
530
|
}
|
|
531
|
+
integerPart += (_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '';
|
|
531
532
|
return fractional
|
|
532
533
|
? integerPart +
|
|
533
|
-
((_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '') +
|
|
534
534
|
((_b = options === null || options === void 0 ? void 0 : options.dot) !== null && _b !== void 0 ? _b : '点') +
|
|
535
535
|
fractional
|
|
536
536
|
.split('')
|
|
537
537
|
.map((d, i) => { var _a, _b; return numberChar[Number(d)] + ((_b = (_a = options === null || options === void 0 ? void 0 : options.fractionalUnits) === null || _a === void 0 ? void 0 : _a[i]) !== null && _b !== void 0 ? _b : ''); })
|
|
538
538
|
.join('')
|
|
539
|
-
: integerPart
|
|
539
|
+
: integerPart;
|
|
540
540
|
}
|
|
541
541
|
function getNormalUnits(units, index) {
|
|
542
542
|
if (index === 0)
|
|
@@ -911,13 +911,13 @@ function scientificNotation(num, options) {
|
|
|
911
911
|
return `{"number":"${n}","exp":${exp}}`;
|
|
912
912
|
case 'unicode':
|
|
913
913
|
default:
|
|
914
|
-
return `${n}×10${
|
|
914
|
+
return `${n}×10${transferNumberToSupUniCode(String(exp))}`;
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
|
-
|
|
918
|
-
|
|
917
|
+
const supMap = Object.assign(Object.assign({}, Array.from('⁰¹²³⁴⁵⁶⁷⁸⁹')), { '-': '⁻', '+': '⁺' });
|
|
918
|
+
function transferNumberToSupUniCode(n) {
|
|
919
919
|
return Array.from(n)
|
|
920
|
-
.map((s) => (
|
|
920
|
+
.map((s) => (supMap[s] ? supMap[s] : s))
|
|
921
921
|
.join('');
|
|
922
922
|
}
|
|
923
923
|
|
|
@@ -1825,6 +1825,14 @@ function camelCase(str, options) {
|
|
|
1825
1825
|
});
|
|
1826
1826
|
}
|
|
1827
1827
|
|
|
1828
|
+
function constantCase(str, options) {
|
|
1829
|
+
const { keepNumber = true } = options || {};
|
|
1830
|
+
let tokens = _splitVar(str);
|
|
1831
|
+
if (!keepNumber)
|
|
1832
|
+
tokens = tokens.filter(({ number }) => !number);
|
|
1833
|
+
return _caseConvert(tokens, '_', ({ code }) => code.toUpperCase());
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1828
1836
|
function kebabCase(str, options) {
|
|
1829
1837
|
const { keepLetterCase = false, keepNumber = true } = options || {};
|
|
1830
1838
|
let tokens = _splitVar(str);
|
|
@@ -2750,4 +2758,4 @@ function throttle(fn, delay, options) {
|
|
|
2750
2758
|
return _throttle(fn, delay, Object.assign({ trailing: false, leading: true }, options));
|
|
2751
2759
|
}
|
|
2752
2760
|
|
|
2753
|
-
export { $$Empty, _, acceptableFileName, acceptableFileType, base64ToBlob, blobToBase64, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chinaNumerals, chunk, clamp, compose, _curryMore as curry, dataUrlToBlob, debounce, decimalNotation, decodeBase64, dedent, deepClone, deepMerge, defer, deprecate, encodeBase64, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, uuidV7, withResolvers };
|
|
2761
|
+
export { $$Empty, _, acceptableFileName, acceptableFileType, base64ToBlob, blobToBase64, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chinaNumerals, chunk, clamp, compose, constantCase, _curryMore as curry, dataUrlToBlob, debounce, decimalNotation, decodeBase64, dedent, deepClone, deepMerge, defer, deprecate, encodeBase64, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, transferNumberToSupUniCode, tryit, ulid, uncapitalize, uuidNil, uuidV4, uuidV7, withResolvers };
|
package/lib/index.umd.js
CHANGED
|
@@ -455,7 +455,7 @@ See the Mulan PSL v2 for more details.
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
function chinaNumerals(num, options) {
|
|
458
|
-
var _a, _b
|
|
458
|
+
var _a, _b;
|
|
459
459
|
const str = decimalNotation(num);
|
|
460
460
|
if (/NaN|Inf/.test(str))
|
|
461
461
|
return str;
|
|
@@ -534,15 +534,15 @@ See the Mulan PSL v2 for more details.
|
|
|
534
534
|
const result = parts.join('').replace(zeroRegex, zeroChar).replace(trailingZeroRegex, '');
|
|
535
535
|
integerPart = result === '' ? numberChar[0] : result;
|
|
536
536
|
}
|
|
537
|
+
integerPart += (_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '';
|
|
537
538
|
return fractional
|
|
538
539
|
? integerPart +
|
|
539
|
-
((_a = options === null || options === void 0 ? void 0 : options.integerUnit) !== null && _a !== void 0 ? _a : '') +
|
|
540
540
|
((_b = options === null || options === void 0 ? void 0 : options.dot) !== null && _b !== void 0 ? _b : '点') +
|
|
541
541
|
fractional
|
|
542
542
|
.split('')
|
|
543
543
|
.map((d, i) => { var _a, _b; return numberChar[Number(d)] + ((_b = (_a = options === null || options === void 0 ? void 0 : options.fractionalUnits) === null || _a === void 0 ? void 0 : _a[i]) !== null && _b !== void 0 ? _b : ''); })
|
|
544
544
|
.join('')
|
|
545
|
-
: integerPart
|
|
545
|
+
: integerPart;
|
|
546
546
|
}
|
|
547
547
|
function getNormalUnits(units, index) {
|
|
548
548
|
if (index === 0)
|
|
@@ -917,13 +917,13 @@ See the Mulan PSL v2 for more details.
|
|
|
917
917
|
return `{"number":"${n}","exp":${exp}}`;
|
|
918
918
|
case 'unicode':
|
|
919
919
|
default:
|
|
920
|
-
return `${n}×10${
|
|
920
|
+
return `${n}×10${transferNumberToSupUniCode(String(exp))}`;
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
|
|
924
|
-
|
|
923
|
+
const supMap = Object.assign(Object.assign({}, Array.from('⁰¹²³⁴⁵⁶⁷⁸⁹')), { '-': '⁻', '+': '⁺' });
|
|
924
|
+
function transferNumberToSupUniCode(n) {
|
|
925
925
|
return Array.from(n)
|
|
926
|
-
.map((s) => (
|
|
926
|
+
.map((s) => (supMap[s] ? supMap[s] : s))
|
|
927
927
|
.join('');
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -1831,6 +1831,14 @@ See the Mulan PSL v2 for more details.
|
|
|
1831
1831
|
});
|
|
1832
1832
|
}
|
|
1833
1833
|
|
|
1834
|
+
function constantCase(str, options) {
|
|
1835
|
+
const { keepNumber = true } = options || {};
|
|
1836
|
+
let tokens = _splitVar(str);
|
|
1837
|
+
if (!keepNumber)
|
|
1838
|
+
tokens = tokens.filter(({ number }) => !number);
|
|
1839
|
+
return _caseConvert(tokens, '_', ({ code }) => code.toUpperCase());
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1834
1842
|
function kebabCase(str, options) {
|
|
1835
1843
|
const { keepLetterCase = false, keepNumber = true } = options || {};
|
|
1836
1844
|
let tokens = _splitVar(str);
|
|
@@ -2775,6 +2783,7 @@ See the Mulan PSL v2 for more details.
|
|
|
2775
2783
|
exports.chunk = chunk;
|
|
2776
2784
|
exports.clamp = clamp;
|
|
2777
2785
|
exports.compose = compose;
|
|
2786
|
+
exports.constantCase = constantCase;
|
|
2778
2787
|
exports.curry = _curryMore;
|
|
2779
2788
|
exports.dataUrlToBlob = dataUrlToBlob;
|
|
2780
2789
|
exports.debounce = debounce;
|
|
@@ -2882,6 +2891,7 @@ See the Mulan PSL v2 for more details.
|
|
|
2882
2891
|
exports.splitWords = splitWords;
|
|
2883
2892
|
exports.throttle = throttle;
|
|
2884
2893
|
exports.titleCase = titleCase;
|
|
2894
|
+
exports.transferNumberToSupUniCode = transferNumberToSupUniCode;
|
|
2885
2895
|
exports.tryit = tryit;
|
|
2886
2896
|
exports.ulid = ulid;
|
|
2887
2897
|
exports.uncapitalize = uncapitalize;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foreslash",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Foreslash is a Javascript utilities lib which contains plenty of practical functions.",
|
|
5
5
|
"author": "moushu",
|
|
6
6
|
"license": "Mulan PSL v2",
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "rollup -c -w",
|
|
37
37
|
"build": "rollup -c",
|
|
38
|
-
"
|
|
39
|
-
"test
|
|
38
|
+
"tsd": "tsd --files /test/**/*.test-d.ts",
|
|
39
|
+
"test": "jest --coverage",
|
|
40
|
+
"test:slow": "jest --coverage --runInBand",
|
|
40
41
|
"prepublishOnly": "jest --coverage && npm run build",
|
|
41
42
|
"docs:dev": "rollup -c && vitepress dev docs",
|
|
42
43
|
"docs:build": "rollup -c && vitepress build docs",
|