MCPcopy Index your code
hub / github.com/parse-community/parse-server / addNestedKeysToRoot

Method addNestedKeysToRoot

src/Utils.js:466–474  ·  view source on GitHub ↗

* Moves the nested keys of a specified key in an object to the root of the object. * * @param {Object} obj The object to modify. * @param {String} key The key whose nested keys will be moved to root. * @returns {Object} The modified object, or the original object if no modification happe

(obj, key)

Source from the content-addressed store, hash-verified

464 * // Output: { a: 1, e: 4, c: 2, d: 3 }
465 */
466 static addNestedKeysToRoot(obj, key) {
467 if (obj[key] && typeof obj[key] === 'object') {
468 // Add nested keys to root
469 Object.assign(obj, { ...obj[key] });
470 // Delete original nested key
471 delete obj[key];
472 }
473 return obj;
474 }
475
476 /**
477 * Encodes a string to be used in a URL.

Callers 1

Utils.spec.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected