Repository URL to install this package:
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chain_able_deps_1 = require("chain-able-deps");
/**
* @param shape @alias specificationTransformations
* @return shape creation
*/
const makeShape = (shape) => {
const shapeKeys = chain_able_deps_1.keys(shape);
const specifications = chain_able_deps_1.preAllocate(shapeKeys);
const iteratee = (key, index) => {
specifications[index] = {
satisfies: (x, prop) => {
// shapeKeys[key]
return chain_able_deps_1.toTestable(key)(prop);
},
transform: shape[key],
};
};
chain_able_deps_1.forOwn(shapeKeys, iteratee);
const shaped = (value, key) => {
let evolved = false;
chain_able_deps_1.forOwn(specifications, specification => {
const { transform, satisfies } = specification;
if (satisfies(value, key)) {
evolved = transform(value, key);
// stop iterating - unless we want multiple transforms...
// return false
}
});
return evolved;
};
return shaped;
};
exports.makeShape = makeShape;
exports.default = makeShape;
//# sourceMappingURL=makeShape.js.map