Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
rhalff committed Sep 7, 2015
1 parent cee88cf commit c781080
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"type": "git",
"url": "git://github.com/rhalff/dot-object.git"
},
"version": "0.11.0",
"version": "1.2.0",
"homepage": "https://github.com/rhalff/dot-object",
"moduleType": [
"amd",
Expand Down
17 changes: 16 additions & 1 deletion dist/dot-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

this._fill(a, obj[k], v, mod);
} else {
if (obj[k] === Object(obj[k]) && Object.keys(obj[k]).length) {
if (!this.override && obj[k] === Object(obj[k]) && Object.keys(obj[k]).length) {
throw new Error('Trying to redefine non-empty obj[\'' + k + '\']');
}

Expand Down Expand Up @@ -131,6 +131,8 @@
obj[k] = _process(obj[k], mod);
}
});

return obj;
};

/**
Expand All @@ -145,6 +147,8 @@
} else if (this.override) {
obj[path] = _process(v, mod);
}

return obj;
};

/**
Expand Down Expand Up @@ -425,6 +429,17 @@
DotObject.del = DotObject.remove = wrap('remove');
DotObject.dot = wrap('dot');

['override', 'overwrite'].forEach(function (prop) {
Object.defineProperty(DotObject, prop, {
get: function () {
return dotDefault.override;
},
set: function (val) {
dotDefault.override = !! val;
}
});
});

DotObject._process = _process;


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.

18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ DotObject.prototype._fill = function(a, obj, v, mod) {

this._fill(a, obj[k], v, mod);
} else {
if (obj[k] === Object(obj[k]) && Object.keys(obj[k]).length) {
if (!this.override &&
obj[k] === Object(obj[k]) && Object.keys(obj[k]).length) {
throw new Error('Trying to redefine non-empty obj[\'' + k + '\']');
}

Expand Down Expand Up @@ -127,6 +128,8 @@ DotObject.prototype.object = function(obj, mods) {
obj[k] = _process(obj[k], mod);
}
});

return obj;
};

/**
Expand All @@ -141,6 +144,8 @@ DotObject.prototype.str = function(path, v, obj, mod) {
} else if (this.override) {
obj[path] = _process(v, mod);
}

return obj;
};

/**
Expand Down Expand Up @@ -426,6 +431,17 @@ DotObject.set = wrap('set');
DotObject.del = DotObject.remove = wrap('remove');
DotObject.dot = wrap('dot');

['override', 'overwrite'].forEach(function(prop) {
Object.defineProperty(DotObject, prop, {
get: function() {
return dotDefault.override;
},
set: function(val) {
dotDefault.override = !!val;
}
});
});

DotObject._process = _process;

module.exports = DotObject;

0 comments on commit c781080

Please sign in to comment.