@@ -11,7 +11,7 @@ export const Array = function (...args: any[]): any[] {
11
11
if ( argsLen == 1 ) {
12
12
// 1 arg, length (number) or first element (non-number)
13
13
const arg : any = args [ 0 ] ;
14
- if ( Porffor . rawType ( arg ) == Porffor . TYPES . number ) {
14
+ if ( Porffor . type ( arg ) == Porffor . TYPES . number ) {
15
15
// number so use as length
16
16
const n : number = args [ 0 ] ;
17
17
if ( Porffor . fastOr (
@@ -33,24 +33,24 @@ export const Array = function (...args: any[]): any[] {
33
33
} ;
34
34
35
35
export const __Array_isArray = ( x : unknown ) : boolean =>
36
- Porffor . rawType ( x ) == Porffor . TYPES . array ;
36
+ Porffor . type ( x ) == Porffor . TYPES . array ;
37
37
38
38
export const __Array_from = ( arg : any , mapFn : any ) : any [ ] => {
39
39
if ( arg == null ) throw new TypeError ( 'Argument cannot be nullish' ) ;
40
40
41
41
let out : any [ ] = Porffor . allocate ( ) ;
42
42
let len : i32 = 0 ;
43
43
44
- const type = Porffor . rawType ( arg ) ;
44
+ const type = Porffor . type ( arg ) ;
45
45
if ( Porffor . fastOr (
46
46
type == Porffor . TYPES . array ,
47
47
type == Porffor . TYPES . string , type == Porffor . TYPES . bytestring ,
48
48
type == Porffor . TYPES . set ,
49
49
Porffor . fastAnd ( type >= Porffor . TYPES . uint8array , type <= Porffor . TYPES . float64array )
50
50
) ) {
51
51
let i : i32 = 0 ;
52
- if ( Porffor . rawType ( mapFn ) != Porffor . TYPES . undefined ) {
53
- if ( Porffor . rawType ( mapFn ) != Porffor . TYPES . function ) throw new TypeError ( 'Called Array.from with a non-function mapFn' ) ;
52
+ if ( Porffor . type ( mapFn ) != Porffor . TYPES . undefined ) {
53
+ if ( Porffor . type ( mapFn ) != Porffor . TYPES . function ) throw new TypeError ( 'Called Array.from with a non-function mapFn' ) ;
54
54
55
55
for ( const x of arg ) {
56
56
out [ i ] = mapFn ( x , i ) ;
@@ -132,7 +132,7 @@ memory.copy 0 0`;
132
132
133
133
export const __Array_prototype_slice = ( _this : any [ ] , _start : any , _end : any ) => {
134
134
const len : i32 = _this . length ;
135
- if ( Porffor . rawType ( _end ) == Porffor . TYPES . undefined ) _end = len ;
135
+ if ( Porffor . type ( _end ) == Porffor . TYPES . undefined ) _end = len ;
136
136
137
137
let start : i32 = ecma262 . ToIntegerOrInfinity ( _start ) ;
138
138
let end : i32 = ecma262 . ToIntegerOrInfinity ( _end ) ;
@@ -181,7 +181,7 @@ export const __Array_prototype_splice = (_this: any[], _start: any, _deleteCount
181
181
}
182
182
if ( start > len ) start = len ;
183
183
184
- if ( Porffor . rawType ( _deleteCount ) == Porffor . TYPES . undefined ) _deleteCount = len - start ;
184
+ if ( Porffor . type ( _deleteCount ) == Porffor . TYPES . undefined ) _deleteCount = len - start ;
185
185
let deleteCount : i32 = ecma262 . ToIntegerOrInfinity ( _deleteCount ) ;
186
186
187
187
if ( deleteCount < 0 ) deleteCount = 0 ;
@@ -272,8 +272,8 @@ memory.copy 0 0`;
272
272
export const __Array_prototype_fill = ( _this : any [ ] , value : any , _start : any , _end : any ) => {
273
273
const len : i32 = _this . length ;
274
274
275
- if ( Porffor . rawType ( _start ) == Porffor . TYPES . undefined ) _start = 0 ;
276
- if ( Porffor . rawType ( _end ) == Porffor . TYPES . undefined ) _end = len ;
275
+ if ( Porffor . type ( _start ) == Porffor . TYPES . undefined ) _start = 0 ;
276
+ if ( Porffor . type ( _end ) == Porffor . TYPES . undefined ) _end = len ;
277
277
278
278
let start : i32 = ecma262 . ToIntegerOrInfinity ( _start ) ;
279
279
let end : i32 = ecma262 . ToIntegerOrInfinity ( _end ) ;
@@ -392,7 +392,7 @@ export const __Array_prototype_copyWithin = (_this: any[], _target: any, _start:
392
392
if ( start > len ) start = len ;
393
393
394
394
let end : i32 ;
395
- if ( Porffor . rawType ( _end ) == Porffor . TYPES . undefined ) {
395
+ if ( Porffor . type ( _end ) == Porffor . TYPES . undefined ) {
396
396
end = len ;
397
397
} else {
398
398
end = ecma262 . ToIntegerOrInfinity ( _end ) ;
@@ -419,7 +419,7 @@ export const __Array_prototype_concat = (_this: any[], ...vals: any[]) => {
419
419
let len : i32 = _this . length ;
420
420
421
421
for ( const x of vals ) {
422
- if ( Porffor . rawType ( x ) & 0b01000000 ) { // value is iterable
422
+ if ( Porffor . type ( x ) & 0b01000000 ) { // value is iterable
423
423
// todo: for..of is broken here because ??
424
424
const l : i32 = x . length ;
425
425
for ( let i : i32 = 0 ; i < l ; i ++ ) {
@@ -497,7 +497,7 @@ export const __Array_prototype_flatMap = (_this: any[], callbackFn: any, thisArg
497
497
let i : i32 = 0 , j : i32 = 0 ;
498
498
while ( i < len ) {
499
499
let x : any = callbackFn . call ( thisArg , _this [ i ] , i ++ , _this ) ;
500
- if ( Porffor . rawType ( x ) == Porffor . TYPES . array ) {
500
+ if ( Porffor . type ( x ) == Porffor . TYPES . array ) {
501
501
for ( const y of x ) out [ j ++ ] = y ;
502
502
} else out [ j ++ ] = x ;
503
503
}
@@ -646,8 +646,8 @@ export const __Array_prototype_sort = (_this: any[], callbackFn: any) => {
646
646
647
647
// 23.1.3.30.2 CompareArrayElements (x, y, comparefn)
648
648
// https://tc39.es/ecma262/#sec-comparearrayelements
649
- const xt : i32 = Porffor . rawType ( x ) ;
650
- const yt : i32 = Porffor . rawType ( y ) ;
649
+ const xt : i32 = Porffor . type ( x ) ;
650
+ const yt : i32 = Porffor . type ( y ) ;
651
651
let v : number ;
652
652
653
653
// 1. If x and y are both undefined, return +0π½.
@@ -690,7 +690,7 @@ export const __Array_prototype_toString = (_this: any[]) => {
690
690
if ( i > 0 ) Porffor . bytestring . appendChar ( out , 44 ) ;
691
691
692
692
const element : any = _this [ i ++ ] ;
693
- const type : i32 = Porffor . rawType ( element ) ;
693
+ const type : i32 = Porffor . type ( element ) ;
694
694
if ( element != 0 || Porffor . fastAnd (
695
695
type != Porffor . TYPES . undefined , // undefined
696
696
type != Porffor . TYPES . object // null
@@ -712,7 +712,7 @@ export const __Array_prototype_join = (_this: any[], _separator: any) => {
712
712
// todo/perf: optimize default separator (?)
713
713
714
714
let separator : bytestring = ',' ;
715
- if ( Porffor . rawType ( _separator ) != Porffor . TYPES . undefined )
715
+ if ( Porffor . type ( _separator ) != Porffor . TYPES . undefined )
716
716
separator = ecma262 . ToString ( _separator ) ;
717
717
718
718
let out : bytestring = Porffor . allocate ( ) ;
@@ -722,7 +722,7 @@ export const __Array_prototype_join = (_this: any[], _separator: any) => {
722
722
if ( i > 0 ) Porffor . bytestring . appendStr ( out , separator ) ;
723
723
724
724
const element : any = _this [ i ++ ] ;
725
- const type : i32 = Porffor . rawType ( element ) ;
725
+ const type : i32 = Porffor . type ( element ) ;
726
726
if ( element != 0 || Porffor . fastAnd (
727
727
type != Porffor . TYPES . undefined , // undefined
728
728
type != Porffor . TYPES . object // null
@@ -780,7 +780,7 @@ export const __Array_prototype_toSpliced = (_this: any[], _start: any, _deleteCo
780
780
}
781
781
if ( start > len ) start = len ;
782
782
783
- if ( Porffor . rawType ( _deleteCount ) == Porffor . TYPES . undefined ) _deleteCount = len - start ;
783
+ if ( Porffor . type ( _deleteCount ) == Porffor . TYPES . undefined ) _deleteCount = len - start ;
784
784
let deleteCount : i32 = ecma262 . ToIntegerOrInfinity ( _deleteCount ) ;
785
785
786
786
if ( deleteCount < 0 ) deleteCount = 0 ;
@@ -853,7 +853,7 @@ memory.copy 0 0`;
853
853
854
854
855
855
export const __Array_prototype_flat = ( _this : any [ ] , _depth : any ) => {
856
- if ( Porffor . rawType ( _depth ) == Porffor . TYPES . undefined ) _depth = 1 ;
856
+ if ( Porffor . type ( _depth ) == Porffor . TYPES . undefined ) _depth = 1 ;
857
857
let depth : i32 = ecma262 . ToIntegerOrInfinity ( _depth ) ;
858
858
859
859
let out : any [ ] = Porffor . allocate ( ) ;
@@ -866,7 +866,7 @@ export const __Array_prototype_flat = (_this: any[], _depth: any) => {
866
866
let i : i32 = 0 , j : i32 = 0 ;
867
867
while ( i < len ) {
868
868
let x : any = _this [ i ++ ] ;
869
- if ( Porffor . rawType ( x ) == Porffor . TYPES . array ) {
869
+ if ( Porffor . type ( x ) == Porffor . TYPES . array ) {
870
870
if ( depth > 1 ) x = __Array_prototype_flat ( x , depth - 1 ) ;
871
871
for ( const y of x ) out [ j ++ ] = y ;
872
872
} else out [ j ++ ] = x ;
0 commit comments