Skip to content

Commit

Permalink
chore: golf & tweak perf
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jan 27, 2021
1 parent a62a6c6 commit 8065a48
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export default function (obj, keys, val) {
keys.split && (keys=keys.split('.'));
var i=0, l=keys.length, t=obj, x, k;
for (; i < l; ++i) {
k = keys[i];
if (k == '__proto__' || k == 'constructor' || k == 'prototype') continue;
x = t[k];
t = t[k] = (i === l - 1 ? val : (x != null ? x : (!!~keys[i+1].indexOf('.') || !(+keys[i+1] > -1)) ? {} : []));
for (; i < l;) {
k = keys[i++];
if (k === '__proto__' || k === 'constructor' || k === 'prototype') continue;
t = t[k] = (i === l ? val : ((x=t[k]) != null ? x : (keys[i]*0 !== 0 || !!~keys[i].indexOf('.')) ? {} : []));
}
}

0 comments on commit 8065a48

Please sign in to comment.