function createHumps(keyConverter) { return function humps(node) { if (isArray(node)) return map(node, humps); if (isPlainObject(node)) return transform(node, createIteratee(keyConverter, humps)); return node; }; }
/** * editPkg - writes to pacakge.json * * @param {Clipped} this * @param {(Object | Function)} mutator * @returns Promise<any> */ function editPkg(this: Clipped, mutator: Object | Function): Promise<any> { if (isPlainObject(mutator)) { merge(this.config.packageJson, mutator) } else if (isFunction(mutator)) { mutator(this.config.packageJson) } return require('write-pkg')(this.config.context, this.config.packageJson.toConfig()) }
function nestChainable (instance) { if (!instance || instance.__keyarray__ || instance.__objectmap__ || instance.__jointed__ || instance.__aliasfunction__) return instance // If is array make it keyable if (Array.isArray(instance) && !instance.__keyarray__) { return new KeyArray(...instance.map(el => (el.key && el.value) ? {key: el.key, value: nestChainable(el.value)} : nestChainable(el))) } // If is object convert to Map if (isPlainObject(instance) && instance !== null && !(instance instanceof Map)) { return new ObjectMap(Object.keys(instance).map(k => [k, nestChainable(instance[k])])) } return instance }
export function makeRuleset(... parts) { let ruleset = new Ruleset(); let style = new EasyStyle(ruleset); for (let t = 0; t < parts.length; ++t) { if (isString(parts[t])) { style = new EasyStyle(ruleset, parseSelector(parts[t])); } else if (isPlainObject(parts[t])) { Object.assign(style, parts[t]); } else { throw new Error(`Failed to execute 'makeRuleset': Parameter ${t + 1} is not of type string, nor it is a plain object.`); } } return ruleset; }
const templateConfigurations = function (obj) { // Allow values which looks like such as // an ES6 literal string without parenthesis inside (aka function call). return Object.keys(obj).reduce((acc, key) => { if (isPlainObject(obj[key]) && !isString(obj[key])) { acc[key] = templateConfigurations(obj[key]); } else if (isString(obj[key]) && obj[key].match(regex) !== null) { acc[key] = eval('`' + obj[key] + '`'); } else { acc[key] = obj[key]; } return acc; }, {}); }
constructor (initialData = {}) { if (initialData instanceof Model) { return initialData } // Create getters/setters bindSchemaToModel(Model, this) // Create virtual getters bindVirtuals(Model, this) hiddenProp(this, '_data', {}) hiddenProp(this, '_pivot', {}) hiddenProp(this, '_validate', true) hiddenProp(this, '_saved', false) if (isPlainObject(initialData)) { // Set initial values (must be after getters/setters) for (const key of Object.keys(initialData)) { this[key] = initialData[key] } } debug(`instanciating ${Model._name} with data ${JSON.stringify(this._data)}`) }
if (isFunction(res)) { res = await res.call(this, this) } else if (isPlainObject(res)) { // Config mutation this.defer(res) res = null
if (isPlainObject(parser)) {
/** * Sets a value in the config. * If 'value' is null, removes the key from the config * * @param {string} key Key to set * @param {any} value Value to set at `key` * @return Config This config instance * * @method get * @public */ set(key, value) { if (isPlainObject(key)) { Object.assign(this.values, key); return this; } // Setting a value to null removes it from the config if (value === null) { delete this.values[key]; return this; } _set(this.values, key, value); return this; }
function normalizeDefer(mutator: any = () => {}): any { if (isPlainObject(mutator)) { return (clipped: Clipped) => { Object.keys(mutator).map(key => { if (isFunction(mutator[key])) { if (clipped.config.toConfig()[key]) { mutator[key](clipped.config[key], clipped) } } else if (isPlainObject(mutator[key])) { if (!clipped.config[key]) { clipped.config[key] = mutator[key] } else { Object.assign(clipped.config[key], mutator[key]) } } else { clipped.config[key] = mutator[key] } }) } } else { return mutator } }
const bindLayout = function (object) { return Object.keys(object).reduce((acc, current) => { if (isPlainObject(object[current])) { acc[current] = bindLayout.call(this, object[current]); } else if (isFunction(object[current])) { acc[current] = object[current].bind(this); } else { acc[current] = object[current]; } return acc; }, {}); }
} else if (!isPlainObject(config)) {
function createHumps(keyConverter) { return function humps(node) { if (isArray(node)) return map(node, humps); if (isPlainObject(node)) return transform(node, createIteratee(keyConverter, humps)); return node; }; }
function createHumps(keyConverter) { return function humps(node) { if (isArray(node)) return map(node, humps); if (isPlainObject(node)) return transform(node, createIteratee(keyConverter, humps)); return node; }; }
function createHumps(keyConverter) { return function humps(node) { if (isArray(node)) return map(node, humps); if (isPlainObject(node)) return transform(node, createIteratee(keyConverter, humps)); return node; }; }