Don't use the for..of syntax in AtScript.
This commit is contained in:
parent
15afb80a2f
commit
ab42664e76
@ -93,9 +93,9 @@ export class ListWrapper {
|
|||||||
static map(array, fn) {
|
static map(array, fn) {
|
||||||
return array.map(fn);
|
return array.map(fn);
|
||||||
}
|
}
|
||||||
static forEach(array, fn) {
|
static forEach(array:List, fn:Function) {
|
||||||
for(var p of array) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
fn(p);
|
fn(array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static push(array, el) {
|
static push(array, el) {
|
||||||
@ -198,8 +198,16 @@ export function isListLikeIterable(obj):boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function iterateListLike(obj, fn:Function) {
|
export function iterateListLike(obj, fn:Function) {
|
||||||
for (var item of obj) {
|
if (ListWrapper.isList(obj)) {
|
||||||
fn(item);
|
for (var i = 0; i < obj.length; i++) {
|
||||||
|
fn(obj[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var iterator = obj[Symbol.iterator]();
|
||||||
|
var item;
|
||||||
|
while (!((item = iterator.next()).done)) {
|
||||||
|
fn(item.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +259,8 @@ var number = type.number = define('number', function(value) {
|
|||||||
function arrayOf(...types) {
|
function arrayOf(...types) {
|
||||||
return assert.define('array of ' + types.map(prettyPrint).join('/'), function(value) {
|
return assert.define('array of ' + types.map(prettyPrint).join('/'), function(value) {
|
||||||
if (assert(value).is(Array)) {
|
if (assert(value).is(Array)) {
|
||||||
for (var item of value) {
|
for (var i = 0; i < value.length; i++) {
|
||||||
assert(item).is(...types);
|
assert(value[i]).is(...types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -270,7 +270,8 @@ function structure(definition) {
|
|||||||
var properties = Object.keys(definition);
|
var properties = Object.keys(definition);
|
||||||
return assert.define('object with properties ' + properties.join(', '), function(value) {
|
return assert.define('object with properties ' + properties.join(', '), function(value) {
|
||||||
if (assert(value).is(Object)) {
|
if (assert(value).is(Object)) {
|
||||||
for (var property of properties) {
|
for (var i = 0; i < properties.length; i++) {
|
||||||
|
var property = properties[i];
|
||||||
assert(value[property]).is(definition[property]);
|
assert(value[property]).is(definition[property]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,8 +319,8 @@ function assert(value) {
|
|||||||
// var errors = []
|
// var errors = []
|
||||||
var allErrors = [];
|
var allErrors = [];
|
||||||
var errors;
|
var errors;
|
||||||
|
for (var i = 0; i < types.length; i++) {
|
||||||
for (var type of types) {
|
var type = types[i];
|
||||||
errors = [];
|
errors = [];
|
||||||
|
|
||||||
if (isType(value, type, errors)) {
|
if (isType(value, type, errors)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user