foreslash 0.3.4 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Change Log
2
2
 
3
- ## Version 0.3.4 - 2025-11-
3
+ ## Version 0.3.5 - 2025-11-30
4
+
5
+ Unstable version
6
+
7
+ - Feat 🥥 Functions added: `uuidV7`
8
+ - Feat 🥥 Function change: `isOdd` and `isEven` now support BigInt
9
+ - Fix 🥕 Document: Added version tags to several methods
10
+ - Other fixes and improvements
11
+
12
+ 不稳定版本
13
+
14
+ - 功能 🥥 添加函数: `uuidV7`
15
+ - 功能 🥥 变更函数: `isOdd` 和 `isEven` 现在支持 BigInt
16
+ - 修复 🥕 文档: 补充部分方法的版本标签
17
+ - 其他修复与优化
18
+
19
+ ## Version 0.3.4 - 2025-11-17
4
20
 
5
21
  Unstable version
6
22
 
package/lib/index.cmn.cjs CHANGED
@@ -468,10 +468,10 @@ function decimalNotation(num) {
468
468
  }
469
469
 
470
470
  function isOdd(num) {
471
- return !!(num & 1);
471
+ return !!(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
472
472
  }
473
473
  function isEven(num) {
474
- return !(num & 1);
474
+ return !(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
475
475
  }
476
476
 
477
477
  function round(num, precision, type) {
@@ -1607,6 +1607,15 @@ function uuidV4() {
1607
1607
  return (`${r.slice(0, 8)}-${r.slice(8, 12)}-4${r.slice(12, 15)}-` +
1608
1608
  `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(15, 18)}-${r.slice(18)}`);
1609
1609
  }
1610
+ function uuidV7() {
1611
+ const r = randomHexString(18);
1612
+ let t = Date.now().toString(16);
1613
+ if (t.length < 12)
1614
+ t = '0'.repeat(12 - t.length) + t;
1615
+ t = t.slice(t.length - 12, t.length);
1616
+ return (`${t.slice(0, 8)}-${t.slice(8, 12)}-7${r.slice(0, 3)}-` +
1617
+ `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(3, 6)}-${r.slice(6)}`);
1618
+ }
1610
1619
 
1611
1620
  const getDefaultVarCase = () => ({ code: '', upperCase: false, number: false });
1612
1621
  const isUpperCase = RegExp.prototype.test.bind(/[A-Z]/);
@@ -2694,4 +2703,5 @@ exports.ulid = ulid;
2694
2703
  exports.uncapitalize = uncapitalize;
2695
2704
  exports.uuidNil = uuidNil;
2696
2705
  exports.uuidV4 = uuidV4;
2706
+ exports.uuidV7 = uuidV7;
2697
2707
  exports.withResolvers = withResolvers;
package/lib/index.d.ts CHANGED
@@ -1031,14 +1031,14 @@ declare function format(num: number | string, options?: {
1031
1031
  * @returns 如果是奇数则返回 true 否则返回 false
1032
1032
  * @version 0.3.2
1033
1033
  */
1034
- declare function isOdd(num: number): boolean;
1034
+ declare function isOdd(num: number | bigint): boolean;
1035
1035
  /**
1036
1036
  * 检查一个数字是否为偶数
1037
1037
  * @param num 需要检查的数字
1038
1038
  * @returns 如果是偶数则返回 true 否则返回 false
1039
1039
  * @version 0.3.2
1040
1040
  */
1041
- declare function isEven(num: number): boolean;
1041
+ declare function isEven(num: number | bigint): boolean;
1042
1042
 
1043
1043
  /**
1044
1044
  * 用线性插值法求取一个中间值
@@ -1456,6 +1456,7 @@ declare function randomBase32String(length: number, isCrockford?: boolean): stri
1456
1456
  * shuffle('abcdefg') // ['d', 'e', 'a', 'c', 'g', 'f', 'b']
1457
1457
  * shuffle([1, 2, 3, 4, 5, 6, 7, 8]) // [3, 2, 6, 5, 8, 1, 7, 4]
1458
1458
  * ```
1459
+ * @version 0.1.1
1459
1460
  */
1460
1461
  declare function shuffle<T>(arr: ArrayLike<T> | Iterable<T>): Array<T>;
1461
1462
 
@@ -1474,20 +1475,32 @@ declare function shuffle<T>(arr: ArrayLike<T> | Iterable<T>): Array<T>;
1474
1475
  * ulid(true, 0) // 0000000000D64N3ZR75CXM1J83 同一时间戳单调递增
1475
1476
  * ulid(false, 0) // 0000000000Z3VJ5THVXV4ZE6CO 取消单调性
1476
1477
  * ```
1478
+ * @version 0.1.2
1477
1479
  */
1478
1480
  declare function ulid(monotonic?: boolean, time?: number): string;
1479
1481
 
1480
- /** 空 UUID [见标准第 4.1.7 节](https://www.ietf.org/rfc/rfc4122.txt) */
1482
+ /** 空 UUID [见标准第 5.9 节](https://www.rfc-editor.org/rfc/rfc9562.html#name-nil-uuid) */
1481
1483
  declare const uuidNil = "00000000-0000-0000-0000-000000000000";
1482
1484
  /**
1483
- * 生成 [UUID V4](https://www.ietf.org/rfc/rfc4122.txt) 字符串(小写)
1484
- * @returns 一个标准的 UUID V4 字符串
1485
+ * 生成 [UUID V4](https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-4) 字符串(小写)
1486
+ * @returns 一个 RFC 9562 标准的 UUID V4 字符串
1485
1487
  * @example
1486
1488
  * ```js
1487
1489
  * uuidV4() // "ea64fb4f-a0a2-4193-8374-d291a522d8b3"
1488
1490
  * ```
1491
+ * @version 0.1.2
1489
1492
  */
1490
1493
  declare function uuidV4(): string;
1494
+ /**
1495
+ * 生成 [UUID V7](https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-7) 字符串(小写)
1496
+ * @returns 一个 RFC 9562 标准的 UUID V7 字符串
1497
+ * @example
1498
+ * ```js
1499
+ * uuidV7() // "019aba02-45ad-703c-a17e-05f8d7ebe357"
1500
+ * ```
1501
+ * @version 0.3.4
1502
+ */
1503
+ declare function uuidV7(): string;
1491
1504
 
1492
1505
  /**
1493
1506
  * 将输入的字符串处理成小驼峰格式
@@ -2459,5 +2472,5 @@ declare function throttle<T extends any[]>(fn: (...args: T) => any, delay: numbe
2459
2472
  reset: () => void;
2460
2473
  };
2461
2474
 
2462
- export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, 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, withResolvers };
2475
+ export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, 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 };
2463
2476
  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
@@ -466,10 +466,10 @@ function decimalNotation(num) {
466
466
  }
467
467
 
468
468
  function isOdd(num) {
469
- return !!(num & 1);
469
+ return !!(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
470
470
  }
471
471
  function isEven(num) {
472
- return !(num & 1);
472
+ return !(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
473
473
  }
474
474
 
475
475
  function round(num, precision, type) {
@@ -1605,6 +1605,15 @@ function uuidV4() {
1605
1605
  return (`${r.slice(0, 8)}-${r.slice(8, 12)}-4${r.slice(12, 15)}-` +
1606
1606
  `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(15, 18)}-${r.slice(18)}`);
1607
1607
  }
1608
+ function uuidV7() {
1609
+ const r = randomHexString(18);
1610
+ let t = Date.now().toString(16);
1611
+ if (t.length < 12)
1612
+ t = '0'.repeat(12 - t.length) + t;
1613
+ t = t.slice(t.length - 12, t.length);
1614
+ return (`${t.slice(0, 8)}-${t.slice(8, 12)}-7${r.slice(0, 3)}-` +
1615
+ `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(3, 6)}-${r.slice(6)}`);
1616
+ }
1608
1617
 
1609
1618
  const getDefaultVarCase = () => ({ code: '', upperCase: false, number: false });
1610
1619
  const isUpperCase = RegExp.prototype.test.bind(/[A-Z]/);
@@ -2568,4 +2577,4 @@ function throttle(fn, delay, options) {
2568
2577
  return _throttle(fn, delay, Object.assign({ trailing: false, leading: true }, options));
2569
2578
  }
2570
2579
 
2571
- export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, 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, withResolvers };
2580
+ export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, 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 };
package/lib/index.umd.js CHANGED
@@ -472,10 +472,10 @@ See the Mulan PSL v2 for more details.
472
472
  }
473
473
 
474
474
  function isOdd(num) {
475
- return !!(num & 1);
475
+ return !!(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
476
476
  }
477
477
  function isEven(num) {
478
- return !(num & 1);
478
+ return !(typeof num === 'bigint' ? num & BigInt(1) : num & 1);
479
479
  }
480
480
 
481
481
  function round(num, precision, type) {
@@ -1611,6 +1611,15 @@ See the Mulan PSL v2 for more details.
1611
1611
  return (`${r.slice(0, 8)}-${r.slice(8, 12)}-4${r.slice(12, 15)}-` +
1612
1612
  `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(15, 18)}-${r.slice(18)}`);
1613
1613
  }
1614
+ function uuidV7() {
1615
+ const r = randomHexString(18);
1616
+ let t = Date.now().toString(16);
1617
+ if (t.length < 12)
1618
+ t = '0'.repeat(12 - t.length) + t;
1619
+ t = t.slice(t.length - 12, t.length);
1620
+ return (`${t.slice(0, 8)}-${t.slice(8, 12)}-7${r.slice(0, 3)}-` +
1621
+ `${'89ab'[Math.floor(Math.random() * 4)]}${r.slice(3, 6)}-${r.slice(6)}`);
1622
+ }
1614
1623
 
1615
1624
  const getDefaultVarCase = () => ({ code: '', upperCase: false, number: false });
1616
1625
  const isUpperCase = RegExp.prototype.test.bind(/[A-Z]/);
@@ -2698,6 +2707,7 @@ See the Mulan PSL v2 for more details.
2698
2707
  exports.uncapitalize = uncapitalize;
2699
2708
  exports.uuidNil = uuidNil;
2700
2709
  exports.uuidV4 = uuidV4;
2710
+ exports.uuidV7 = uuidV7;
2701
2711
  exports.withResolvers = withResolvers;
2702
2712
 
2703
2713
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreslash",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
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",