Repository URL to install this package:
Version:
6.0.0-beta.8 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint complexity: "OFF" */
const chain_able_deps_1 = require("chain-able-deps");
// import recurse from 'chain-able-traverse'
const sortObj_1 = require("./sortObj");
function recurse(...args) {
console.warn('REQUIRES CHAIN-ABLE-TRAVERSE');
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// OPENS ALL THE DOORS TO API HANDLING
// /*, nestedSchema, input */
function toUniverseView(obj, onlyPrimitive = false, ordered = false, metadata = false) {
let stringPathObj = {};
const meta = {};
recurse(obj).forEach((value, key, recurser) => {
if (!key)
return;
// metadata
const stringPath = recurser.path.join('.');
meta[stringPath] = value;
// coerce to empty versions when we want them
// if (isNative(value) || isBuiltIn(value) || isTyped(value)) {
// // eslint-disable-next-line
// // debugger
// value = getEmpty(value)
// }
// else if (!isPrimitive(value)) {
// value = getEmpty(value)
// }
// add .length
// if (metadata && isObjPure(meta[stringPath])) {
// defineFinal(meta[stringPath], 'length', size(meta[stringPath]))
// defineFinal(meta[stringPath], 'keys', Object.keys(meta[stringPath]))
// }
// check options
if (onlyPrimitive && !chain_able_deps_1.isPrimitive(value))
return;
stringPathObj[recurser.path.join('.')] = value;
});
if (ordered) {
stringPathObj = sortObj_1.sortObj(stringPathObj);
}
// Object.keys(stringPathObj).forEach(key => {
// if (!isPrimitive(stringPathObj[key])) {
// delete stringPathObj[key]
// }
// })
chain_able_deps_1.defineFinal(stringPathObj, '@@meta', meta);
return stringPathObj;
}
exports.toUniverseView = toUniverseView;
exports.default = toUniverseView;
//# sourceMappingURL=universeView.js.map