-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid
instanceof
where it's possible since .prototype
and `@@hasI…
…nstance` can be replaced
- Loading branch information
Showing
78 changed files
with
291 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
var arrayAt = require('../array/virtual/at'); | ||
var stringAt = require('../string/virtual/at'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var arrayMethod = require('../array/virtual/at'); | ||
var stringMethod = require('../string/virtual/at'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.at; | ||
if (it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.at)) return arrayAt; | ||
if (typeof it == 'string' || it === StringPrototype || (it instanceof String && own === StringPrototype.at)) { | ||
return stringAt; | ||
if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.at)) return arrayMethod; | ||
if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.at)) { | ||
return stringMethod; | ||
} return own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var bind = require('../function/virtual/bind'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../function/virtual/bind'); | ||
|
||
var FunctionPrototype = Function.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.bind; | ||
return it === FunctionPrototype || (it instanceof Function && own === FunctionPrototype.bind) ? bind : own; | ||
return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var codePointAt = require('../string/virtual/code-point-at'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/code-point-at'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.codePointAt; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.codePointAt) ? codePointAt : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.codePointAt) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var concat = require('../array/virtual/concat'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/concat'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.concat; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.concat) ? concat : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var copyWithin = require('../array/virtual/copy-within'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/copy-within'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.copyWithin; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.copyWithin) ? copyWithin : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.copyWithin) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var endsWith = require('../string/virtual/ends-with'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/ends-with'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.endsWith; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.endsWith) ? endsWith : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.endsWith) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var entries = require('../array/virtual/entries'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/entries'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.entries; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.entries) ? entries : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var every = require('../array/virtual/every'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/every'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.every; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.every) ? every : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var fill = require('../array/virtual/fill'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/fill'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.fill; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.fill) ? fill : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.fill) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var filter = require('../array/virtual/filter'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/filter'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.filter; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.filter) ? filter : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var findIndex = require('../array/virtual/find-index'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/find-index'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.findIndex; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.findIndex) ? findIndex : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var find = require('../array/virtual/find'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/find'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.find; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.find) ? find : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var flags = require('../regexp/flags'); | ||
|
||
var RegExpPrototype = RegExp.prototype; | ||
|
||
module.exports = function (it) { | ||
return (it === RegExpPrototype || it instanceof RegExp) && !('flags' in it) ? flags(it) : it.flags; | ||
return (it === RegExpPrototype || isPrototypeOf(RegExpPrototype, it)) ? flags(it) : it.flags; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var flatMap = require('../array/virtual/flat-map'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/flat-map'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.flatMap; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.flatMap) ? flatMap : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.flatMap) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var flat = require('../array/virtual/flat'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/flat'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.flat; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.flat) ? flat : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.flat) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var forEach = require('../array/virtual/for-each'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/for-each'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.forEach; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.forEach) ? forEach : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
var arrayIncludes = require('../array/virtual/includes'); | ||
var stringIncludes = require('../string/virtual/includes'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var arrayMethod = require('../array/virtual/includes'); | ||
var stringMethod = require('../string/virtual/includes'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.includes; | ||
if (it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.includes)) return arrayIncludes; | ||
if (typeof it == 'string' || it === StringPrototype || (it instanceof String && own === StringPrototype.includes)) { | ||
return stringIncludes; | ||
if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod; | ||
if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) { | ||
return stringMethod; | ||
} return own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var indexOf = require('../array/virtual/index-of'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/index-of'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.indexOf; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.indexOf) ? indexOf : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var keys = require('../array/virtual/keys'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/keys'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.keys; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.keys) ? keys : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var lastIndexOf = require('../array/virtual/last-index-of'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/last-index-of'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.lastIndexOf; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.lastIndexOf) ? lastIndexOf : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.lastIndexOf) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var map = require('../array/virtual/map'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/map'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.map; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.map) ? map : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var matchAll = require('../string/virtual/match-all'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/match-all'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.matchAll; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.matchAll) ? matchAll : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.matchAll) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var padEnd = require('../string/virtual/pad-end'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/pad-end'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.padEnd; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.padEnd) ? padEnd : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.padEnd) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var padStart = require('../string/virtual/pad-start'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/pad-start'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.padStart; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.padStart) ? padStart : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.padStart) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var reduceRight = require('../array/virtual/reduce-right'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/reduce-right'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.reduceRight; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.reduceRight) ? reduceRight : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduceRight) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var reduce = require('../array/virtual/reduce'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../array/virtual/reduce'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.reduce; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.reduce) ? reduce : own; | ||
return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
var repeat = require('../string/virtual/repeat'); | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/repeat'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.repeat; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (it instanceof String && own === StringPrototype.repeat) ? repeat : own; | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.repeat) ? method : own; | ||
}; |
Oops, something went wrong.