dot-object 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dot-object might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 2018-10-26 Version 1.7.1
4
+ * [[`e1bb99c83e`](https://github.com/rhalff/dot-object/commit/e1bb99c83e)] - Fix isIndex numeric key matching. (Fixed by mrdivyansh #31)
5
+
3
6
  ## 2017-09-20 Version 1.7.0
4
7
  * let .dot and .object understand empty objects / arrays
5
8
 
package/README.md CHANGED
@@ -327,9 +327,9 @@ Result:
327
327
  }
328
328
  ```
329
329
 
330
- ## Using a different seperator
330
+ ## Using a different separator
331
331
 
332
- If you do not like dot notation, you are free to specify a different seperator.
332
+ If you do not like dot notation, you are free to specify a different separator.
333
333
 
334
334
  ```javascript
335
335
  var Dot = require('dot-object');
@@ -31,7 +31,7 @@
31
31
  }
32
32
 
33
33
  function isIndex(k) {
34
- return /^\d+/.test(k)
34
+ return /^\d+$/.test(k)
35
35
  }
36
36
 
37
37
  function isObject(val) {
@@ -53,14 +53,14 @@
53
53
  return path.split(sep)
54
54
  }
55
55
 
56
- function DotObject(seperator, override, useArray) {
56
+ function DotObject(separator, override, useArray) {
57
57
  if (!(this instanceof DotObject)) {
58
- return new DotObject(seperator, override, useArray)
58
+ return new DotObject(separator, override, useArray)
59
59
  }
60
60
 
61
61
  if (typeof override === 'undefined') override = false
62
62
  if (typeof useArray === 'undefined') useArray = true
63
- this.seperator = seperator || '.'
63
+ this.separator = separator || '.'
64
64
  this.override = override
65
65
  this.useArray = useArray
66
66
  this.keepArray = false
@@ -140,11 +140,11 @@
140
140
 
141
141
  Object.keys(obj).forEach(function(k) {
142
142
  var mod = mods === undefined ? null : mods[k]
143
- // normalize array notation.
144
- var ok = parsePath(k, self.seperator).join(self.seperator)
143
+ // normalize array notation.
144
+ var ok = parsePath(k, self.separator).join(self.separator)
145
145
 
146
- if (ok.indexOf(self.seperator) !== -1) {
147
- self._fill(ok.split(self.seperator), obj, obj[k], mod)
146
+ if (ok.indexOf(self.separator) !== -1) {
147
+ self._fill(ok.split(self.separator), obj, obj[k], mod)
148
148
  delete obj[k]
149
149
  } else if (self.override) {
150
150
  obj[k] = _process(obj[k], mod)
@@ -161,8 +161,8 @@
161
161
  * @param {Function|Array} mod optional modifier
162
162
  */
163
163
  DotObject.prototype.str = function(path, v, obj, mod) {
164
- if (path.indexOf(this.seperator) !== -1) {
165
- this._fill(path.split(this.seperator), obj, v, mod)
164
+ if (path.indexOf(this.separator) !== -1) {
165
+ this._fill(path.split(this.separator), obj, v, mod)
166
166
  } else if (!obj.hasOwnProperty(path) || this.override) {
167
167
  obj[path] = _process(v, mod)
168
168
  }
@@ -187,7 +187,7 @@
187
187
  var key
188
188
  var cp
189
189
 
190
- keys = parsePath(path, this.seperator)
190
+ keys = parsePath(path, this.separator)
191
191
  for (i = 0; i < keys.length; i++) {
192
192
  key = parseKey(keys[i], obj)
193
193
  if (obj && typeof obj === 'object' && key in obj) {
@@ -371,7 +371,7 @@
371
371
  if (typeof val === 'undefined') {
372
372
  return obj
373
373
  }
374
- keys = parsePath(path, this.seperator)
374
+ keys = parsePath(path, this.separator)
375
375
 
376
376
  for (i = 0; i < keys.length; i++) {
377
377
  key = keys[i]
@@ -471,7 +471,7 @@
471
471
  ) {
472
472
  return this.dot(obj[key], tgt, path.concat(key))
473
473
  } else {
474
- tgt[path.concat(key).join(this.seperator)] = obj[key]
474
+ tgt[path.concat(key).join(this.separator)] = obj[key]
475
475
  }
476
476
  }.bind(this))
477
477
  return tgt
@@ -1 +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<r.length;e++)void 0!==(i=r[e](t))&&(t=i);return t}function i(t,r){return"-"===t[0]&&Array.isArray(r)&&/^-\d+$/.test(t)?r.length+parseInt(t,10):t}function n(t){return/^\d+/.test(t)}function o(t){return"[object Object]"===Object.prototype.toString.call(t)}function s(t){return Object(t)===t}function f(t){return 0===Object.keys(t).length}function c(t,r){return t.indexOf("[")>=0&&(t=t.replace(/\[/g,".").replace(/]/g,"")),t.split(r)}function p(t,r,e){if(!(this instanceof p))return new p(t,r,e);void 0===r&&(r=!1),void 0===e&&(e=!0),this.seperator=t||".",this.override=r,this.useArray=e,this.keepArray=!1,this.cleanup=[]}function u(t){return function(){return a[t].apply(a,arguments)}}var a=new p(".",!1,!0);p.prototype._fill=function(t,r,i,o){var c=t.shift();if(t.length>0){if(r[c]=r[c]||(this.useArray&&n(t[0])?[]:{}),!s(r[c])){if(!this.override){if(!s(i)||!f(i))throw new Error("Trying to redefine `"+c+"` which is a "+typeof r[c]);return}r[c]={}}this._fill(t,r[c],i,o)}else{if(!this.override&&s(r[c])&&!f(r[c])){if(!s(i)||!f(i))throw new Error("Trying to redefine non-empty obj['"+c+"']");return}r[c]=e(i,o)}},p.prototype.object=function(t,r){var i=this;return Object.keys(t).forEach(function(n){var o=void 0===r?null:r[n],s=c(n,i.seperator).join(i.seperator);-1!==s.indexOf(i.seperator)?(i._fill(s.split(i.seperator),t,t[n],o),delete t[n]):i.override&&(t[n]=e(t[n],o))}),t},p.prototype.str=function(t,r,i,n){return-1!==t.indexOf(this.seperator)?this._fill(t.split(this.seperator),i,r,n):i.hasOwnProperty(t)&&!this.override||(i[t]=e(r,n)),i},p.prototype.pick=function(t,r,e){var n,o,s,f,p;for(o=c(t,this.seperator),n=0;n<o.length;n++){if(f=i(o[n],r),!(r&&"object"==typeof r&&f in r))return;if(n===o.length-1)return e?(s=r[f],delete r[f],Array.isArray(r)&&(p=o.slice(0,-1).join("."),-1===this.cleanup.indexOf(p)&&this.cleanup.push(p)),s):r[f];r=r[f]}return e&&Array.isArray(r)&&(r=r.filter(function(t){return void 0!==t})),r},p.prototype.remove=function(t,r){var e;if(this.cleanup=[],Array.isArray(t)){for(e=0;e<t.length;e++)this.pick(t[e],r,!0);return this._cleanup(r),r}return this.pick(t,r,!0)},p.prototype._cleanup=function(t){var r,e,i,n;if(this.cleanup.length){for(e=0;e<this.cleanup.length;e++)r=(r=(n=(i=this.cleanup[e].split(".")).splice(0,-1).join("."))?this.pick(n,t):t)[i[0]].filter(function(t){return void 0!==t}),this.set(this.cleanup[e],r,t);this.cleanup=[]}},p.prototype.del=p.prototype.remove,p.prototype.move=function(t,r,i,n,o){return"function"==typeof n||Array.isArray(n)?this.set(r,e(this.pick(t,i,!0),n),i,o):(o=n,this.set(r,this.pick(t,i,!0),i,o)),i},p.prototype.transfer=function(t,r,i,n,o,s){return"function"==typeof o||Array.isArray(o)?this.set(r,e(this.pick(t,i,!0),o),n,s):(s=o,this.set(r,this.pick(t,i,!0),n,s)),n},p.prototype.copy=function(t,r,i,n,o,s){return"function"==typeof o||Array.isArray(o)?this.set(r,e(JSON.parse(JSON.stringify(this.pick(t,i,!1))),o),n,s):(s=o,this.set(r,this.pick(t,i,!1),n,s)),n},p.prototype.set=function(t,r,e,i){var n,s,f,p;if(void 0===r)return e;for(f=c(t,this.seperator),n=0;n<f.length;n++){if(p=f[n],n===f.length-1)if(i&&o(r)&&o(e[p]))for(s in r)r.hasOwnProperty(s)&&(e[p][s]=r[s]);else if(i&&Array.isArray(e[p])&&Array.isArray(r))for(var u=0;u<r.length;u++)e[f[n]].push(r[u]);else e[p]=r;else e.hasOwnProperty(p)&&(o(e[p])||Array.isArray(e[p]))||(/^\d+$/.test(f[n+1])?e[p]=[]:e[p]={});e=e[p]}return e},p.prototype.transform=function(t,r,e){return r=r||{},e=e||{},Object.keys(t).forEach(function(i){this.set(t[i],this.pick(i,r),e)}.bind(this)),e},p.prototype.dot=function(t,r,e){return r=r||{},e=e||[],Object.keys(t).forEach(function(i){if(s(t[i])&&(o(t[i])&&!f(t[i])||Array.isArray(t[i])&&!this.keepArray&&0!==t[i].length))return this.dot(t[i],r,e.concat(i));r[e.concat(i).join(this.seperator)]=t[i]}.bind(this)),r},p.pick=u("pick"),p.move=u("move"),p.transfer=u("transfer"),p.transform=u("transform"),p.copy=u("copy"),p.object=u("object"),p.str=u("str"),p.set=u("set"),p.del=p.remove=u("remove"),p.dot=u("dot"),["override","overwrite"].forEach(function(t){Object.defineProperty(p,t,{get:function(){return a.override},set:function(t){a.override=!!t}})}),["useArray","keepArray"].forEach(function(t){Object.defineProperty(p,t,{get:function(){return a[t]},set:function(r){a[t]=r}})}),p._process=e,"function"==typeof define&&define.amd?define(function(){return p}):"undefined"!=typeof module&&module.exports?module.exports=p:t.DotObject=p}(this);
1
+ !function(t,r){"use strict";function s(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<r.length;e++)void 0!==(i=r[e](t))&&(t=i);return t}function c(t){return"[object Object]"===Object.prototype.toString.call(t)}function f(t){return Object(t)===t}function p(t){return 0===Object.keys(t).length}function a(t,r){return 0<=t.indexOf("[")&&(t=t.replace(/\[/g,".").replace(/]/g,"")),t.split(r)}function i(t,r,e){if(!(this instanceof i))return new i(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 e=new i(".",!1,!0);function n(t){return function(){return e[t].apply(e,arguments)}}i.prototype._fill=function(t,r,e,i){var n,o=t.shift();if(0<t.length){if(r[o]=r[o]||(this.useArray&&(n=t[0],/^\d+$/.test(n))?[]:{}),!f(r[o])){if(!this.override){if(!f(e)||!p(e))throw new Error("Trying to redefine `"+o+"` which is a "+typeof r[o]);return}r[o]={}}this._fill(t,r[o],e,i)}else{if(!this.override&&f(r[o])&&!p(r[o])){if(!f(e)||!p(e))throw new Error("Trying to redefine non-empty obj['"+o+"']");return}r[o]=s(e,i)}},i.prototype.object=function(i,n){var o=this;return Object.keys(i).forEach(function(t){var r=void 0===n?null:n[t],e=a(t,o.separator).join(o.separator);-1!==e.indexOf(o.separator)?(o._fill(e.split(o.separator),i,i[t],r),delete i[t]):o.override&&(i[t]=s(i[t],r))}),i},i.prototype.str=function(t,r,e,i){return-1!==t.indexOf(this.separator)?this._fill(t.split(this.separator),e,r,i):e.hasOwnProperty(t)&&!this.override||(e[t]=s(r,i)),e},i.prototype.pick=function(t,r,e){var i,n,o,s,f,p,c;for(n=a(t,this.separator),i=0;i<n.length;i++){if(p=n[i],c=r,s="-"===p[0]&&Array.isArray(c)&&/^-\d+$/.test(p)?c.length+parseInt(p,10):p,!(r&&"object"==typeof r&&s in r))return;if(i===n.length-1)return e?(o=r[s],delete r[s],Array.isArray(r)&&(f=n.slice(0,-1).join("."),-1===this.cleanup.indexOf(f)&&this.cleanup.push(f)),o):r[s];r=r[s]}return e&&Array.isArray(r)&&(r=r.filter(function(t){return void 0!==t})),r},i.prototype.remove=function(t,r){var e;if(this.cleanup=[],Array.isArray(t)){for(e=0;e<t.length;e++)this.pick(t[e],r,!0);return this._cleanup(r),r}return this.pick(t,r,!0)},i.prototype._cleanup=function(t){var r,e,i,n;if(this.cleanup.length){for(e=0;e<this.cleanup.length;e++)r=(r=(n=(i=this.cleanup[e].split(".")).splice(0,-1).join("."))?this.pick(n,t):t)[i[0]].filter(function(t){return void 0!==t}),this.set(this.cleanup[e],r,t);this.cleanup=[]}},i.prototype.del=i.prototype.remove,i.prototype.move=function(t,r,e,i,n){return"function"==typeof i||Array.isArray(i)?this.set(r,s(this.pick(t,e,!0),i),e,n):(n=i,this.set(r,this.pick(t,e,!0),e,n)),e},i.prototype.transfer=function(t,r,e,i,n,o){return"function"==typeof n||Array.isArray(n)?this.set(r,s(this.pick(t,e,!0),n),i,o):(o=n,this.set(r,this.pick(t,e,!0),i,o)),i},i.prototype.copy=function(t,r,e,i,n,o){return"function"==typeof n||Array.isArray(n)?this.set(r,s(JSON.parse(JSON.stringify(this.pick(t,e,!1))),n),i,o):(o=n,this.set(r,this.pick(t,e,!1),i,o)),i},i.prototype.set=function(t,r,e,i){var n,o,s,f;if(void 0===r)return e;for(s=a(t,this.separator),n=0;n<s.length;n++){if(f=s[n],n===s.length-1)if(i&&c(r)&&c(e[f]))for(o in r)r.hasOwnProperty(o)&&(e[f][o]=r[o]);else if(i&&Array.isArray(e[f])&&Array.isArray(r))for(var p=0;p<r.length;p++)e[s[n]].push(r[p]);else e[f]=r;else e.hasOwnProperty(f)&&(c(e[f])||Array.isArray(e[f]))||(/^\d+$/.test(s[n+1])?e[f]=[]:e[f]={});e=e[f]}return e},i.prototype.transform=function(r,e,i){return e=e||{},i=i||{},Object.keys(r).forEach(function(t){this.set(r[t],this.pick(t,e),i)}.bind(this)),i},i.prototype.dot=function(r,e,i){return e=e||{},i=i||[],Object.keys(r).forEach(function(t){if(f(r[t])&&(c(r[t])&&!p(r[t])||Array.isArray(r[t])&&!this.keepArray&&0!==r[t].length))return this.dot(r[t],e,i.concat(t));e[i.concat(t).join(this.separator)]=r[t]}.bind(this)),e},i.pick=n("pick"),i.move=n("move"),i.transfer=n("transfer"),i.transform=n("transform"),i.copy=n("copy"),i.object=n("object"),i.str=n("str"),i.set=n("set"),i.del=i.remove=n("remove"),i.dot=n("dot"),["override","overwrite"].forEach(function(t){Object.defineProperty(i,t,{get:function(){return e.override},set:function(t){e.override=!!t}})}),["useArray","keepArray"].forEach(function(r){Object.defineProperty(i,r,{get:function(){return e[r]},set:function(t){e[r]=t}})}),i._process=s,"function"==typeof define&&define.amd?define(function(){return i}):"undefined"!=typeof module&&module.exports?module.exports=i:t.DotObject=i}(this);
package/gulpfile.js CHANGED
@@ -34,7 +34,7 @@ gulp.task('watch', function () {
34
34
  gulp.task('build-node', function () {
35
35
  gulp.src('src/dot-object.js')
36
36
  .pipe(hf.footer('\nmodule.exports = DotObject\n'))
37
- .pipe(rename({basename: 'index'}))
37
+ .pipe(rename({ basename: 'index' }))
38
38
  .pipe(gulp.dest('./'))
39
39
  })
40
40
 
@@ -42,10 +42,10 @@ gulp.task('build-bower', function () {
42
42
  gulp.src('src/dot-object.js')
43
43
  .pipe(hf.header('src/header.tpl'))
44
44
  .pipe(hf.footer('src/footer.tpl'))
45
- .pipe(beautify({indentSize: 2}))
45
+ .pipe(beautify({ indentSize: 2 }))
46
46
  .pipe(gulp.dest(DEST))
47
47
  .pipe(uglify())
48
- .pipe(rename({extname: '.min.js'}))
48
+ .pipe(rename({ extname: '.min.js' }))
49
49
  .pipe(gulp.dest(DEST))
50
50
  })
51
51
 
package/index.js CHANGED
@@ -30,7 +30,7 @@ function parseKey (key, val) {
30
30
  }
31
31
 
32
32
  function isIndex (k) {
33
- return /^\d+/.test(k)
33
+ return /^\d+$/.test(k)
34
34
  }
35
35
 
36
36
  function isObject (val) {
@@ -52,14 +52,14 @@ function parsePath (path, sep) {
52
52
  return path.split(sep)
53
53
  }
54
54
 
55
- function DotObject (seperator, override, useArray) {
55
+ function DotObject (separator, override, useArray) {
56
56
  if (!(this instanceof DotObject)) {
57
- return new DotObject(seperator, override, useArray)
57
+ return new DotObject(separator, override, useArray)
58
58
  }
59
59
 
60
60
  if (typeof override === 'undefined') override = false
61
61
  if (typeof useArray === 'undefined') useArray = true
62
- this.seperator = seperator || '.'
62
+ this.separator = separator || '.'
63
63
  this.override = override
64
64
  this.useArray = useArray
65
65
  this.keepArray = false
@@ -139,10 +139,10 @@ DotObject.prototype.object = function (obj, mods) {
139
139
  Object.keys(obj).forEach(function (k) {
140
140
  var mod = mods === undefined ? null : mods[k]
141
141
  // normalize array notation.
142
- var ok = parsePath(k, self.seperator).join(self.seperator)
142
+ var ok = parsePath(k, self.separator).join(self.separator)
143
143
 
144
- if (ok.indexOf(self.seperator) !== -1) {
145
- self._fill(ok.split(self.seperator), obj, obj[k], mod)
144
+ if (ok.indexOf(self.separator) !== -1) {
145
+ self._fill(ok.split(self.separator), obj, obj[k], mod)
146
146
  delete obj[k]
147
147
  } else if (self.override) {
148
148
  obj[k] = _process(obj[k], mod)
@@ -159,8 +159,8 @@ DotObject.prototype.object = function (obj, mods) {
159
159
  * @param {Function|Array} mod optional modifier
160
160
  */
161
161
  DotObject.prototype.str = function (path, v, obj, mod) {
162
- if (path.indexOf(this.seperator) !== -1) {
163
- this._fill(path.split(this.seperator), obj, v, mod)
162
+ if (path.indexOf(this.separator) !== -1) {
163
+ this._fill(path.split(this.separator), obj, v, mod)
164
164
  } else if (!obj.hasOwnProperty(path) || this.override) {
165
165
  obj[path] = _process(v, mod)
166
166
  }
@@ -185,7 +185,7 @@ DotObject.prototype.pick = function (path, obj, remove) {
185
185
  var key
186
186
  var cp
187
187
 
188
- keys = parsePath(path, this.seperator)
188
+ keys = parsePath(path, this.separator)
189
189
  for (i = 0; i < keys.length; i++) {
190
190
  key = parseKey(keys[i], obj)
191
191
  if (obj && typeof obj === 'object' && key in obj) {
@@ -365,7 +365,7 @@ DotObject.prototype.set = function (path, val, obj, merge) {
365
365
  if (typeof val === 'undefined') {
366
366
  return obj
367
367
  }
368
- keys = parsePath(path, this.seperator)
368
+ keys = parsePath(path, this.separator)
369
369
 
370
370
  for (i = 0; i < keys.length; i++) {
371
371
  key = keys[i]
@@ -462,10 +462,10 @@ DotObject.prototype.dot = function (obj, tgt, path) {
462
462
  (Array.isArray(obj[key]) && (!this.keepArray && (obj[key].length !== 0)))
463
463
  )
464
464
  )
465
- ) {
465
+ ) {
466
466
  return this.dot(obj[key], tgt, path.concat(key))
467
467
  } else {
468
- tgt[path.concat(key).join(this.seperator)] = obj[key]
468
+ tgt[path.concat(key).join(this.separator)] = obj[key]
469
469
  }
470
470
  }.bind(this))
471
471
  return tgt
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dot-object",
3
3
  "description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "author": {
6
6
  "name": "Rob Halff",
7
7
  "email": "rob.halff@gmail.com"
@@ -32,13 +32,13 @@
32
32
  "gulp": "^3.9.1",
33
33
  "gulp-beautify": "^2.0.1",
34
34
  "gulp-headerfooter": "^1.0.3",
35
- "gulp-mocha": "^4.3.1",
36
- "gulp-rename": "^1.2.2",
37
- "gulp-standard": "^10.0.0",
38
- "gulp-uglify": "^3.0.0",
35
+ "gulp-mocha": "^6.0.0",
36
+ "gulp-rename": "^1.4.0",
37
+ "gulp-standard": "^12.0.0",
38
+ "gulp-uglify": "^3.0.1",
39
39
  "gulp-util": "^3.0.8",
40
- "mocha": "3.x.x",
41
- "should": "11.x.x",
40
+ "mocha": "5.x.x",
41
+ "should": "13.x.x",
42
42
  "underscore.string": "latest"
43
43
  },
44
44
  "keywords": [
@@ -49,7 +49,7 @@
49
49
  "dot"
50
50
  ],
51
51
  "dependencies": {
52
- "commander": "^2.10.0",
53
- "glob": "^7.1.2"
52
+ "commander": "^2.19.0",
53
+ "glob": "^7.1.3"
54
54
  }
55
55
  }
package/src/dot-object.js CHANGED
@@ -30,7 +30,7 @@ function parseKey (key, val) {
30
30
  }
31
31
 
32
32
  function isIndex (k) {
33
- return /^\d+/.test(k)
33
+ return /^\d+$/.test(k)
34
34
  }
35
35
 
36
36
  function isObject (val) {
@@ -52,14 +52,14 @@ function parsePath (path, sep) {
52
52
  return path.split(sep)
53
53
  }
54
54
 
55
- function DotObject (seperator, override, useArray) {
55
+ function DotObject (separator, override, useArray) {
56
56
  if (!(this instanceof DotObject)) {
57
- return new DotObject(seperator, override, useArray)
57
+ return new DotObject(separator, override, useArray)
58
58
  }
59
59
 
60
60
  if (typeof override === 'undefined') override = false
61
61
  if (typeof useArray === 'undefined') useArray = true
62
- this.seperator = seperator || '.'
62
+ this.separator = separator || '.'
63
63
  this.override = override
64
64
  this.useArray = useArray
65
65
  this.keepArray = false
@@ -139,10 +139,10 @@ DotObject.prototype.object = function (obj, mods) {
139
139
  Object.keys(obj).forEach(function (k) {
140
140
  var mod = mods === undefined ? null : mods[k]
141
141
  // normalize array notation.
142
- var ok = parsePath(k, self.seperator).join(self.seperator)
142
+ var ok = parsePath(k, self.separator).join(self.separator)
143
143
 
144
- if (ok.indexOf(self.seperator) !== -1) {
145
- self._fill(ok.split(self.seperator), obj, obj[k], mod)
144
+ if (ok.indexOf(self.separator) !== -1) {
145
+ self._fill(ok.split(self.separator), obj, obj[k], mod)
146
146
  delete obj[k]
147
147
  } else if (self.override) {
148
148
  obj[k] = _process(obj[k], mod)
@@ -159,8 +159,8 @@ DotObject.prototype.object = function (obj, mods) {
159
159
  * @param {Function|Array} mod optional modifier
160
160
  */
161
161
  DotObject.prototype.str = function (path, v, obj, mod) {
162
- if (path.indexOf(this.seperator) !== -1) {
163
- this._fill(path.split(this.seperator), obj, v, mod)
162
+ if (path.indexOf(this.separator) !== -1) {
163
+ this._fill(path.split(this.separator), obj, v, mod)
164
164
  } else if (!obj.hasOwnProperty(path) || this.override) {
165
165
  obj[path] = _process(v, mod)
166
166
  }
@@ -185,7 +185,7 @@ DotObject.prototype.pick = function (path, obj, remove) {
185
185
  var key
186
186
  var cp
187
187
 
188
- keys = parsePath(path, this.seperator)
188
+ keys = parsePath(path, this.separator)
189
189
  for (i = 0; i < keys.length; i++) {
190
190
  key = parseKey(keys[i], obj)
191
191
  if (obj && typeof obj === 'object' && key in obj) {
@@ -365,7 +365,7 @@ DotObject.prototype.set = function (path, val, obj, merge) {
365
365
  if (typeof val === 'undefined') {
366
366
  return obj
367
367
  }
368
- keys = parsePath(path, this.seperator)
368
+ keys = parsePath(path, this.separator)
369
369
 
370
370
  for (i = 0; i < keys.length; i++) {
371
371
  key = keys[i]
@@ -462,10 +462,10 @@ DotObject.prototype.dot = function (obj, tgt, path) {
462
462
  (Array.isArray(obj[key]) && (!this.keepArray && (obj[key].length !== 0)))
463
463
  )
464
464
  )
465
- ) {
465
+ ) {
466
466
  return this.dot(obj[key], tgt, path.concat(key))
467
467
  } else {
468
- tgt[path.concat(key).join(this.seperator)] = obj[key]
468
+ tgt[path.concat(key).join(this.separator)] = obj[key]
469
469
  }
470
470
  }.bind(this))
471
471
  return tgt
@@ -66,8 +66,8 @@ describe('Dotted Array notation', function () {
66
66
  it('multiple indexes', function () {
67
67
  var src = {
68
68
  I: [
69
- {am: [{nes: ['ted']}]},
70
- {me: 'too'}
69
+ { am: [{ nes: ['ted'] }] },
70
+ { me: 'too' }
71
71
  ]
72
72
  }
73
73
 
@@ -82,17 +82,17 @@ describe('Dotted Array notation', function () {
82
82
 
83
83
  describe('can set', function () {
84
84
  it('index at target', function () {
85
- var obj = {path: []}
85
+ var obj = { path: [] }
86
86
 
87
87
  Dot.set(v('path.0'), 'test', obj)
88
88
  Dot.set(v('path.1'), 'test2', obj)
89
89
 
90
90
  obj.path.should.be.instanceOf(Array)
91
- obj.should.eql({path: ['test', 'test2']})
91
+ obj.should.eql({ path: ['test', 'test2'] })
92
92
  })
93
93
 
94
94
  it('index and set undefined for empty indices', function () {
95
- var obj = {path: []}
95
+ var obj = { path: [] }
96
96
 
97
97
  Dot.set(v('path.0'), 'test', obj)
98
98
  Dot.set(v('path.2'), 'test2', obj)
@@ -102,27 +102,27 @@ describe('Dotted Array notation', function () {
102
102
  // array will have an undefined index.
103
103
  JSON.stringify(obj)
104
104
  .should.eql(
105
- JSON.stringify({path: ['test', undefined, 'test2']})
106
- )
105
+ JSON.stringify({ path: ['test', undefined, 'test2'] })
106
+ )
107
107
 
108
108
  // to json will converted it to null
109
109
  JSON.stringify(obj).should.eql('{"path":["test",null,"test2"]}')
110
110
  })
111
111
 
112
112
  it('index and overwrite existing values', function () {
113
- var obj = {path: ['still', 'shall', 'be', 'gone', 'here']}
113
+ var obj = { path: ['still', 'shall', 'be', 'gone', 'here'] }
114
114
 
115
115
  Dot.set(v('path.1'), 'x', obj)
116
116
  Dot.set(v('path.2'), 'xx', obj)
117
117
  Dot.set(v('path.3'), 'xxx', obj)
118
118
 
119
- obj.should.eql({path: ['still', 'x', 'xx', 'xxx', 'here']})
119
+ obj.should.eql({ path: ['still', 'x', 'xx', 'xxx', 'here'] })
120
120
  })
121
121
  })
122
122
 
123
123
  describe('can remove', function () {
124
124
  it('indexes one by one leaving traces', function () {
125
- var obj = {path: ['still', 'shall', 'really', 'be', 'gone', 'here']}
125
+ var obj = { path: ['still', 'shall', 'really', 'be', 'gone', 'here'] }
126
126
 
127
127
  Dot.remove(v('path.1'), obj)
128
128
  Dot.remove(v('path.2'), obj)
@@ -132,12 +132,12 @@ describe('Dotted Array notation', function () {
132
132
  // array will have an undefined index.
133
133
  JSON.stringify(obj)
134
134
  .should.eql(
135
- JSON.stringify({
136
- path: [
137
- 'still', undefined, undefined, undefined, undefined, 'here'
138
- ]
139
- })
140
- )
135
+ JSON.stringify({
136
+ path: [
137
+ 'still', undefined, undefined, undefined, undefined, 'here'
138
+ ]
139
+ })
140
+ )
141
141
 
142
142
  // to json will converted it to null
143
143
  JSON.stringify(obj).should.eql(
@@ -146,7 +146,7 @@ describe('Dotted Array notation', function () {
146
146
  })
147
147
 
148
148
  it('array of indexes leaving no traces', function () {
149
- var obj = {path: ['still', 'shall', 'really', 'be', 'gone', 'here']}
149
+ var obj = { path: ['still', 'shall', 'really', 'be', 'gone', 'here'] }
150
150
 
151
151
  Dot.remove([
152
152
  v('path.1'),
package/test/dot-json.js CHANGED
@@ -55,6 +55,28 @@ describe('Object test:', function () {
55
55
  })
56
56
  })
57
57
 
58
+ it('Should allow keys with numbers', function () {
59
+ var row = {
60
+ 'id': 2,
61
+ '0A': 'a',
62
+ '0A9': 'b',
63
+ '0B.1AB.A34C9': 'c'
64
+ }
65
+
66
+ Dot.object(row)
67
+
68
+ row.should.eql({
69
+ 'id': 2,
70
+ '0A': 'a',
71
+ '0A9': 'b',
72
+ '0B': {
73
+ '1AB': {
74
+ 'A34C9': 'c'
75
+ }
76
+ }
77
+ })
78
+ })
79
+
58
80
  it('Should expand dotted string', function () {
59
81
  var tgt = {}
60
82
 
@@ -130,39 +152,39 @@ describe('Object test:', function () {
130
152
 
131
153
  Dot.object(row, mods)
132
154
 
133
- row.should.eql({'page': {'title': 'My Page', 'slug': 'my-page'}})
155
+ row.should.eql({ 'page': { 'title': 'My Page', 'slug': 'my-page' } })
134
156
  })
135
157
 
136
158
  it('should not process non dot value with modifier when override is false',
137
159
  function () {
138
- var row = {'title': 'my page', 'slug': 'My Page'}
160
+ var row = { 'title': 'my page', 'slug': 'My Page' }
139
161
 
140
- var mods = {'title': _s.titleize, 'slug': _s.slugify}
162
+ var mods = { 'title': _s.titleize, 'slug': _s.slugify }
141
163
 
142
164
  Dot.object(row, mods)
143
165
 
144
- row.should.eql({'title': 'my page', 'slug': 'My Page'})
166
+ row.should.eql({ 'title': 'my page', 'slug': 'My Page' })
145
167
  }
146
168
  )
147
169
 
148
170
  it('Dot.object should process multiple modifiers', function () {
149
- var row = {'page.name': ' My Page '}
171
+ var row = { 'page.name': ' My Page ' }
150
172
 
151
- var mods = {'page.name': [_s.trim, _s.underscored]}
173
+ var mods = { 'page.name': [_s.trim, _s.underscored] }
152
174
 
153
175
  Dot.object(row, mods)
154
176
 
155
- row.should.eql({'page': {'name': 'my_page'}})
177
+ row.should.eql({ 'page': { 'name': 'my_page' } })
156
178
  })
157
179
 
158
- it('Dot.object should work with a different seperator', function () {
159
- var row = {'page=>name': ' My Page '}
180
+ it('Dot.object should work with a different separator', function () {
181
+ var row = { 'page=>name': ' My Page ' }
160
182
 
161
- var mods = {'page=>name': [_s.trim, _s.underscored]}
183
+ var mods = { 'page=>name': [_s.trim, _s.underscored] }
162
184
 
163
185
  var dot = new Dot('=>', false)
164
186
  dot.object(row, mods)
165
187
 
166
- row.should.eql({'page': {'name': 'my_page'}})
188
+ row.should.eql({ 'page': { 'name': 'my_page' } })
167
189
  })
168
190
  })
package/test/move.js CHANGED
@@ -15,8 +15,8 @@ describe('Move test:', function () {
15
15
 
16
16
  var expected = {
17
17
  id: '527423a65e380f0000588e47',
18
- source: {id: '526dd5c6b4c4aa8770000001', port: 'github'},
19
- target: {id: '527402d6b15d1800008755cf', port: 'in'}
18
+ source: { id: '526dd5c6b4c4aa8770000001', port: 'github' },
19
+ target: { id: '527402d6b15d1800008755cf', port: 'in' }
20
20
  }
21
21
 
22
22
  Dot.move('source', 'source.id', link)
@@ -36,8 +36,8 @@ describe('Move test:', function () {
36
36
  }
37
37
 
38
38
  var expected = {
39
- source: {id: '526dd5c6b4c4aa8770000001'},
40
- target: {port: 'in'},
39
+ source: { id: '526dd5c6b4c4aa8770000001' },
40
+ target: { port: 'in' },
41
41
  out: 'github'
42
42
  }
43
43
 
@@ -56,8 +56,8 @@ describe('Move test:', function () {
56
56
  }
57
57
 
58
58
  var expected = {
59
- source: {id: 'ONE'},
60
- target: {port: 'TWO'}
59
+ source: { id: 'ONE' },
60
+ target: { port: 'TWO' }
61
61
  }
62
62
 
63
63
  function up (val) { return val.toUpperCase() }
package/test/override.js CHANGED
@@ -17,7 +17,7 @@ describe('Override test:', function () {
17
17
 
18
18
  obj.should.eql({
19
19
  'some': 'value',
20
- 'already': {'new': 'value'}
20
+ 'already': { 'new': 'value' }
21
21
  })
22
22
  })
23
23
 
@@ -34,7 +34,7 @@ describe('Override test:', function () {
34
34
 
35
35
  obj.should.eql({
36
36
  'some': 'new_value',
37
- 'already': {'new': 'value'}
37
+ 'already': { 'new': 'value' }
38
38
  })
39
39
  })
40
40
 
@@ -52,7 +52,7 @@ describe('Override test:', function () {
52
52
 
53
53
  Dot.override = true
54
54
 
55
- Dot.str('sample.dotted.bar', {baz: 'boom'}, obj)
55
+ Dot.str('sample.dotted.bar', { baz: 'boom' }, obj)
56
56
 
57
57
  Dot.override = false
58
58
 
package/test/transfer.js CHANGED
@@ -19,7 +19,7 @@ describe('Transfer:', function () {
19
19
  name: 'Brandon'
20
20
  }
21
21
 
22
- var srcExpected = {name: 'John', stuff: {}}
22
+ var srcExpected = { name: 'John', stuff: {} }
23
23
 
24
24
  var tgtExpected = {
25
25
  name: 'Brandon',
@@ -59,7 +59,7 @@ describe('Transfer:', function () {
59
59
  name: 'Brandon'
60
60
  }
61
61
 
62
- var srcExpected = {name: 'John', stuff: {}}
62
+ var srcExpected = { name: 'John', stuff: {} }
63
63
 
64
64
  var tgtExpected = {
65
65
  name: 'Brandon',