Browse Source

Fix result swallow when putting undefined.

Herbert Vojčík 7 years ago
parent
commit
24e9b9627c
2 changed files with 2 additions and 0 deletions
  1. 1 0
      lib/cow-value-model.js
  2. 1 0
      src/cow-value-model.js

+ 1 - 0
lib/cow-value-model.js

@@ -67,6 +67,7 @@ var cowWorkshop = exports.cowWorkshop = function cowWorkshop(keys) {
 
         keys.forEach(function (key, index) {
             var value = fn(cowValueModel(key)(obj));
+            if (typeof value === "undefined") return;
             var modifier = cowValueModel(resultKeys[index]);
             var oldResult = result;
             result = modifier(oldResult, value);

+ 1 - 0
src/cow-value-model.js

@@ -36,6 +36,7 @@ export const cowValueModel = (...keyDescriptions) => {
 export const cowWorkshop = (keys, fn = x => x) => (obj, {result = obj, resultKeys = keys, diff} = {}) => {
     keys.forEach((key, index) => {
         const value = fn(cowValueModel(key)(obj));
+        if (typeof value === "undefined") return;
         const modifier = cowValueModel(resultKeys[index]);
         const oldResult = result;
         result = modifier(oldResult, value);