dottie
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -27,2 +27,14 @@ (function(undefined) { | ||
var reverseDupArray = function (array) { | ||
var result = new Array(array.length); | ||
var index = array.length; | ||
var arrayMaxIndex = index - 1; | ||
while (index--) { | ||
result[arrayMaxIndex - index] = array[index]; | ||
} | ||
return result; | ||
}; | ||
var Dottie = function() { | ||
@@ -64,3 +76,3 @@ var args = Array.prototype.slice.call(arguments); | ||
} else if (Array.isArray(path)) { | ||
names = path.reverse(); | ||
names = reverseDupArray(path); | ||
} | ||
@@ -67,0 +79,0 @@ |
{ | ||
"name": "dottie", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "expect.js": "~0.2.0", |
@@ -88,2 +88,15 @@ [![Build Status](https://travis-ci.org/mickhansen/dottie.js.png)](https://travis-ci.org/mickhansen/dottie.js.png) | ||
### Get paths in object | ||
```js | ||
var object = { | ||
a: 1, | ||
b: { | ||
c: 2, | ||
d: { e: 3 } | ||
} | ||
}; | ||
dottie.paths(object); // ["a", "b.c", "b.d.e"]; | ||
``` | ||
## Performance | ||
@@ -90,0 +103,0 @@ |
@@ -98,3 +98,6 @@ var expect = require("expect.js") | ||
it('should get nested values with keys that have dots', function () { | ||
expect(dottie.get(data, ['nested.dot', 'key'])).to.equal('value'); | ||
var path = ['nested.dot', 'key']; | ||
expect(dottie.get(data, path)).to.equal('value'); | ||
expect(path).to.eql(['nested.dot', 'key']); | ||
}); | ||
@@ -101,0 +104,0 @@ }); |
22222
518
108