Browse Source

Extract var atCurrentPath.

Herby Vojčík 6 years ago
parent
commit
33aeea590d
1 changed files with 2 additions and 1 deletions
  1. 2 1
      index.js

+ 2 - 1
index.js

@@ -56,6 +56,7 @@ const modifier = (key, value, valueModifier) => {
 
 const atPathBeginningWith = prefix => (...keyDescriptions) => {
     const keys = parseKeysInto(keyDescriptions, [...prefix]),
+        atCurrentPath = atPathBeginningWith(keys),
         keyChain = chain(keys),
         putChain = keyChain((key, next) => x => modifier(key, getKey(x, key), next)(x)),
         mapChain = keyChain((key, next) => x => {
@@ -64,7 +65,7 @@ const atPathBeginningWith = prefix => (...keyDescriptions) => {
             return modifier(key, valueWithCheck.value, next)(x);
         });
 
-    return Object.assign(atPathBeginningWith(keys), {
+    return Object.assign(atCurrentPath, {
         get: obj => keys.reduce(getKey, obj),
         put: val => putChain(() => val),
         map: mapChain