Files
TestMesa/backend/frontend/node_modules/tcomb/lib/decompose.js
2024-12-17 14:36:15 -08:00

26 lines
529 B
JavaScript

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;