Browse Source

cow: Allow post parsed keys as second argument.

Herbert Vojčík 7 years ago
parent
commit
9251d4d636
2 changed files with 2 additions and 4 deletions
  1. 1 1
      lib/cow-value-model.js
  2. 1 3
      src/cow-value-model.js

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

@@ -9,7 +9,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
 
 var cowValueModel = exports.cowValueModel = function cowValueModel(key) {
-    var keys = key.split('.');
+    var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : key.split('.');
 
     function setField() {
         var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

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

@@ -1,6 +1,4 @@
-export const cowValueModel = key => {
-    const keys = key.split('.');
-
+export const cowValueModel = (key, keys = key.split('.')) => {
     function setField (x = {}, index, val) {
         if (index >= keys.length) return val;
         const key = keys[index],