es-toolkit 1.30.0 → 1.30.1-dev.968
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 +8 -0
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +7 -0
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/util/uniqueId.d.mts +25 -0
- package/dist/compat/util/uniqueId.d.ts +25 -0
- package/dist/compat/util/uniqueId.mjs +7 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -254,3 +254,4 @@ export { toPath } from './util/toPath.mjs';
|
|
|
254
254
|
export { toPlainObject } from './util/toPlainObject.mjs';
|
|
255
255
|
export { toSafeInteger } from './util/toSafeInteger.mjs';
|
|
256
256
|
export { toString } from './util/toString.mjs';
|
|
257
|
+
export { uniqueId } from './util/uniqueId.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -254,3 +254,4 @@ export { toPath } from './util/toPath.js';
|
|
|
254
254
|
export { toPlainObject } from './util/toPlainObject.js';
|
|
255
255
|
export { toSafeInteger } from './util/toSafeInteger.js';
|
|
256
256
|
export { toString } from './util/toString.js';
|
|
257
|
+
export { uniqueId } from './util/uniqueId.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -3008,6 +3008,12 @@ function toSafeInteger(value) {
|
|
|
3008
3008
|
return clamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
|
3009
3009
|
}
|
|
3010
3010
|
|
|
3011
|
+
let idCounter = 0;
|
|
3012
|
+
function uniqueId(prefix = '') {
|
|
3013
|
+
const id = ++idCounter;
|
|
3014
|
+
return `${prefix}${id}`;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3011
3017
|
exports.at = zipWith.at;
|
|
3012
3018
|
exports.countBy = zipWith.countBy;
|
|
3013
3019
|
exports.flatMap = zipWith.flatMap;
|
|
@@ -3261,6 +3267,7 @@ exports.unescape = unescape;
|
|
|
3261
3267
|
exports.union = union;
|
|
3262
3268
|
exports.uniq = uniq;
|
|
3263
3269
|
exports.uniqBy = uniqBy;
|
|
3270
|
+
exports.uniqueId = uniqueId;
|
|
3264
3271
|
exports.unset = unset;
|
|
3265
3272
|
exports.unzip = unzip;
|
|
3266
3273
|
exports.upperCase = upperCase;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -254,3 +254,4 @@ export { toPath } from './util/toPath.mjs';
|
|
|
254
254
|
export { toPlainObject } from './util/toPlainObject.mjs';
|
|
255
255
|
export { toSafeInteger } from './util/toSafeInteger.mjs';
|
|
256
256
|
export { toString } from './util/toString.mjs';
|
|
257
|
+
export { uniqueId } from './util/uniqueId.mjs';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique identifier, optionally prefixed with a given string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} [prefix] - An optional string to prefix the unique identifier.
|
|
5
|
+
* If not provided or not a string, only the unique
|
|
6
|
+
* numeric identifier is returned.
|
|
7
|
+
* @returns {string} A string containing the unique identifier, with the optional
|
|
8
|
+
* prefix if provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Generate a unique ID with a prefix
|
|
12
|
+
* uniqueId('user_'); // => 'user_1'
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Generate a unique ID without a prefix
|
|
16
|
+
* uniqueId(); // => '2'
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Subsequent calls increment the internal counter
|
|
20
|
+
* uniqueId('item_'); // => 'item_3'
|
|
21
|
+
* uniqueId(); // => '4'
|
|
22
|
+
*/
|
|
23
|
+
declare function uniqueId(prefix?: string): string;
|
|
24
|
+
|
|
25
|
+
export { uniqueId };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique identifier, optionally prefixed with a given string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} [prefix] - An optional string to prefix the unique identifier.
|
|
5
|
+
* If not provided or not a string, only the unique
|
|
6
|
+
* numeric identifier is returned.
|
|
7
|
+
* @returns {string} A string containing the unique identifier, with the optional
|
|
8
|
+
* prefix if provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Generate a unique ID with a prefix
|
|
12
|
+
* uniqueId('user_'); // => 'user_1'
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Generate a unique ID without a prefix
|
|
16
|
+
* uniqueId(); // => '2'
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Subsequent calls increment the internal counter
|
|
20
|
+
* uniqueId('item_'); // => 'item_3'
|
|
21
|
+
* uniqueId(); // => '4'
|
|
22
|
+
*/
|
|
23
|
+
declare function uniqueId(prefix?: string): string;
|
|
24
|
+
|
|
25
|
+
export { uniqueId };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.1-dev.968+becaac59",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|