Skip to content

Commit fdd48f6

Browse files
RubenVerborghrubensworks
authored andcommitted
Fix Array checks.
1 parent b685468 commit fdd48f6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/Util.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ class Util {
137137
if (!value) {
138138
value = [];
139139
}
140-
if (!(value instanceof Array)) {
140+
if (!Array.isArray(value)) {
141141
throw new Error('Values must be an array\n' + NodeUtil.inspect(param));
142142
}
143143
param.fixed.forEach((f: any) => value.push(f));
144144
}
145145
}
146146

147147
// If the value is singular, and the value should be unique, transform the array to a single element
148-
if (param.unique && param.unique.value === 'true' && value instanceof Array) {
148+
if (param.unique && param.unique.value === 'true' && Array.isArray(value)) {
149149
value = value[0];
150150
}
151151

152152
// If a param range is defined, apply the type and validate the range.
153153
if (param.range) {
154-
if (value instanceof Array) {
154+
if (Array.isArray(value)) {
155155
value = value.map((e) => Util.captureType(e, param));
156156
} else {
157157
value = Util.captureType(value, param);
@@ -570,4 +570,4 @@ class Util {
570570
}
571571
}
572572

573-
export = Util;
573+
export = Util;

lib/factory/MappedNamedComponentFactory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class MappedNamedComponentFactory extends UnnamedComponentFactory {
106106
return new Resource(null, {
107107
fields: resource.fields.reduce((fields: any[], field: any) => {
108108
let mapped: any = MappedNamedComponentFactory.map(resourceScope, field, params);
109-
if (mapped instanceof Array) {
109+
if (Array.isArray(mapped)) {
110110
fields = fields.concat(mapped);
111111
} else {
112112
fields.push(mapped);

lib/factory/UnnamedComponentFactory.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ export class UnnamedComponentFactory implements IComponentFactory {
8585
})).then((elements: any[]) => {
8686
var ret: any[] = [];
8787
elements.forEach((element) => {
88-
if (element instanceof Array) {
88+
if (Array.isArray(element)) {
8989
ret = ret.concat(element);
9090
} else {
9191
ret.push(element);
9292
}
9393
});
9494
resolve(ret);
9595
}).catch(reject);
96-
} else if (value instanceof Array) {
96+
} else if (Array.isArray(value)) {
9797
return Promise.all(value.map(
9898
(element) => UnnamedComponentFactory.getArgumentValue(element, componentRunner, settings)))
9999
.then(resolve).catch(reject);

0 commit comments

Comments
 (0)