Skip to content

Commit

Permalink
converted to setPrototypeOf for forward and backward compat
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Feb 20, 2016
1 parent 405a758 commit f6d9955
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* MIT Licensed
*/

var setPrototypeOf = require('setprototypeof')

/**
* Expose `Proto`.
Expand Down Expand Up @@ -41,7 +42,7 @@ function Proto(protos, options) {
var middleware = function setProto() {
var i = arguments.length
while (i--) {
arguments[i].__proto__ = middleware[_protos[i]].proto
setPrototypeOf(arguments[i], middleware[_protos[i]].proto)
}
}

Expand All @@ -50,9 +51,10 @@ function Proto(protos, options) {
while (i--) {
var name = _protos[i]
var prop = middleware[name] = {
proto: { __proto__: protos[name].prototype }
proto: {}
, _opts: opts
}
setPrototypeOf(prop.proto, protos[name].prototype)
prop.defineProperty = defineProperty.bind(prop)
prop.defineProperties = defineProperties.bind(prop)
}
Expand All @@ -62,7 +64,7 @@ function Proto(protos, options) {


/**
* define a property onto the __proto__
* define a property onto the prototype
*/
function defineProperty(name, descriptor) {
if (!name) {
Expand Down Expand Up @@ -90,7 +92,7 @@ function defineProperty(name, descriptor) {


/**
* define properties on __proto__ via an object map
* define properties on prototype via an object map
*/
function defineProperties(props) {
if (!props) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"inject"
],
"dependencies": {
"setprototypeof": "^1.0.1"
},
"devDependencies": {
"mocha": "^2.0.1",
Expand Down

0 comments on commit f6d9955

Please sign in to comment.