var isType = require('./isType'); function isRefinement(type) { return isType(type) && type.meta.kind === 'subtype'; } function getPredicates(type) { return isRefinement(type) ? [type.meta.predicate].concat(getPredicates(type.meta.type)) : []; } function getUnrefinedType(type) { return isRefinement(type) ? getUnrefinedType(type.meta.type) : type; } function decompose(type) { return { predicates: getPredicates(type), unrefinedType: getUnrefinedType(type) }; } module.exports = decompose;