MCPcopy
hub / github.com/vitest-dev/vitest / toArray

Function toArray

packages/utils/src/helpers.ts:142–152  ·  view source on GitHub ↗
(array?: Nullable<Arrayable<T>>)

Source from the content-addressed store, hash-verified

140}
141
142export function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {
143 if (array === null || array === undefined) {
144 array = []
145 }
146
147 if (Array.isArray(array)) {
148 return array
149 }
150
151 return [array]
152}
153
154export function isObject(item: unknown): boolean {
155 return item != null && typeof item === 'object' && !Array.isArray(item)

Callers 15

configFunction · 0.90
collectTestsFunction · 0.90
taskFunction · 0.90
initSuiteFunction · 0.90
createSuiteFunction · 0.90
createTaskCollectorFunction · 0.90
getTestsFunction · 0.90
getTasksFunction · 0.90
getSuitesFunction · 0.90
hasTestsFunction · 0.90
hasFailedFunction · 0.90
testsCollectorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected