Skip to content

Commit 0e12d7a

Browse files
authored
fix: Switch to bool instead of boolean in DataView (#1647)
1 parent 027f938 commit 0e12d7a

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

std/assembly/dataview.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class DataView {
2929
this.byteLength = byteLength;
3030
}
3131

32-
getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {
32+
getFloat32(byteOffset: i32, littleEndian: bool = false): f32 {
3333
if (
3434
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
3535
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -38,7 +38,7 @@ export class DataView {
3838
: reinterpret<f32>(bswap<u32>(load<u32>(this.dataStart + <usize>byteOffset)));
3939
}
4040

41-
getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {
41+
getFloat64(byteOffset: i32, littleEndian: bool = false): f64 {
4242
if (
4343
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
4444
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -52,15 +52,15 @@ export class DataView {
5252
return load<i8>(this.dataStart + <usize>byteOffset);
5353
}
5454

55-
getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {
55+
getInt16(byteOffset: i32, littleEndian: bool = false): i16 {
5656
if (
5757
(byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)
5858
) throw new RangeError(E_INDEXOUTOFRANGE);
5959
var result: i16 = load<i16>(this.dataStart + <usize>byteOffset);
6060
return littleEndian ? result : bswap<i16>(result);
6161
}
6262

63-
getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {
63+
getInt32(byteOffset: i32, littleEndian: bool = false): i32 {
6464
if (
6565
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
6666
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -73,31 +73,31 @@ export class DataView {
7373
return load<u8>(this.dataStart + <usize>byteOffset);
7474
}
7575

76-
getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {
76+
getUint16(byteOffset: i32, littleEndian: bool = false): u16 {
7777
if (
7878
(byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)
7979
) throw new RangeError(E_INDEXOUTOFRANGE);
8080
var result: u16 = load<u16>(this.dataStart + <usize>byteOffset);
8181
return littleEndian ? result : bswap<u16>(result);
8282
}
8383

84-
getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {
84+
getUint32(byteOffset: i32, littleEndian: bool = false): u32 {
8585
if (
8686
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
8787
) throw new RangeError(E_INDEXOUTOFRANGE);
8888
var result: u32 = load<u32>(this.dataStart + <usize>byteOffset);
8989
return littleEndian ? result : bswap<u32>(result);
9090
}
9191

92-
setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {
92+
setFloat32(byteOffset: i32, value: f32, littleEndian: bool = false): void {
9393
if (
9494
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
9595
) throw new RangeError(E_INDEXOUTOFRANGE);
9696
if (littleEndian) store<f32>(this.dataStart + <usize>byteOffset, value);
9797
else store<u32>(this.dataStart + <usize>byteOffset, bswap<u32>(reinterpret<u32>(value)));
9898
}
9999

100-
setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {
100+
setFloat64(byteOffset: i32, value: f64, littleEndian: bool = false): void {
101101
if (
102102
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
103103
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -110,14 +110,14 @@ export class DataView {
110110
store<i8>(this.dataStart + <usize>byteOffset, value);
111111
}
112112

113-
setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {
113+
setInt16(byteOffset: i32, value: i16, littleEndian: bool = false): void {
114114
if (
115115
(byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)
116116
) throw new RangeError(E_INDEXOUTOFRANGE);
117117
store<i16>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<i16>(value));
118118
}
119119

120-
setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {
120+
setInt32(byteOffset: i32, value: i32, littleEndian: bool = false): void {
121121
if (
122122
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
123123
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -129,14 +129,14 @@ export class DataView {
129129
store<u8>(this.dataStart + <usize>byteOffset, value);
130130
}
131131

132-
setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {
132+
setUint16(byteOffset: i32, value: u16, littleEndian: bool = false): void {
133133
if (
134134
(byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)
135135
) throw new RangeError(E_INDEXOUTOFRANGE);
136136
store<u16>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<u16>(value));
137137
}
138138

139-
setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {
139+
setUint32(byteOffset: i32, value: u32, littleEndian: bool = false): void {
140140
if (
141141
(byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)
142142
) throw new RangeError(E_INDEXOUTOFRANGE);
@@ -145,30 +145,30 @@ export class DataView {
145145

146146
// Non-standard additions that make sense in WebAssembly, but won't work in JS:
147147

148-
getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {
148+
getInt64(byteOffset: i32, littleEndian: bool = false): i64 {
149149
if (
150150
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
151151
) throw new RangeError(E_INDEXOUTOFRANGE);
152152
var result: i64 = load<i64>(this.dataStart + <usize>byteOffset);
153153
return littleEndian ? result : bswap<i64>(result);
154154
}
155155

156-
getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {
156+
getUint64(byteOffset: i32, littleEndian: bool = false): u64 {
157157
if (
158158
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
159159
) throw new RangeError(E_INDEXOUTOFRANGE);
160160
var result = load<u64>(this.dataStart + <usize>byteOffset);
161161
return littleEndian ? result : bswap<u64>(result);
162162
}
163163

164-
setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {
164+
setInt64(byteOffset: i32, value: i64, littleEndian: bool = false): void {
165165
if (
166166
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
167167
) throw new RangeError(E_INDEXOUTOFRANGE);
168168
store<i64>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<i64>(value));
169169
}
170170

171-
setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {
171+
setUint64(byteOffset: i32, value: u64, littleEndian: bool = false): void {
172172
if (
173173
(byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)
174174
) throw new RangeError(E_INDEXOUTOFRANGE);

std/assembly/index.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,45 +1387,45 @@ declare class DataView {
13871387
/** Constructs a new `DataView` with the given properties */
13881388
constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);
13891389
/** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */
1390-
getFloat32(byteOffset: i32, littleEndian?: boolean): f32;
1390+
getFloat32(byteOffset: i32, littleEndian?: bool): f32;
13911391
/** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */
1392-
getFloat64(byteOffset: i32, littleEndian?: boolean): f64;
1392+
getFloat64(byteOffset: i32, littleEndian?: bool): f64;
13931393
/** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */
13941394
getInt8(byteOffset: i32): i8;
13951395
/** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */
1396-
getInt16(byteOffset: i32, littleEndian?: boolean): i16;
1396+
getInt16(byteOffset: i32, littleEndian?: bool): i16;
13971397
/** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */
1398-
getInt32(byteOffset: i32, littleEndian?: boolean): i32;
1398+
getInt32(byteOffset: i32, littleEndian?: bool): i32;
13991399
/** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */
1400-
getInt64(byteOffset: i32, littleEndian?: boolean): i64;
1400+
getInt64(byteOffset: i32, littleEndian?: bool): i64;
14011401
/** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */
14021402
getUint8(byteOffset: i32): u8;
14031403
/** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */
1404-
getUint16(byteOffset: i32, littleEndian?: boolean): u16;
1404+
getUint16(byteOffset: i32, littleEndian?: bool): u16;
14051405
/** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */
1406-
getUint32(byteOffset: i32, littleEndian?: boolean): u32;
1406+
getUint32(byteOffset: i32, littleEndian?: bool): u32;
14071407
/** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */
1408-
getUint64(byteOffset: i32, littleEndian?: boolean): u64;
1408+
getUint64(byteOffset: i32, littleEndian?: bool): u64;
14091409
/** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */
1410-
setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;
1410+
setFloat32(byteOffset: i32, value: f32, littleEndian?: bool): void;
14111411
/** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */
1412-
setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;
1412+
setFloat64(byteOffset: i32, value: f64, littleEndian?: bool): void;
14131413
/** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */
14141414
setInt8(byteOffset: i32, value: i8): void;
14151415
/** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */
1416-
setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;
1416+
setInt16(byteOffset: i32, value: i16, littleEndian?: bool): void;
14171417
/** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */
1418-
setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;
1418+
setInt32(byteOffset: i32, value: i32, littleEndian?: bool): void;
14191419
/** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */
1420-
setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void;
1420+
setInt64(byteOffset: i32, value: i64, littleEndian?: bool): void;
14211421
/** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */
14221422
setUint8(byteOffset: i32, value: u8): void;
14231423
/** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */
1424-
setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;
1424+
setUint16(byteOffset: i32, value: u16, littleEndian?: bool): void;
14251425
/** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */
1426-
setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;
1426+
setUint32(byteOffset: i32, value: u32, littleEndian?: bool): void;
14271427
/** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */
1428-
setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void;
1428+
setUint64(byteOffset: i32, value: u64, littleEndian?: bool): void;
14291429
/** Returns a string representation of DataView. */
14301430
toString(): string;
14311431
}

0 commit comments

Comments
 (0)