forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.ts
More file actions
21 lines (21 loc) · 677 Bytes
/
object.ts
File metadata and controls
21 lines (21 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export class Object {
static is<T>(value1: T, value2: T): bool {
if (isFloat<T>()) {
if (value1 == value2) {
// 0 === -0, but they are not identical
if (sizeof<T>() == 8) {
// @ts-ignore: typecast
return reinterpret<u64>(value1) == reinterpret<u64>(value2);
} else {
// @ts-ignore: typecast
return reinterpret<u32>(value1) == reinterpret<u32>(value2);
}
}
// NaN !== NaN, but they are identical.
// @ts-ignore: typecast
return bool(i32(isNaN(value1)) & i32(isNaN(value2)));
}
// For references, strings, integers and booleans
return value1 == value2;
}
}