Skip to content

Commit

Permalink
Merge branch 'release/v2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhalff committed Nov 2, 2019
2 parents c2e0b19 + 8dcb301 commit 1e6f080
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog

## 2019-11-02 Version 2.1.1
* Wrong array conversion when brackets are used (Reported by vladshcherbin #27)

## 2019-11-02 Version 2.1.0
* fix delete function not being wrapped. (Reported by murphyke #40)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dot-object",
"version": "2.1.0",
"version": "2.1.1",
"description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.",
"main": "dist/dot-object.js",
"authors": [
Expand Down
4 changes: 3 additions & 1 deletion dist/dot-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@
* @param {Function|Array} mod optional modifier
*/
DotObject.prototype.str = function(path, v, obj, mod) {
var ok = parsePath(path, this.separator).join(this.separator)

if (path.indexOf(this.separator) !== -1) {
this._fill(path.split(this.separator), obj, v, mod)
this._fill(ok.split(this.separator), obj, v, mod)
} else {
obj[path] = _process(v, mod)
}
Expand Down
2 changes: 1 addition & 1 deletion dist/dot-object.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ DotObject.prototype.object = function (obj, mods) {
* @param {Function|Array} mod optional modifier
*/
DotObject.prototype.str = function (path, v, obj, mod) {
var ok = parsePath(path, this.separator).join(this.separator)

if (path.indexOf(this.separator) !== -1) {
this._fill(path.split(this.separator), obj, v, mod)
this._fill(ok.split(this.separator), obj, v, mod)
} else {
obj[path] = _process(v, mod)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dot-object",
"description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.",
"version": "2.1.0",
"version": "2.1.1",
"author": {
"name": "Rob Halff",
"email": "rob.halff@gmail.com"
Expand Down
4 changes: 3 additions & 1 deletion src/dot-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ DotObject.prototype.object = function (obj, mods) {
* @param {Function|Array} mod optional modifier
*/
DotObject.prototype.str = function (path, v, obj, mod) {
var ok = parsePath(path, this.separator).join(this.separator)

if (path.indexOf(this.separator) !== -1) {
this._fill(path.split(this.separator), obj, v, mod)
this._fill(ok.split(this.separator), obj, v, mod)
} else {
obj[path] = _process(v, mod)
}
Expand Down
19 changes: 19 additions & 0 deletions test/str.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ describe('str:', function () {
})
})

it('can set nested with array notation', function () {
var obj = {
a: 1
}
Dot.str('object.fields[0].subfield', 'value', obj)
Dot.str('object.fields[1].subfield', 'value1', obj)

obj.should.deepEqual({
a: 1,
object: {
fields: [{
subfield: 'value'
}, {
subfield: 'value1'
}]
}
})
})

it('can set root level property regardless whether override is set', function () {
Dot.str('a', 'b', {
a: 1
Expand Down

0 comments on commit 1e6f080

Please sign in to comment.