Skip to content

Commit

Permalink
added catch for length property override
Browse files Browse the repository at this point in the history
  • Loading branch information
adascal committed May 24, 2016
1 parent 7dc5cf4 commit 7eb347a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
27 changes: 16 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@ module.exports = function overrideFn(context, fnName, fn) {
return fn.apply(this, params);
};

Object.defineProperties(context[fnName], {
length: {
get: function () {
return baseFn.length;
try {
Object.defineProperties(context[fnName], {
length: {
get: function () {
return baseFn.length;
}
},
name: {
get: function () {
return baseFn.name;
}
}
},
name: {
get: function () {
return baseFn.name;
}
}
});
});
}
catch (ex) {
console.warn(ex);
}

context[fnName].toString = function () {
return baseFn.toString();
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
},
"keywords": [
"override",
"function",
"override function",
"override fn",
"override-fn",
"overrideFn",
"massive",
"massive-angular",
"massive angular",
"massiveAngular"
"massive angular"
],
"license": "MIT",
"bugs": {
Expand Down

0 comments on commit 7eb347a

Please sign in to comment.