File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 3
3
external getUnsafe : (array <'a >, int ) => 'a = "%array_unsafe_get"
4
4
external setUnsafe : (array <'a >, int , 'a ) => unit = "%array_unsafe_set"
5
5
6
+ external unsafe_get : (array <'a >, int ) => 'a = "%array_unsafe_get"
7
+
6
8
@val external fromIterator : Iterator .t <'a > => array <'a > = "Array.from"
7
9
@val external fromArrayLike : Js .Array2 .array_like <'a > => array <'a > = "Array.from"
8
10
@val
Original file line number Diff line number Diff line change @@ -862,6 +862,25 @@ for index in 0 to array->Array.length - 1 {
862
862
*/
863
863
external getUnsafe : (array <'a >, int ) => 'a = "%array_unsafe_get"
864
864
865
+ /**
866
+ `unsafe_get(array, index)` returns the element at `index` of `array`.
867
+
868
+ This is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `array`.
869
+
870
+ Use `Array.unsafe_get` only when you are sure the `index` exists (i.e. when using for-loop).
871
+
872
+ ## Examples
873
+ ```rescript
874
+ let array = [1, 2, 3]
875
+ for index in 0 to array->Array.length - 1 {
876
+ let value = array->Array.unsafe_get(index)
877
+ Console.log(value)
878
+ }
879
+ ```
880
+ */
881
+ @deprecated ("Use getUnsafe instead. This will be removed in v13" )
882
+ external unsafe_get : (array <'a >, int ) => 'a = "%array_unsafe_get"
883
+
865
884
/**
866
885
`setUnsafe(array, index, item)` sets the provided `item` at `index` of `array`.
867
886
You can’t perform that action at this time.
0 commit comments