From e1bb99c83ee48a534562ca39614a3e64cd424f63 Mon Sep 17 00:00:00 2001 From: Divyansh kumar Date: Tue, 23 Jan 2018 20:49:51 +0530 Subject: [PATCH] Check full key text whether can be index or not --- dist/dot-object.js | 2 +- dist/dot-object.min.js | 2 +- index.js | 2 +- src/dot-object.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/dot-object.js b/dist/dot-object.js index 5e9510f..fd0435e 100644 --- a/dist/dot-object.js +++ b/dist/dot-object.js @@ -31,7 +31,7 @@ } function isIndex(k) { - return /^\d+/.test(k) + return /^\d+$/.test(k) } function isObject(val) { diff --git a/dist/dot-object.min.js b/dist/dot-object.min.js index ed08e78..16d7922 100644 --- a/dist/dot-object.min.js +++ b/dist/dot-object.min.js @@ -1 +1 @@ -!function(t,r){"use strict";function e(t,r){var e,i;if("function"==typeof r)void 0!==(i=r(t))&&(t=i);else if(Array.isArray(r))for(e=0;e=0&&(t=t.replace(/\[/g,".").replace(/]/g,"")),t.split(r)}function f(t,r,e){if(!(this instanceof f))return new f(t,r,e);void 0===r&&(r=!1),void 0===e&&(e=!0),this.separator=t||".",this.override=r,this.useArray=e,this.keepArray=!1,this.cleanup=[]}var p=new f(".",!1,!0);function c(t){return function(){return p[t].apply(p,arguments)}}f.prototype._fill=function(t,r,i,s){var f,p=t.shift();if(t.length>0){if(r[p]=r[p]||(this.useArray&&(f=t[0],/^\d+/.test(f))?[]:{}),!n(r[p])){if(!this.override){if(!n(i)||!o(i))throw new Error("Trying to redefine `"+p+"` which is a "+typeof r[p]);return}r[p]={}}this._fill(t,r[p],i,s)}else{if(!this.override&&n(r[p])&&!o(r[p])){if(!n(i)||!o(i))throw new Error("Trying to redefine non-empty obj['"+p+"']");return}r[p]=e(i,s)}},f.prototype.object=function(t,r){var i=this;return Object.keys(t).forEach(function(n){var o=void 0===r?null:r[n],f=s(n,i.separator).join(i.separator);-1!==f.indexOf(i.separator)?(i._fill(f.split(i.separator),t,t[n],o),delete t[n]):i.override&&(t[n]=e(t[n],o))}),t},f.prototype.str=function(t,r,i,n){return-1!==t.indexOf(this.separator)?this._fill(t.split(this.separator),i,r,n):i.hasOwnProperty(t)&&!this.override||(i[t]=e(r,n)),i},f.prototype.pick=function(t,r,e){var i,n,o,f,p,c,a;for(n=s(t,this.separator),i=0;i=0&&(t=t.replace(/\[/g,".").replace(/]/g,"")),t.split(r)}function f(t,r,e){if(!(this instanceof f))return new f(t,r,e);void 0===r&&(r=!1),void 0===e&&(e=!0),this.separator=t||".",this.override=r,this.useArray=e,this.keepArray=!1,this.cleanup=[]}var p=new f(".",!1,!0);function c(t){return function(){return p[t].apply(p,arguments)}}f.prototype._fill=function(t,r,i,s){var f,p=t.shift();if(t.length>0){if(r[p]=r[p]||(this.useArray&&(f=t[0],/^\d+$/.test(f))?[]:{}),!n(r[p])){if(!this.override){if(!n(i)||!o(i))throw new Error("Trying to redefine `"+p+"` which is a "+typeof r[p]);return}r[p]={}}this._fill(t,r[p],i,s)}else{if(!this.override&&n(r[p])&&!o(r[p])){if(!n(i)||!o(i))throw new Error("Trying to redefine non-empty obj['"+p+"']");return}r[p]=e(i,s)}},f.prototype.object=function(t,r){var i=this;return Object.keys(t).forEach(function(n){var o=void 0===r?null:r[n],f=s(n,i.separator).join(i.separator);-1!==f.indexOf(i.separator)?(i._fill(f.split(i.separator),t,t[n],o),delete t[n]):i.override&&(t[n]=e(t[n],o))}),t},f.prototype.str=function(t,r,i,n){return-1!==t.indexOf(this.separator)?this._fill(t.split(this.separator),i,r,n):i.hasOwnProperty(t)&&!this.override||(i[t]=e(r,n)),i},f.prototype.pick=function(t,r,e){var i,n,o,f,p,c,a;for(n=s(t,this.separator),i=0;i