Skip to content

Commit

Permalink
perf: use Object.setPrototypeOf firstly
Browse files Browse the repository at this point in the history
use `Object.setPrototypeOf` firstly, then fallback to `__proto__` in straightway

close timoxley#4
  • Loading branch information
imcuttle committed Sep 26, 2018
1 parent 200a079 commit 0e631f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function toFactory(Class) {
const Factory = function(...args) {
return new Class(...args)
}
Factory.__proto__ = Class
Object.setPrototypeOf ? Object.setPrototypeOf(Factory, Class) : (Factory.__proto__ = Class)
Factory.prototype = Class.prototype
return Factory
}
Expand Down

0 comments on commit 0e631f1

Please sign in to comment.