refactor(core): replace instanceof Array (#33077)

PR Close #33077
This commit is contained in:
Nikita Potapenko
2019-10-10 12:03:27 +03:00
committed by Miško Hevery
parent 10dcbcf45d
commit 72494c4411
6 changed files with 9 additions and 9 deletions

View File

@ -230,7 +230,7 @@ function recursivelyProcessProviders(records: Map<any, Record>, provider: Static
let scope: string|null = null;
if (provider) {
provider = resolveForwardRef(provider);
if (provider instanceof Array) {
if (Array.isArray(provider)) {
// if we have an array recurse into the array
for (let i = 0; i < provider.length; i++) {
scope = recursivelyProcessProviders(records, provider[i]) || scope;
@ -359,7 +359,7 @@ function computeDeps(provider: StaticProvider): DependencyRecord[] {
for (let i = 0; i < providerDeps.length; i++) {
let options = OptionFlags.Default;
let token = resolveForwardRef(providerDeps[i]);
if (token instanceof Array) {
if (Array.isArray(token)) {
for (let j = 0, annotations = token; j < annotations.length; j++) {
const annotation = annotations[j];
if (annotation instanceof Optional || annotation == Optional) {

View File

@ -227,7 +227,7 @@ export function formatError(
text: string, obj: any, injectorErrorName: string, source: string | null = null): string {
text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text;
let context = stringify(obj);
if (obj instanceof Array) {
if (Array.isArray(obj)) {
context = obj.map(stringify).join(' -> ');
} else if (typeof obj === 'object') {
let parts = <string[]>[];

View File

@ -189,7 +189,7 @@ function _normalizeProviders(
} else if (b && typeof b == 'object' && (b as any).provide !== undefined) {
res.push(b as NormalizedProvider);
} else if (b instanceof Array) {
} else if (Array.isArray(b)) {
_normalizeProviders(b, res);
} else {