Skip to content

Commit

Permalink
Merge pull request #15 from tjmehta/replace-instanceof-object
Browse files Browse the repository at this point in the history
replace instanceof checks w/ typeof for more robust behavior
  • Loading branch information
tjmehta committed Mar 15, 2016
2 parents 6244abf + 2e5336d commit 7d3035f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion every.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function every (obj, callback, thisArg) {
if (Array.isArray(obj)) {
return obj.every(callback, thisArg)
}
if (!(obj instanceof Object)) {
if (typeof obj !== 'object' && typeof obj !== 'function') {
throw new TypeError(obj + ' must be an object')
}
if (typeof callback !== 'function') {
Expand Down
2 changes: 1 addition & 1 deletion for-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function forEach (obj, callback, thisArg) {
if (Array.isArray(obj)) {
return obj.forEach(callback, thisArg)
}
if (!(obj instanceof Object)) {
if (typeof obj !== 'object' && typeof obj !== 'function') {
throw new TypeError(obj + ' must be an object')
}
if (typeof callback !== 'function') {
Expand Down
2 changes: 1 addition & 1 deletion reduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function reduce (obj, callback, initialValue) {
? obj.reduce(callback, initialValue)
: obj.reduce(callback)
}
if (!(obj instanceof Object)) {
if (typeof obj !== 'object' && typeof obj !== 'function') {
throw new TypeError(obj + ' must be an object')
}
if (typeof callback !== 'function') {
Expand Down
2 changes: 1 addition & 1 deletion some.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function some (obj, callback, thisArg) {
if (Array.isArray(obj)) {
return obj.some(callback, thisArg)
}
if (!(obj instanceof Object)) {
if (typeof obj !== 'object' && typeof obj !== 'function') {
throw new TypeError(obj + ' must be an object')
}
if (typeof callback !== 'function') {
Expand Down

0 comments on commit 7d3035f

Please sign in to comment.