Skip to content

Commit f337c9b

Browse files
committed
fix(utils): [clone] Clone is not a constructor
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 66c9298 commit f337c9b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

__tests__/reporters/notifier.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @module tests/reporters/Notifier
44
*/
55

6-
import { isArray, type OneOrMany } from '#src'
6+
import { cast, isArray, type OneOrMany } from '#src'
77
import notifier from 'node-notifier'
88
import type NotificationCenter from 'node-notifier/notifiers/notificationcenter'
99
import { performance } from 'node:perf_hooks'
@@ -162,7 +162,7 @@ class Notifier implements Reporter {
162162
}
163163

164164
/**
165-
* Returns an array of {@link Test} objects.
165+
* Returns an array of {@linkcode Test} objects.
166166
*
167167
* @protected
168168
*
@@ -172,7 +172,7 @@ class Notifier implements Reporter {
172172
protected tests(tasks: OneOrMany<Task> = []): Test[] {
173173
return (isArray<Task>(tasks) ? tasks : [tasks]).flatMap(task => {
174174
return task.type === 'custom'
175-
? [task as unknown as Test]
175+
? [cast(task)]
176176
: task.type === 'test'
177177
? [task]
178178
: 'tasks' in task

src/utils/clone.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Class, Optional } from '#src/types'
77
import cast from './cast'
88
import define from './define'
99
import descriptor from './descriptor'
10+
import ifelse from './ifelse'
1011
import isArray from './is-array'
1112
import isArrayBuffer from './is-array-buffer'
1213
import isBuffer from './is-buffer'
@@ -97,9 +98,9 @@ const clone = <T>(value: T): T => {
9798
}
9899

99100
// clone unknown value
100-
if (!cast<Optional<T>>(result)) result = new Clone()
101+
if (!cast<Optional<T>>(result) && isFunction(Clone)) result = new Clone()
101102

102-
return result
103+
return ifelse(result, result, cast({}))
103104
}
104105

105106
/**

0 commit comments

Comments
 (0)