diff --git a/packages/behavior/type.js b/packages/behavior/type.js index 3933cdc..b7fba87 100644 --- a/packages/behavior/type.js +++ b/packages/behavior/type.js @@ -82,15 +82,15 @@ export function description(type, instance) { const allTypes = types(); const defaults = { children: {}, - type, }; const splitTypes = type.split('|'); for (let i = 0; i < splitTypes.length; i++) { - const type = splitTypes[i]; - if (allTypes[type]) { + const splitType = splitTypes[i]; + if (allTypes[splitType]) { return { ...defaults, - ...('function' === typeof allTypes[type] ? allTypes[type](instance) : allTypes[type]) + type: splitType, + ...('function' === typeof allTypes[splitType] ? allTypes[splitType](instance) : allTypes[splitType]) }; } } @@ -100,16 +100,15 @@ export function description(type, instance) { }; } -export function fitsInto(candidate, reference) { +export function fitsInto(candidate, reference, eq = (l, r) => l === r) { const candidates = candidate.split('|'); - const references = candidate.split('|'); + const references = reference.split('|'); for (let i = 0; i < references.length; i++) { - if ('any' === references[i]) { + if (-1 !== ['any'].indexOf(references[i])) { return true; } for (let j = 0; j < candidates.length; j++) { - const refer = candidates[j]; - if (references[i] === candidates[j]) { + if (eq(references[i], candidates[j])) { return true; } }