You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `false`. Returns `true` if all functions returned `true` or the array is empty, otherwise `false`.
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array starting at the end until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array, returning a new array of the function's return values.
114
114
@@ -124,15 +124,15 @@ arr[0]; // now it works 😊
124
124
125
125
*```ts
126
126
function reduce<U>(
127
-
fn: (acc: U, cur: T, idx: i32, src: Array) => U,
127
+
fn: (accumValue: U, currentValue: T, index: i32, self: Array<T>) => U,
128
128
initialValue: U
129
129
): U
130
130
```
131
-
Callsthespecifiedreducerfunction with each value of the array, resulting in a single return value. The respective previous reducer function's return value is remembered in `acc`, starting with `initialValue`, becoming the final return value in the process.
131
+
Callsthespecifiedreducerfunction with each value of the array, resulting in a single return value. The respective previous reducer function's return value is remembered in `accumValue`, starting with `initialValue`, becoming the final return value in the process.
132
132
133
133
*```ts
134
134
function reduceRight<U>(
135
-
fn: (acc: U, cur: T, idx: i32, src: Array) => U,
135
+
fn: (accumValue: U, currentValue: T, index: i32, self: Array<T>) => U,
136
136
initialValue: U
137
137
): U
138
138
```
@@ -154,7 +154,7 @@ arr[0]; // now it works 😊
154
154
Returnsashallowcopyofthearray's values from `begin` inclusive to `end` exclusive, as a new array. If omitted, `end` defaults to the end of the array.
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning `true`. Returns `false` otherwise or if the array is empty.
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `false`. Returns `true` if all functions returned `true` or the array is empty, otherwise `false`.
65
+
66
+
*```ts
67
+
function fill(value: T, start?: i32, end?: i32): this
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array starting at the end until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array, returning a new array of the function's return values.
115
+
116
+
*```ts
117
+
function slice(start?: i32, end?: i32): Array<T>
78
118
```
79
119
Returnsashallowcopyofthisstaticarray's values from `begin` inclusive to `end` exclusive, as a new normal array. If omitted, `end` defaults to the end of the array.
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning `true`. Returns `false` otherwise or if the array is empty.
125
+
81
126
*```ts
82
127
function sort(fn?: (a: T, b: T) => i32): this
83
128
```
84
129
Sortsthevaluesofthearrayinplace, usingthespecifiedcomparatorfunction, modifying the array before returning it. The comparator returning a negative value means `a < b`, a positive value means `a > b` and `0` means that both are equal. Unlike in JavaScript, where an implicit conversion to strings is performed, the comparator defaults to compare two values of type `T`.
85
130
131
+
*```ts
132
+
function reduce<U>(
133
+
fn: (accumValue: U, currentValue: T, index: i32, self: StaticArray<T>) => U,
134
+
initialValue: U
135
+
): U
136
+
```
137
+
Callsthespecifiedreducerfunction with each value of the array, resulting in a single return value. The respective previous reducer function's return value is remembered in `accumValue`, starting with `initialValue`, becoming the final return value in the process.
138
+
139
+
*```ts
140
+
function reduceRight<U>(
141
+
fn: (accumValue: U, currentValue: T, index: i32, self: StaticArray<T>) => U,
142
+
initialValue: U
143
+
): U
144
+
```
145
+
Callsthespecifiedreducerfunction with each value of the array, from right to left, resulting in a single return value. See `Array#reduce` for the reducer function's signature.
146
+
147
+
*```ts
148
+
function reverse(): this
149
+
```
150
+
Reversesanarray's values in place, modifying the array before returning it.
Copy file name to clipboardExpand all lines: src/stdlib/typedarray.md
+11-23Lines changed: 11 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The TypedArray API works very much like JavaScript's \([MDN](https://developer.m
27
27
## Constructor
28
28
29
29
*```ts
30
-
newTypedArray<T>(length: i32)
30
+
newTypedArray(length: i32)
31
31
```
32
32
Constructs a new typed array view with a new backing buffer and all values initialized to zero. See `wrap` below for wrapping a raw buffer.
33
33
@@ -39,7 +39,7 @@ The TypedArray API works very much like JavaScript's \([MDN](https://developer.m
39
39
Number of bytes per element.
40
40
41
41
* ```ts
42
-
function wrap(buffer:ArrayBuffer, byteOffset?:i32, length?:i32):TypedArray<T>
42
+
function wrap(buffer:ArrayBuffer, byteOffset?:i32, length?:i32):TypedArray
43
43
```
44
44
Wraps a raw buffer to be viewed as a sequence of values of the typed array's value type. This is equivalent to the respective alternative constructor signature in JS but exists because there is no function overloading \(yet\).
45
45
@@ -70,9 +70,7 @@ The TypedArray API works very much like JavaScript's \([MDN](https://developer.m
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `false`. Returns `true` if all functions returned `true` or the array is empty, otherwise `false`.
78
76
@@ -82,23 +80,17 @@ The TypedArray API works very much like JavaScript's \([MDN](https://developer.m
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array starting at the end until it finds the first value for which the function returns `true`, returning its index. Returns `-1` if that's never the case.
Callsthespecifiedfunction with every value of the array, returning a new array of the function's return values.
126
116
127
117
*```ts
128
118
function reduce<U>(
129
-
fn: (acc: U, cur: T, idx: i32, src: Array) => U,
119
+
fn: (accumValue: U, currentValue T, index: i32, self: TypedArray) => U,
130
120
initialValue: U
131
121
): U
132
122
```
133
-
Callsthespecifiedreducerfunction with each value of the array, resulting in a single return value. The respective previous reducer function's return value is remembered in `acc`, starting with `initialValue`, becoming the final return value in the process.
123
+
Callsthespecifiedreducerfunction with each value of the array, resulting in a single return value. The respective previous reducer function's return value is remembered in `accumValue`, starting with `initialValue`, becoming the final return value in the process.
134
124
135
125
*```ts
136
126
function reduceRight<U>(
137
-
fn: (acc: U, cur: T, idx: i32, src: Array) => U,
127
+
fn: (accumValue: U, currentValue: T, index: i32, self: TypedArray) => U,
138
128
initialValue: U
139
129
): U
140
130
```
@@ -151,9 +141,7 @@ The TypedArray API works very much like JavaScript's \([MDN](https://developer.m
Callsthespecifiedfunction with every value of the array until it finds the first value for which the function returns `true`, returning `true`. Returns `false` otherwise or if the array is empty.
0 commit comments