mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 16:31:32 +00:00
Add isArrayLike builtin (#453)
This commit is contained in:
@ -215,6 +215,13 @@ globalScope["isString"] = function isString(arg) {
|
||||
};
|
||||
|
||||
globalScope["isArray"] = Array.isArray;
|
||||
globalScope["isArrayLike"] = function isArrayLike(expr) {
|
||||
return expr
|
||||
&& typeof expr === 'object'
|
||||
&& typeof expr.length === 'number'
|
||||
&& expr.length >= 0
|
||||
&& Math.trunc(expr.length) === expr.length;
|
||||
}
|
||||
|
||||
globalScope["isDefined"] = function isDefined(expr) {
|
||||
return typeof expr !== "undefined";
|
||||
|
Reference in New Issue
Block a user