Skip to content

Commit 6cf7d84

Browse files
committed
feat(defaults): allow default impls without arrays in defs
1 parent 16ad124 commit 6cf7d84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ function define (types, spec, opts) {
125125
}
126126

127127
function checkMethodSpec (duck, name, spec) {
128-
const gfTypes = spec[name]
129-
if (typeof gfTypes[gfTypes.length - 1] === 'function') {
128+
let gfTypes = spec[name]
129+
if (typeof gfTypes === 'function') {
130+
duck._defaultImpls[name] = gfTypes
131+
gfTypes = [gfTypes]
132+
} if (typeof gfTypes[gfTypes.length - 1] === 'function') {
130133
duck._defaultImpls[name] = gfTypes.pop()
131134
} else {
132135
duck.isDerivable = false

0 commit comments

Comments
 (0)