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
`copyWithin(array, ~target, ~start, ~end)` copies the sequence of array elements within the array to the position starting at `target`. The copy is taken from the index positions `start` to `end`.
93
+
94
+
Beware this will *mutate* the array.
95
+
96
+
See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN.
`indexOf(array, item)` returns the index of the provided `item` in `array`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.
441
+
`indexOf(array, item, ~from)` returns the index of the provided `item` in `array`, starting the search at `from`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.
420
442
421
-
Returns `-1` if the item doesn not exist. Check out `Array.indexOfOpt` for a version that returns `None` instead of `-1` if the item does not exist.
443
+
Returns `-1` if the item isn't found. Check out `Array.indexOfOpt` for a version that returns `None` instead of `-1` if the item does not exist.
422
444
423
445
See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN.
424
446
@@ -427,12 +449,13 @@ See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
427
449
```rescript
428
450
[1, 2]->Array.indexOf(2) == 1
429
451
[1, 2]->Array.indexOf(3) == -1
452
+
[1, 2, 1, 2]->Array.indexOf(2, ~from=2) == 3
430
453
431
454
[{"language": "ReScript"}]->Array.indexOf({"language": "ReScript"}) == -1 // -1, because of strict equality
`indexOfOpt(array, item)` returns an option of the index of the provided `item` in `array`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.
@@ -448,7 +471,8 @@ See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
`join(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items.
`lastIndexOf(array, item, ~from)` returns the last index of the provided `item` in `array`, searching backwards from `from`. Uses [strict check for equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality) when comparing items.
530
+
531
+
Returns `-1` if the item isn't found. Check out `Array.lastIndexOfOpt` for a version that returns `None` instead of `-1` if the item does not exist.
532
+
533
+
See [`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) on MDN.
534
+
535
+
## Examples
536
+
537
+
```rescript
538
+
[1, 2, 1, 2]->Array.lastIndexOf(2) == 3
539
+
[1, 2]->Array.lastIndexOf(3) == -1
540
+
[1, 2, 1, 2]->Array.lastIndexOf(2, ~from=2) == 1
541
+
542
+
[{"language": "ReScript"}]->Array.lastIndexOf({"language": "ReScript"}) == -1 // -1, because of strict equality
/** `fromBuffer` creates a `BigInt64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
18
18
19
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
19
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromBufferToEnd` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
25
26
26
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
27
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromBufferWithRange` creates a `BigInt64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
32
33
33
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
34
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromLength` creates a zero-initialized `BigInt64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
40
41
41
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
42
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
42
43
*/
43
44
@new
44
45
externalfromLength: int=>t="BigInt64Array"
45
46
46
47
/** `fromArrayLikeOrIterable` creates a `BigInt64Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)
/** `fromArrayLikeOrIterableWithMap` creates a `BigInt64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)
/** `fromBuffer` creates a `BigUint64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)
18
18
19
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
19
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromBufferToEnd` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and continuing through to the end. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)
25
26
26
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
27
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromBufferWithRange` creates a `BigUint64Array` from an `ArrayBuffer.t`, starting at a particular offset and consuming `length` **bytes**. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)
32
33
33
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
34
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
/** `fromLength` creates a zero-initialized `BigUint64Array` to hold the specified count of numbers; this is **not** a byte length. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array/BigUint64Array)
40
41
41
-
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
42
+
**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
42
43
*/
43
44
@new
44
45
externalfromLength: int=>t="BigUint64Array"
45
46
46
47
/** `fromArrayLikeOrIterable` creates a `BigUint64Array` from an array-like or iterable object. See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)
/** `fromArrayLikeOrIterableWithMap` creates a `BigUint64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)
0 commit comments