@vitest/utils
Advanced tools
Comparing version 0.28.5 to 0.29.0
@@ -5,2 +5,3 @@ import { Nullable, Arrayable } from './types.js'; | ||
declare function slash(path: string): string; | ||
declare function parseRegexp(input: string): RegExp; | ||
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>; | ||
@@ -20,2 +21,2 @@ declare function isObject(item: unknown): boolean; | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, slash, toArray }; | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray }; |
@@ -10,2 +10,10 @@ function assertTypes(value, name, types) { | ||
} | ||
function parseRegexp(input) { | ||
const m = input.match(/(\/?)(.+)\1([a-z]*)/i); | ||
if (!m) | ||
return /$^/; | ||
if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3])) | ||
return RegExp(input); | ||
return new RegExp(m[2], m[3]); | ||
} | ||
function toArray(array) { | ||
@@ -88,2 +96,2 @@ if (array === null || array === void 0) | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, slash, toArray }; | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray }; |
@@ -1,2 +0,2 @@ | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, slash, toArray } from './helpers.js'; | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
export { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, MergeInsertions, MutableArray, Nullable } from './types.js'; | ||
@@ -11,2 +11,3 @@ import { PrettyFormatOptions } from 'pretty-format'; | ||
declare function getSafeTimers(): { | ||
nextTick: any; | ||
setTimeout: any; | ||
@@ -16,2 +17,4 @@ setInterval: any; | ||
clearTimeout: any; | ||
setImmediate: any; | ||
clearImmediate: any; | ||
}; | ||
@@ -18,0 +21,0 @@ declare function setSafeTimers(): void; |
@@ -1,2 +0,2 @@ | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, slash, toArray } from './helpers.js'; | ||
export { assertTypes, clone, createDefer, deepClone, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
import { format as format$1, plugins } from 'pretty-format'; | ||
@@ -52,9 +52,17 @@ import util from 'util'; | ||
clearInterval: safeClearInterval, | ||
clearTimeout: safeClearTimeout | ||
clearTimeout: safeClearTimeout, | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
} = globalThis[SAFE_TIMERS_SYMBOL] || globalThis; | ||
const { | ||
nextTick: safeNextTick | ||
} = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || { nextTick: (cb) => cb() }; | ||
return { | ||
nextTick: safeNextTick, | ||
setTimeout: safeSetTimeout, | ||
setInterval: safeSetInterval, | ||
clearInterval: safeClearInterval, | ||
clearTimeout: safeClearTimeout | ||
clearTimeout: safeClearTimeout, | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
}; | ||
@@ -67,9 +75,17 @@ } | ||
clearInterval: safeClearInterval, | ||
clearTimeout: safeClearTimeout | ||
clearTimeout: safeClearTimeout, | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
} = globalThis; | ||
const { | ||
nextTick: safeNextTick | ||
} = globalThis.process || { nextTick: (cb) => cb() }; | ||
const timers = { | ||
nextTick: safeNextTick, | ||
setTimeout: safeSetTimeout, | ||
setInterval: safeSetInterval, | ||
clearInterval: safeClearInterval, | ||
clearTimeout: safeClearTimeout | ||
clearTimeout: safeClearTimeout, | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
}; | ||
@@ -76,0 +92,0 @@ globalThis[SAFE_TIMERS_SYMBOL] = timers; |
{ | ||
"name": "@vitest/utils", | ||
"type": "module", | ||
"version": "0.28.5", | ||
"version": "0.29.0", | ||
"description": "Shared Vitest utility functions", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17428
466