object-rewrite
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -39,4 +39,6 @@ const assert = require("assert"); | ||
if (overwrite[needle] !== undefined) { | ||
// eslint-disable-next-line no-param-reassign | ||
parents[0][needle.split(".").slice(-1)[0]] = overwrite[needle](key, value, parents); | ||
const lastStringIndex = key.reduce((p, c, idx) => typeof c === "string" ? idx : p, 0); | ||
const directParent = key.slice(lastStringIndex, -1).reduce((p, c) => p[c], parents[0]); // eslint-disable-next-line no-param-reassign | ||
directParent[key.slice(-1)[0]] = overwrite[needle](key, value, parents); | ||
} | ||
@@ -52,2 +54,2 @@ } | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3NlcnQiLCJyZXF1aXJlIiwib2JqZWN0U2NhbiIsInRyZWUiLCJtb2R1bGUiLCJleHBvcnRzIiwiZXhjbHVkZSIsImluamVjdCIsIm92ZXJ3cml0ZSIsInJldGFpbiIsIm5lZWRsZXMiLCJPYmplY3QiLCJrZXlzIiwiZXhjbHVkZWQiLCJyZXRhaW5lZCIsInNjYW5uZXIiLCJ1c2VBcnJheVNlbGVjdG9yIiwiam9pbmVkIiwiY2FsbGJhY2tGbiIsImtleSIsInZhbHVlIiwiaXNNYXRjaCIsIm5lZWRsZSIsInBhcmVudHMiLCJ1bmRlZmluZWQiLCJwdXNoIiwiaW5jbHVkZXMiLCJhc3NpZ24iLCJzcGxpdCIsInNsaWNlIiwiaW5wdXQiLCJwcnVuZSIsImxlbmd0aCJdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTUEsU0FBU0MsUUFBUSxRQUFSLENBQWY7O0FBQ0EsTUFBTUMsYUFBYUQsUUFBUSxhQUFSLENBQW5COztBQUNBLE1BQU1FLE9BQU9GLFFBQVEsYUFBUixDQUFiOztBQUVBRyxPQUFPQyxPQUFQLEdBQWlCLENBQUM7QUFDaEJDLFl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AgICBPYmplY3QuYXNzaWduKHZhbHVlLCBpbmplY3RbbmVlZGxlXShrZXksIHZhbHVlLCBwYXJlbnRzKSk7XG4gICAgICB9XG4gICAgICBpZiAob3ZlcndyaXRlW25lZWRsZV0gIT09IHVuZGVmaW5lZCkge1xuICAgICAgICBjb25zdCBsYXN0U3RyaW5nSW5kZXggPSBrZXkucmVkdWNlKChwLCBjLCBpZHgpID0+ICh0eXBlb2YgYyA9PT0gXCJzdHJpbmdcIiA/IGlkeCA6IHApLCAwKTtcbiAgICAgICAgY29uc3QgZGlyZWN0UGFyZW50ID0ga2V5LnNsaWNlKGxhc3RTdHJpbmdJbmRleCwgLTEpLnJlZHVjZSgocCwgYykgPT4gcFtjXSwgcGFyZW50c1swXSk7XG4gICAgICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby1wYXJhbS1yZWFzc2lnblxuICAgICAgICBkaXJlY3RQYXJlbnRba2V5LnNsaWNlKC0xKVswXV0gPSBvdmVyd3JpdGVbbmVlZGxlXShrZXksIHZhbHVlLCBwYXJlbnRzKTtcbiAgICAgIH1cbiAgICB9XG4gIH0pO1xuXG4gIHJldHVybiAoaW5wdXQpID0+IHtcbiAgICBzY2FubmVyKGlucHV0KTtcbiAgICB0cmVlLnBydW5lKGlucHV0LCBleGNsdWRlZCwgcmV0YWluZWQpO1xuICAgIGV4Y2x1ZGVkLmxlbmd0aCA9IDA7XG4gICAgcmV0YWluZWQubGVuZ3RoID0gMDtcbiAgfTtcbn07XG4iXX0= |
{ | ||
"name": "object-rewrite", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Rewrite an Object", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19241
89