@vitest/utils 4.1.0-beta.5 → 4.1.0
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 +7 -0
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.js +15 -1
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @vitest/utils
|
|
2
|
+
|
|
3
|
+
[](https://npmx.dev/package/@vitest/utils)
|
|
4
|
+
|
|
5
|
+
Internal shared utilities used by other Vitest packages.
|
|
6
|
+
|
|
7
|
+
[GitHub](https://github.com/vitest-dev/vitest/tree/main/packages/utils) | [Documentation](https://vitest.dev/)
|
package/dist/helpers.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ declare function createDefer<T>(): DeferPromise<T>;
|
|
|
61
61
|
*/
|
|
62
62
|
declare function getCallLastIndex(code: string): number | null;
|
|
63
63
|
declare function isNegativeNaN(val: number): boolean;
|
|
64
|
+
declare function ordinal(i: number): string;
|
|
64
65
|
/**
|
|
65
66
|
* Deep merge :P
|
|
66
67
|
*
|
|
@@ -71,5 +72,5 @@ declare function isNegativeNaN(val: number): boolean;
|
|
|
71
72
|
declare function deepMerge<T extends object = object>(target: T, ...sources: any[]): T;
|
|
72
73
|
declare function unique<T>(array: T[]): T[];
|
|
73
74
|
|
|
74
|
-
export { assertTypes, cleanUrl, clone, createDefer, createSimpleStackTrace, deepClone, deepMerge, filterOutComments, getCallLastIndex, getOwnProperties, getType, isBareImport, isExternalUrl, isNegativeNaN, isObject, isPrimitive, nanoid, noop, notNullish, objectAttr, shuffle, slash, toArray, unique, unwrapId, withTrailingSlash, wrapId };
|
|
75
|
+
export { assertTypes, cleanUrl, clone, createDefer, createSimpleStackTrace, deepClone, deepMerge, filterOutComments, getCallLastIndex, getOwnProperties, getType, isBareImport, isExternalUrl, isNegativeNaN, isObject, isPrimitive, nanoid, noop, notNullish, objectAttr, ordinal, shuffle, slash, toArray, unique, unwrapId, withTrailingSlash, wrapId };
|
|
75
76
|
export type { DeferPromise };
|
package/dist/helpers.js
CHANGED
|
@@ -286,6 +286,20 @@ function isPlainObject(val) {
|
|
|
286
286
|
function isMergeableObject(item) {
|
|
287
287
|
return isPlainObject(item) && !Array.isArray(item);
|
|
288
288
|
}
|
|
289
|
+
function ordinal(i) {
|
|
290
|
+
const j = i % 10;
|
|
291
|
+
const k = i % 100;
|
|
292
|
+
if (j === 1 && k !== 11) {
|
|
293
|
+
return `${i}st`;
|
|
294
|
+
}
|
|
295
|
+
if (j === 2 && k !== 12) {
|
|
296
|
+
return `${i}nd`;
|
|
297
|
+
}
|
|
298
|
+
if (j === 3 && k !== 13) {
|
|
299
|
+
return `${i}rd`;
|
|
300
|
+
}
|
|
301
|
+
return `${i}th`;
|
|
302
|
+
}
|
|
289
303
|
/**
|
|
290
304
|
* Deep merge :P
|
|
291
305
|
*
|
|
@@ -320,4 +334,4 @@ function unique(array) {
|
|
|
320
334
|
return Array.from(new Set(array));
|
|
321
335
|
}
|
|
322
336
|
|
|
323
|
-
export { assertTypes, cleanUrl, clone, createDefer, createSimpleStackTrace, deepClone, deepMerge, filterOutComments, getCallLastIndex, getOwnProperties, getType, isBareImport, isExternalUrl, isNegativeNaN, isObject, isPrimitive, nanoid, noop, notNullish, objectAttr, shuffle, slash, toArray, unique, unwrapId, withTrailingSlash, wrapId };
|
|
337
|
+
export { assertTypes, cleanUrl, clone, createDefer, createSimpleStackTrace, deepClone, deepMerge, filterOutComments, getCallLastIndex, getOwnProperties, getType, isBareImport, isExternalUrl, isNegativeNaN, isObject, isPrimitive, nanoid, noop, notNullish, objectAttr, ordinal, shuffle, slash, toArray, unique, unwrapId, withTrailingSlash, wrapId };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"description": "Shared Vitest utility functions",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
8
|
-
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/utils
|
|
8
|
+
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/utils",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/vitest-dev/vitest.git",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"convert-source-map": "^2.0.0",
|
|
88
88
|
"tinyrainbow": "^3.0.3",
|
|
89
|
-
"@vitest/pretty-format": "4.1.0
|
|
89
|
+
"@vitest/pretty-format": "4.1.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@jridgewell/trace-mapping": "0.3.31",
|