Skip to content

Commit

Permalink
Should also work with objects
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredwesterveld committed Jul 4, 2014
1 parent f9a4052 commit b06ed2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Expand Up @@ -6,8 +6,10 @@ const util = require("util")

// used http://stackoverflow.com/a/2946616/11926 as baseline
function getAllMethods(object) {
return Object.getOwnPropertyNames(object.prototype).filter(function(property) {
return typeof object.prototype[property] === "function"
const obj = object.prototype || object

return Object.getOwnPropertyNames(obj).filter(function(property) {
return typeof obj[property] === "function"
})
}

Expand Down
5 changes: 5 additions & 0 deletions test/test.implement.js
Expand Up @@ -41,4 +41,9 @@ describe("implement", function () {
done()
}
})

it("Should also work with objects", function (done) {
implement(new ArrayQueue(), new Queue())
done()
})
})

0 comments on commit b06ed2b

Please sign in to comment.