Skip to content

Commit 2d7d1d3

Browse files
committed
more migrations
1 parent 28cbe34 commit 2d7d1d3

14 files changed

+94
-9
lines changed

packages/@rescript/runtime/Stdlib_Array.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ let compare = (a, b, cmp) => {
9999
: compareFromIndex(a, b, 0, cmp, lenA)
100100
}
101101

102-
@deprecated("Use `copyWithin` instead")
102+
@deprecated({
103+
reason: "Use `copyWithin` instead",
104+
migrate: Array.copyWithin(~start=0),
105+
})
103106
@send
104107
external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin"
105108

packages/@rescript/runtime/Stdlib_Array.resi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ arr->Array.copyAllWithin(~target=2) == [100, 101, 100, 101, 102]
101101
arr == [100, 101, 100, 101, 102]
102102
```
103103
*/
104-
@deprecated("Use `copyWithin` instead")
104+
@deprecated({
105+
reason: "Use `copyWithin` instead",
106+
migrate: Array.copyWithin(~start=0),
107+
})
105108
@send external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin"
106109

107110
/**

packages/@rescript/runtime/Stdlib_DataView.res

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@ type t
33

44
@new
55
external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "DataView"
6-
@new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "DataView"
6+
@deprecated({
7+
reason: "Use `fromBuffer` instead",
8+
migrate: DataView.fromBuffer(
9+
%insert.unlabelledArgument(0),
10+
~byteOffset=%insert.labelledArgument("byteOffset"),
11+
),
12+
})
13+
@new
14+
external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "DataView"
15+
@deprecated({
16+
reason: "Use `fromBuffer` instead",
17+
migrate: DataView.fromBuffer(
18+
%insert.unlabelledArgument(0),
19+
~byteOffset=%insert.labelledArgument("byteOffset"),
20+
~length=%insert.labelledArgument("length"),
21+
),
22+
})
723
@new
824
external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t =
925
"DataView"

packages/@rescript/runtime/Stdlib_DataView.resi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ DataView.fromBuffer(ArrayBuffer.make(16), ~byteOffset=4, ~length=8)
6161
DataView.fromBufferToEnd(buffer, ~byteOffset=4)
6262
```
6363
*/
64-
@deprecated("Use `fromBuffer` instead") @new
64+
@deprecated({
65+
reason: "Use `fromBuffer` instead",
66+
migrate: DataView.fromBuffer(~byteOffset=%insert.labelledArgument("byteOffset")),
67+
})
68+
@new
6569
external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "DataView"
6670

6771
/**
@@ -77,7 +81,11 @@ See [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
7781
DataView.fromBufferWithRange(ArrayBuffer.make(16), ~byteOffset=2, ~length=8)
7882
```
7983
*/
80-
@deprecated("Use `fromBuffer` instead") @new
84+
@deprecated({
85+
reason: "Use `fromBuffer` instead",
86+
migrate: DataView.fromBuffer(),
87+
})
88+
@new
8189
external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t =
8290
"DataView"
8391

packages/@rescript/runtime/Stdlib_TypedArray.res

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ type t<'a>
1414
@get external length: t<'a> => int = "length"
1515

1616
@send external copyAllWithin: (t<'a>, ~target: int) => array<'a> = "copyWithin"
17-
@deprecated("Use `copyWithin` instead") @send
17+
@deprecated({
18+
reason: "Use `copyWithin` instead",
19+
migrate: TypedArray.copyWithin(),
20+
})
21+
@send
1822
external copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin"
1923
@send
2024
external copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin"
2125

2226
@send external fillAll: (t<'a>, 'a) => t<'a> = "fill"
23-
@deprecated("Use `fill` instead") @send
27+
@deprecated({
28+
reason: "Use `fill` instead",
29+
migrate: TypedArray.fill(),
30+
})
31+
@send
2432
external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill"
2533
@send external fill: (t<'a>, 'a, ~start: int, ~end: int=?) => t<'a> = "fill"
2634

@@ -43,12 +51,20 @@ external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill"
4351
@send external lastIndexOfFrom: (t<'a>, 'a, int) => int = "lastIndexOf"
4452

4553
@send external slice: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "slice"
46-
@deprecated("Use `slice` instead") @send
54+
@deprecated({
55+
reason: "Use `slice` instead",
56+
migrate: TypedArray.slice(),
57+
})
58+
@send
4759
external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice"
4860
@send external copy: t<'a> => t<'a> = "slice"
4961

5062
@send external subarray: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "subarray"
51-
@deprecated("Use `subarray` instead") @send
63+
@deprecated({
64+
reason: "Use `subarray` instead",
65+
migrate: TypedArray.subarray(),
66+
})
67+
@send
5268
external subarrayToEnd: (t<'a>, ~start: int) => t<'a> = "subarray"
5369

5470
@send external toString: t<'a> => string = "toString"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let a = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2)
2+
let b = DataView.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=4)
3+

tests/tools_tests/src/expected/StdlibMigration_StdlibArray.res.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
let ba1 = [1, 2, 3, 4, 5]->Array.copyWithin(~target=2, ~start=0)
2+
let ba2 = Array.copyWithin([1, 2, 3, 4, 5], ~target=2, ~start=0)
3+
14
let b1 = [1, 2, 3, 4]->Array.copyWithin(~target=0, ~start=2)
25
let b2 = Array.copyWithin([1, 2, 3, 4], ~target=0, ~start=2)
36

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let ta = Uint8Array.fromArray([1, 2, 3, 4])
2+
3+
let a1 = ta->TypedArray.copyWithin(~target=1, ~start=2)
4+
let a2 = ta->TypedArray.fill(9, ~start=1)
5+
let a3 = ta->TypedArray.slice(~start=1)
6+
let a4 = ta->TypedArray.subarray(~start=1)
7+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let a = DataView.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2)
2+
let b = DataView.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=4)

tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
let ba1 = [1, 2, 3, 4, 5]->Array.copyAllWithin(~target=2)
2+
let ba2 = Array.copyAllWithin([1, 2, 3, 4, 5], ~target=2)
3+
14
let b1 = [1, 2, 3, 4]->Array.copyWithinToEnd(~target=0, ~start=2)
25
let b2 = Array.copyWithinToEnd([1, 2, 3, 4], ~target=0, ~start=2)
36

0 commit comments

Comments
 (0)