diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aadcbf0f6..896e9282ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Apply heuristic to suggest using JSX fragments where we guess that might be what the user wanted. https://github.com/rescript-lang/rescript/pull/7714 - Show deprecation warnings for `bs-dependencies` etc. for local dependencies only. https://github.com/rescript-lang/rescript/pull/7724 - Add check for minimum required node version. https://github.com/rescript-lang/rescript/pull/7723 +- Use more optional args in stdlib and deprecate some functions. https://github.com/rescript-lang/rescript/pull/7730 #### :bug: Bug fix diff --git a/runtime/Stdlib_Array.res b/runtime/Stdlib_Array.res index 32a9979b8f..534c631c7c 100644 --- a/runtime/Stdlib_Array.res +++ b/runtime/Stdlib_Array.res @@ -13,11 +13,12 @@ external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" @val external fromArrayLikeWithMap: (arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from" -@send external fillAll: (array<'a>, 'a) => unit = "fill" +@deprecated("Use `fill` instead") @send external fillAll: (array<'a>, 'a) => unit = "fill" -@send external fillToEnd: (array<'a>, 'a, ~start: int) => unit = "fill" +@deprecated("Use `fill` instead") @send +external fillToEnd: (array<'a>, 'a, ~start: int) => unit = "fill" -@send external fill: (array<'a>, 'a, ~start: int, ~end: int) => unit = "fill" +@send external fill: (array<'a>, 'a, ~start: int=?, ~end: int=?) => unit = "fill" let make = (~length, x) => if length <= 0 { @@ -83,13 +84,14 @@ let compare = (a, b, cmp) => { : compareFromIndex(a, b, 0, cmp, lenA) } -@send external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" +@deprecated("Use `copyWithin` instead") @send +external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" -@send +@deprecated("Use `copyWithin` instead") @send external copyWithinToEnd: (array<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" @send -external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int) => array<'a> = "copyWithin" +external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin" @send external pop: array<'a> => option<'a> = "pop" @@ -124,13 +126,14 @@ external removeInPlace: (array<'a>, int, @as(1) _) => unit = "splice" @send external includes: (array<'a>, 'a) => bool = "includes" -@send external indexOf: (array<'a>, 'a) => int = "indexOf" +@send external indexOf: (array<'a>, 'a, ~from: int=?) => int = "indexOf" let indexOfOpt = (arr, item) => switch arr->indexOf(item) { | -1 => None | index => Some(index) } -@send external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" +@deprecated("Use `indexOf` instead") @send +external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" @send external join: (array, string) => string = "join" @@ -142,16 +145,19 @@ external joinWith: (array, string) => string = "join" @deprecated("Use `joinUnsafe` instead") @send external joinWithUnsafe: (array<'a>, string) => string = "join" -@send external lastIndexOf: (array<'a>, 'a) => int = "lastIndexOf" +@send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" let lastIndexOfOpt = (arr, item) => switch arr->lastIndexOf(item) { | -1 => None | index => Some(index) } -@send external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" +@deprecated("Use `lastIndexOf` instead") @send +external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" + +@send external slice: (array<'a>, ~start: int=?, ~end: int=?) => array<'a> = "slice" +@deprecated("Use `slice` instead") @send +external sliceToEnd: (array<'a>, ~start: int) => array<'a> = "slice" -@send external slice: (array<'a>, ~start: int, ~end: int) => array<'a> = "slice" -@send external sliceToEnd: (array<'a>, ~start: int) => array<'a> = "slice" @send external copy: array<'a> => array<'a> = "slice" @send external sort: (array<'a>, ('a, 'a) => Stdlib_Ordering.t) => unit = "sort" diff --git a/runtime/Stdlib_Array.resi b/runtime/Stdlib_Array.resi index 8eb31682b4..617060db10 100644 --- a/runtime/Stdlib_Array.resi +++ b/runtime/Stdlib_Array.resi @@ -81,15 +81,32 @@ someArray->Array.length == 2 external length: array<'a> => int = "length" // TODO: Docs -@send external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" +@deprecated("Use `copyWithin` instead") @send +external copyAllWithin: (array<'a>, ~target: int) => array<'a> = "copyWithin" // TODO: Docs -@send +@deprecated("Use `copyWithin` instead") @send external copyWithinToEnd: (array<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" -// TODO: Docs +/** +`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`. + +Beware this will *mutate* the array. + +See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN. + +## Examples + +```rescript +let myArray = [1, 2, 3, 4, 5] +myArray->Array.copyWithin(~target=0, ~start=3) == [4, 5, 3, 4, 5] + +let myArray = [1, 2, 3, 4, 5] +myArray->Array.copyWithin(~target=1, ~start=3, ~end=4) == [1, 4, 3, 4, 5] +``` +*/ @send -external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int) => array<'a> = "copyWithin" +external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin" /** `fillAll(array, value)` fills the entire `array` with `value`. @@ -106,7 +123,7 @@ myArray->Array.fillAll(9) myArray == [9, 9, 9, 9] ``` */ -@send +@deprecated("Use `fill` instead") @send external fillAll: (array<'a>, 'a) => unit = "fill" /** @@ -124,7 +141,7 @@ myArray->Array.fillToEnd(9, ~start=1) myArray == [1, 9, 9, 9] ``` */ -@send +@deprecated("Use `fill` instead") @send external fillToEnd: (array<'a>, 'a, ~start: int) => unit = "fill" /** @@ -139,13 +156,18 @@ See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer ```rescript let myArray = [1, 2, 3, 4] -myArray->Array.fill(9, ~start=1, ~end=3) +myArray->Array.fill(9) +myArray == [9, 9, 9, 9] + +myArray->Array.fill(0, ~start=1) +myArray == [9, 0, 0, 0] -myArray == [1, 9, 9, 4] +myArray->Array.fill(5, ~start=1, ~end=3) +myArray == [9, 5, 5, 0] ``` */ @send -external fill: (array<'a>, 'a, ~start: int, ~end: int) => unit = "fill" +external fill: (array<'a>, 'a, ~start: int=?, ~end: int=?) => unit = "fill" /** `pop(array)` removes the last item from `array` and returns it. @@ -416,9 +438,9 @@ See [`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R external includes: (array<'a>, 'a) => bool = "includes" /** -`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. +`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. -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. +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. See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN. @@ -427,12 +449,13 @@ See [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re ```rescript [1, 2]->Array.indexOf(2) == 1 [1, 2]->Array.indexOf(3) == -1 +[1, 2, 1, 2]->Array.indexOf(2, ~from=2) == 3 [{"language": "ReScript"}]->Array.indexOf({"language": "ReScript"}) == -1 // -1, because of strict equality ``` */ @send -external indexOf: (array<'a>, 'a) => int = "indexOf" +external indexOf: (array<'a>, 'a, ~from: int=?) => int = "indexOf" /** `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 ``` */ let indexOfOpt: (array<'a>, 'a) => option -@send external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" +@deprecated("Use `indexOf` instead") @send +external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf" /** `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. @@ -501,9 +525,27 @@ external joinUnsafe: (array<'a>, string) => string = "join" */ @deprecated("Use `joinUnsafe` instead") @send external joinWithUnsafe: (array<'a>, string) => string = "join" -@send external lastIndexOf: (array<'a>, 'a) => int = "lastIndexOf" +/** +`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. + +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. + +See [`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) on MDN. + +## Examples + +```rescript +[1, 2, 1, 2]->Array.lastIndexOf(2) == 3 +[1, 2]->Array.lastIndexOf(3) == -1 +[1, 2, 1, 2]->Array.lastIndexOf(2, ~from=2) == 1 + +[{"language": "ReScript"}]->Array.lastIndexOf({"language": "ReScript"}) == -1 // -1, because of strict equality +``` +*/ +@send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" let lastIndexOfOpt: (array<'a>, 'a) => option -@send external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" +@deprecated("Use `lastIndexOf` instead") @send +external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf" /** `slice(array, ~start, ~end)` creates a new array of items copied from `array` from `start` until (but not including) `end`. @@ -514,10 +556,12 @@ See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe ```rescript [1, 2, 3, 4]->Array.slice(~start=1, ~end=3) == [2, 3] +[1, 2, 3, 4]->Array.slice(~start=1) == [2, 3, 4] +[1, 2, 3, 4]->Array.slice == [1, 2, 3, 4] ``` */ @send -external slice: (array<'a>, ~start: int, ~end: int) => array<'a> = "slice" +external slice: (array<'a>, ~start: int=?, ~end: int=?) => array<'a> = "slice" /** `sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`. @@ -530,7 +574,7 @@ See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe [1, 2, 3, 4]->Array.sliceToEnd(~start=1) == [2, 3, 4] ``` */ -@send +@deprecated("Use `slice` instead") @send external sliceToEnd: (array<'a>, ~start: int) => array<'a> = "slice" /** `copy(array)` makes a copy of the array with the items in it, but does not make copies of the items themselves. diff --git a/runtime/Stdlib_BigInt64Array.res b/runtime/Stdlib_BigInt64Array.res index 2dadb7f916..f90f7b7f29 100644 --- a/runtime/Stdlib_BigInt64Array.res +++ b/runtime/Stdlib_BigInt64Array.res @@ -16,29 +16,30 @@ external fromArray: array => t = "BigInt64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "BigInt64Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = + "BigInt64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "BigInt64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "BigInt64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "BigInt64Array" @@ -46,11 +47,11 @@ external fromLength: int => t = "BigInt64Array" /** `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) */ @val -external fromArrayLikeOrIterable: 'a => t = "BigInt64Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => bigint=?) => t = "BigInt64Array.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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigInt64Array.from" /** diff --git a/runtime/Stdlib_BigUint64Array.res b/runtime/Stdlib_BigUint64Array.res index 38d5b7f301..c46c67a0c6 100644 --- a/runtime/Stdlib_BigUint64Array.res +++ b/runtime/Stdlib_BigUint64Array.res @@ -16,29 +16,30 @@ external fromArray: array => t = "BigUint64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "BigUint64Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = + "BigUint64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "BigUint64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "BigUint64Array" /** `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) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "BigUint64Array" @@ -46,11 +47,11 @@ external fromLength: int => t = "BigUint64Array" /** `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) */ @val -external fromArrayLikeOrIterable: 'a => t = "BigUint64Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => bigint=?) => t = "BigUint64Array.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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigUint64Array.from" /** diff --git a/runtime/Stdlib_Float32Array.res b/runtime/Stdlib_Float32Array.res index 892f55c8f6..3422c422f2 100644 --- a/runtime/Stdlib_Float32Array.res +++ b/runtime/Stdlib_Float32Array.res @@ -16,29 +16,30 @@ external fromArray: array => t = "Float32Array" /** `fromBuffer` creates a `Float32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array/Float32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Float32Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = + "Float32Array" /** `fromBufferToEnd` creates a `Float32Array` 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/Float32Array/Float32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Float32Array" /** `fromBufferWithRange` creates a `Float32Array` 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/Float32Array/Float32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Float32Array" /** `fromLength` creates a zero-initialized `Float32Array` 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/Float32Array/Float32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Float32Array" @@ -46,11 +47,11 @@ external fromLength: int => t = "Float32Array" /** `fromArrayLikeOrIterable` creates a `Float32Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Float32Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => float=?) => t = "Float32Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Float32Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float32Array.from" /** diff --git a/runtime/Stdlib_Float64Array.res b/runtime/Stdlib_Float64Array.res index b7761a4fac..e88d65b9c2 100644 --- a/runtime/Stdlib_Float64Array.res +++ b/runtime/Stdlib_Float64Array.res @@ -16,29 +16,30 @@ external fromArray: array => t = "Float64Array" /** `fromBuffer` creates a `Float64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array/Float64Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Float64Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = + "Float64Array" /** `fromBufferToEnd` creates a `Float64Array` 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/Float64Array/Float64Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Float64Array" /** `fromBufferWithRange` creates a `Float64Array` 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/Float64Array/Float64Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Float64Array" /** `fromLength` creates a zero-initialized `Float64Array` 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/Float64Array/Float64Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Float64Array" @@ -46,11 +47,11 @@ external fromLength: int => t = "Float64Array" /** `fromArrayLikeOrIterable` creates a `Float64Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Float64Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => float=?) => t = "Float64Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Float64Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => float) => t = "Float64Array.from" /** diff --git a/runtime/Stdlib_Int16Array.res b/runtime/Stdlib_Int16Array.res index 8672da86d3..e0a9a8b922 100644 --- a/runtime/Stdlib_Int16Array.res +++ b/runtime/Stdlib_Int16Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Int16Array" /** `fromBuffer` creates a `Int16Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Int16Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int16Array" /** `fromBufferToEnd` creates a `Int16Array` 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/Int16Array/Int16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int16Array" /** `fromBufferWithRange` creates a `Int16Array` 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/Int16Array/Int16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Int16Array" /** `fromLength` creates a zero-initialized `Int16Array` 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/Int16Array/Int16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Int16Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Int16Array" /** `fromArrayLikeOrIterable` creates a `Int16Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Int16Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int16Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Int16Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int16Array.from" /** diff --git a/runtime/Stdlib_Int32Array.res b/runtime/Stdlib_Int32Array.res index ae9cc4321e..8f50f172a8 100644 --- a/runtime/Stdlib_Int32Array.res +++ b/runtime/Stdlib_Int32Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Int32Array" /** `fromBuffer` creates a `Int32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array/Int32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Int32Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int32Array" /** `fromBufferToEnd` creates a `Int32Array` 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/Int32Array/Int32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int32Array" /** `fromBufferWithRange` creates a `Int32Array` 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/Int32Array/Int32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Int32Array" /** `fromLength` creates a zero-initialized `Int32Array` 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/Int32Array/Int32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Int32Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Int32Array" /** `fromArrayLikeOrIterable` creates a `Int32Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Int32Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int32Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Int32Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int32Array.from" /** diff --git a/runtime/Stdlib_Int8Array.res b/runtime/Stdlib_Int8Array.res index db9c9c36c3..b791863cd0 100644 --- a/runtime/Stdlib_Int8Array.res +++ b/runtime/Stdlib_Int8Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Int8Array" /** `fromBuffer` creates a `Int8Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array/Int8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Int8Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Int8Array" /** `fromBufferToEnd` creates a `Int8Array` 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/Int8Array/Int8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Int8Array" /** `fromBufferWithRange` creates a `Int8Array` 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/Int8Array/Int8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Int8Array" /** `fromLength` creates a zero-initialized `Int8Array` 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/Int8Array/Int8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Int8Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Int8Array" /** `fromArrayLikeOrIterable` creates a `Int8Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Int8Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Int8Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Int8Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Int8Array.from" /** diff --git a/runtime/Stdlib_String.res b/runtime/Stdlib_String.res index 11cbe773c7..a1ca7605f8 100644 --- a/runtime/Stdlib_String.res +++ b/runtime/Stdlib_String.res @@ -136,8 +136,9 @@ let searchOpt = (s, re) => | index => Some(index) } -@send external slice: (string, ~start: int, ~end: int) => string = "slice" -@send external sliceToEnd: (string, ~start: int) => string = "slice" +@send external slice: (string, ~start: int, ~end: int=?) => string = "slice" +@deprecated("Use `slice` instead") @send +external sliceToEnd: (string, ~start: int) => string = "slice" @send external split: (string, string) => array = "split" @send external splitAtMost: (string, string, ~limit: int) => array = "split" @@ -149,8 +150,9 @@ external splitByRegExpAtMost: (string, Stdlib_RegExp.t, ~limit: int) => array bool = "startsWith" @send external startsWithFrom: (string, string, int) => bool = "startsWith" -@send external substring: (string, ~start: int, ~end: int) => string = "substring" -@send external substringToEnd: (string, ~start: int) => string = "substring" +@send external substring: (string, ~start: int, ~end: int=?) => string = "substring" +@deprecated("Use `substring` instead") @send +external substringToEnd: (string, ~start: int) => string = "substring" @send external toLowerCase: string => string = "toLowerCase" @send external toLocaleLowerCase: string => string = "toLocaleLowerCase" diff --git a/runtime/Stdlib_String.resi b/runtime/Stdlib_String.resi index 896bf1dc4b..18a616525b 100644 --- a/runtime/Stdlib_String.resi +++ b/runtime/Stdlib_String.resi @@ -825,10 +825,12 @@ String.slice("abcdefg", ~start=2, ~end=5) == "cde" String.slice("abcdefg", ~start=2, ~end=9) == "cdefg" String.slice("abcdefg", ~start=-4, ~end=-2) == "de" String.slice("abcdefg", ~start=5, ~end=1) == "" +String.slice("abcdefg", ~start=2) == "cdefg" +String.slice("Hello World", ~start=6) == "World" ``` */ @send -external slice: (string, ~start: int, ~end: int) => string = "slice" +external slice: (string, ~start: int, ~end: int=?) => string = "slice" /** `sliceToEnd(str, ~start)` returns the substring of `str` starting at character @@ -845,7 +847,7 @@ String.sliceToEnd("abcdefg", ~start=-2) == "fg" String.sliceToEnd("abcdefg", ~start=7) == "" ``` */ -@send +@deprecated("Use `slice` instead") @send external sliceToEnd: (string, ~start: int) => string = "slice" /** @@ -964,10 +966,12 @@ including end from `str`. String.substring("playground", ~start=3, ~end=6) == "ygr" String.substring("playground", ~start=6, ~end=3) == "ygr" String.substring("playground", ~start=4, ~end=12) == "ground" +String.substring("playground", ~start=4) == "ground" +String.substring("Hello World", ~start=6) == "World" ``` */ @send -external substring: (string, ~start: int, ~end: int) => string = "substring" +external substring: (string, ~start: int, ~end: int=?) => string = "substring" /** `substringToEnd(str, ~start)` returns the substring of `str` from position @@ -985,7 +989,7 @@ String.substringToEnd("playground", ~start=-3) == "playground" String.substringToEnd("playground", ~start=12) == "" ``` */ -@send +@deprecated("Use `substring` instead") @send external substringToEnd: (string, ~start: int) => string = "substring" /** diff --git a/runtime/Stdlib_TypedArray.res b/runtime/Stdlib_TypedArray.res index af38e2448f..5478156168 100644 --- a/runtime/Stdlib_TypedArray.res +++ b/runtime/Stdlib_TypedArray.res @@ -14,13 +14,15 @@ type t<'a> @get external length: t<'a> => int = "length" @send external copyAllWithin: (t<'a>, ~target: int) => array<'a> = "copyWithin" -@send external copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" +@deprecated("Use `copyWithin` instead") @send +external copyWithinToEnd: (t<'a>, ~target: int, ~start: int) => array<'a> = "copyWithin" @send -external copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int) => array<'a> = "copyWithin" +external copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int=?) => array<'a> = "copyWithin" @send external fillAll: (t<'a>, 'a) => t<'a> = "fill" -@send external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill" -@send external fill: (t<'a>, 'a, ~start: int, ~end: int) => t<'a> = "fill" +@deprecated("Use `fill` instead") @send +external fillToEnd: (t<'a>, 'a, ~start: int) => t<'a> = "fill" +@send external fill: (t<'a>, 'a, ~start: int, ~end: int=?) => t<'a> = "fill" @send external reverse: t<'a> => unit = "reverse" @send external toReversed: t<'a> => t<'a> = "toReversed" @@ -40,12 +42,14 @@ external copyWithin: (t<'a>, ~target: int, ~start: int, ~end: int) => array<'a> @send external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" @send external lastIndexOfFrom: (t<'a>, 'a, int) => int = "lastIndexOf" -@send external slice: (t<'a>, ~start: int, ~end: int) => t<'a> = "slice" -@send external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice" +@send external slice: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "slice" +@deprecated("Use `slice` instead") @send +external sliceToEnd: (t<'a>, ~start: int) => t<'a> = "slice" @send external copy: t<'a> => t<'a> = "slice" -@send external subarray: (t<'a>, ~start: int, ~end: int) => t<'a> = "subarray" -@send external subarrayToEnd: (t<'a>, ~start: int) => t<'a> = "subarray" +@send external subarray: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "subarray" +@deprecated("Use `subarray` instead") @send +external subarrayToEnd: (t<'a>, ~start: int) => t<'a> = "subarray" @send external toString: t<'a> => string = "toString" @send external toLocaleString: t<'a> => string = "toLocaleString" diff --git a/runtime/Stdlib_Uint16Array.res b/runtime/Stdlib_Uint16Array.res index 5964328694..cdbfc2311c 100644 --- a/runtime/Stdlib_Uint16Array.res +++ b/runtime/Stdlib_Uint16Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Uint16Array" /** `fromBuffer` creates a `Uint16Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array/Uint16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Uint16Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint16Array" /** `fromBufferToEnd` creates a `Uint16Array` 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/Uint16Array/Uint16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint16Array" /** `fromBufferWithRange` creates a `Uint16Array` 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/Uint16Array/Uint16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Uint16Array" /** `fromLength` creates a zero-initialized `Uint16Array` 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/Uint16Array/Uint16Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Uint16Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Uint16Array" /** `fromArrayLikeOrIterable` creates a `Uint16Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Uint16Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint16Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Uint16Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint16Array.from" /** diff --git a/runtime/Stdlib_Uint32Array.res b/runtime/Stdlib_Uint32Array.res index 3801a0407d..a6644a9c61 100644 --- a/runtime/Stdlib_Uint32Array.res +++ b/runtime/Stdlib_Uint32Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Uint32Array" /** `fromBuffer` creates a `Uint32Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array/Uint32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Uint32Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint32Array" /** `fromBufferToEnd` creates a `Uint32Array` 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/Uint32Array/Uint32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint32Array" /** `fromBufferWithRange` creates a `Uint32Array` 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/Uint32Array/Uint32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Uint32Array" /** `fromLength` creates a zero-initialized `Uint32Array` 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/Uint32Array/Uint32Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Uint32Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Uint32Array" /** `fromArrayLikeOrIterable` creates a `Uint32Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Uint32Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint32Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Uint32Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint32Array.from" /** diff --git a/runtime/Stdlib_Uint8Array.res b/runtime/Stdlib_Uint8Array.res index 94c52c83e0..2e5e9dbede 100644 --- a/runtime/Stdlib_Uint8Array.res +++ b/runtime/Stdlib_Uint8Array.res @@ -16,29 +16,29 @@ external fromArray: array => t = "Uint8Array" /** `fromBuffer` creates a `Uint8Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/Uint8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Uint8Array" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = "Uint8Array" /** `fromBufferToEnd` creates a `Uint8Array` 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/Uint8Array/Uint8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint8Array" /** `fromBufferWithRange` creates a `Uint8Array` 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/Uint8Array/Uint8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Uint8Array" /** `fromLength` creates a zero-initialized `Uint8Array` 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/Uint8Array/Uint8Array) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Uint8Array" @@ -46,11 +46,11 @@ external fromLength: int => t = "Uint8Array" /** `fromArrayLikeOrIterable` creates a `Uint8Array` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Uint8Array.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint8Array.from" /** `fromArrayLikeOrIterableWithMap` creates a `Uint8Array` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8Array.from" /** diff --git a/runtime/Stdlib_Uint8ClampedArray.res b/runtime/Stdlib_Uint8ClampedArray.res index ea32fab206..78f351918b 100644 --- a/runtime/Stdlib_Uint8ClampedArray.res +++ b/runtime/Stdlib_Uint8ClampedArray.res @@ -16,29 +16,30 @@ external fromArray: array => t = "Uint8ClampedArray" /** `fromBuffer` creates a `Uint8ClampedArray` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray/Uint8ClampedArray) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new -external fromBuffer: Stdlib_ArrayBuffer.t => t = "Uint8ClampedArray" +external fromBuffer: (Stdlib_ArrayBuffer.t, ~byteOffset: int=?, ~length: int=?) => t = + "Uint8ClampedArray" /** `fromBufferToEnd` creates a `Uint8ClampedArray` 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/Uint8ClampedArray/Uint8ClampedArray) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferToEnd: (Stdlib_ArrayBuffer.t, ~byteOffset: int) => t = "Uint8ClampedArray" /** `fromBufferWithRange` creates a `Uint8ClampedArray` 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/Uint8ClampedArray/Uint8ClampedArray) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ -@new +@deprecated("Use `fromBuffer` instead") @new external fromBufferWithRange: (Stdlib_ArrayBuffer.t, ~byteOffset: int, ~length: int) => t = "Uint8ClampedArray" /** `fromLength` creates a zero-initialized `Uint8ClampedArray` 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/Uint8ClampedArray/Uint8ClampedArray) -**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. +**Note:** This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds. */ @new external fromLength: int => t = "Uint8ClampedArray" @@ -46,11 +47,11 @@ external fromLength: int => t = "Uint8ClampedArray" /** `fromArrayLikeOrIterable` creates a `Uint8ClampedArray` 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) */ @val -external fromArrayLikeOrIterable: 'a => t = "Uint8ClampedArray.from" +external fromArrayLikeOrIterable: ('a, ~map: ('b, int) => int=?) => t = "Uint8ClampedArray.from" /** `fromArrayLikeOrIterableWithMap` creates a `Uint8ClampedArray` 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) */ -@val +@deprecated("Use `fromArrayLikeOrIterable` instead") @val external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => int) => t = "Uint8ClampedArray.from" /** diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 0663346ce6..3361871351 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -176,14 +176,14 @@ Path Array. "label": "slice", "kind": 12, "tags": [], - "detail": "(array<'a>, ~start: int, ~end: int) => array<'a>", - "documentation": {"kind": "markdown", "value": "\n`slice(array, ~start, ~end)` creates a new array of items copied from `array` from `start` until (but not including) `end`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 3, 4]->Array.slice(~start=1, ~end=3) == [2, 3]\n```\n"} + "detail": "(array<'a>, ~start: int=?, ~end: int=?) => array<'a>", + "documentation": {"kind": "markdown", "value": "\n`slice(array, ~start, ~end)` creates a new array of items copied from `array` from `start` until (but not including) `end`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 3, 4]->Array.slice(~start=1, ~end=3) == [2, 3]\n[1, 2, 3, 4]->Array.slice(~start=1) == [2, 3, 4]\n[1, 2, 3, 4]->Array.slice == [1, 2, 3, 4]\n```\n"} }, { "label": "fillToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, 'a, ~start: int) => unit", - "documentation": {"kind": "markdown", "value": "\n`fillToEnd(array, value, ~start)` fills `array` with `value` from the `start` index.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillToEnd(9, ~start=1)\nmyArray == [1, 9, 9, 9]\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `fill` instead\n\n\n`fillToEnd(array, value, ~start)` fills `array` with `value` from the `start` index.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillToEnd(9, ~start=1)\nmyArray == [1, 9, 9, 9]\n```\n"} }, { "label": "includes", "kind": 12, @@ -217,9 +217,9 @@ Path Array. }, { "label": "lastIndexOfFrom", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, 'a, int) => int", - "documentation": null + "documentation": {"kind": "markdown", "value": "Deprecated: Use `lastIndexOf` instead\n\n"} }, { "label": "toLocaleString", "kind": 12, @@ -284,8 +284,8 @@ Path Array. "label": "copyWithin", "kind": 12, "tags": [], - "detail": "(\n array<'a>,\n ~target: int,\n ~start: int,\n ~end: int,\n) => array<'a>", - "documentation": null + "detail": "(\n array<'a>,\n ~target: int,\n ~start: int,\n ~end: int=?,\n) => array<'a>", + "documentation": {"kind": "markdown", "value": "\n`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`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4, 5]\nmyArray->Array.copyWithin(~target=0, ~start=3) == [4, 5, 3, 4, 5]\n\nlet myArray = [1, 2, 3, 4, 5]\nmyArray->Array.copyWithin(~target=1, ~start=3, ~end=4) == [1, 4, 3, 4, 5]\n```\n"} }, { "label": "toString", "kind": 12, @@ -302,8 +302,8 @@ Path Array. "label": "fill", "kind": 12, "tags": [], - "detail": "(array<'a>, 'a, ~start: int, ~end: int) => unit", - "documentation": {"kind": "markdown", "value": "\n`fill(array, value, ~start, ~end)` fills `array` with `value` from `start` to `end`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\n\nmyArray->Array.fill(9, ~start=1, ~end=3)\n\nmyArray == [1, 9, 9, 4]\n```\n"} + "detail": "(array<'a>, 'a, ~start: int=?, ~end: int=?) => unit", + "documentation": {"kind": "markdown", "value": "\n`fill(array, value, ~start, ~end)` fills `array` with `value` from `start` to `end`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\n\nmyArray->Array.fill(9)\nmyArray == [9, 9, 9, 9]\n\nmyArray->Array.fill(0, ~start=1)\nmyArray == [9, 0, 0, 0]\n\nmyArray->Array.fill(5, ~start=1, ~end=3)\nmyArray == [9, 5, 5, 0]\n```\n"} }, { "label": "findWithIndex", "kind": 12, @@ -344,8 +344,8 @@ Path Array. "label": "lastIndexOf", "kind": 12, "tags": [], - "detail": "(array<'a>, 'a) => int", - "documentation": null + "detail": "(array<'a>, 'a, ~from: int=?) => int", + "documentation": {"kind": "markdown", "value": "\n`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.\n\nReturns `-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.\n\nSee [`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 1, 2]->Array.lastIndexOf(2) == 3\n[1, 2]->Array.lastIndexOf(3) == -1\n[1, 2, 1, 2]->Array.lastIndexOf(2, ~from=2) == 1\n\n[{\"language\": \"ReScript\"}]->Array.lastIndexOf({\"language\": \"ReScript\"}) == -1 // -1, because of strict equality\n```\n"} }, { "label": "filter", "kind": 12, @@ -409,9 +409,9 @@ Path Array. }, { "label": "sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, ~start: int) => array<'a>", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 3, 4]->Array.sliceToEnd(~start=1) == [2, 3, 4]\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(array, start)` creates a new array from `array`, with all items from `array` starting from `start`.\n\nSee [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN.\n\n## Examples\n\n```rescript\n[1, 2, 3, 4]->Array.sliceToEnd(~start=1) == [2, 3, 4]\n```\n"} }, { "label": "fromArrayLikeWithMap", "kind": 12, @@ -421,9 +421,9 @@ Path Array. }, { "label": "fillAll", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, 'a) => unit", - "documentation": {"kind": "markdown", "value": "\n`fillAll(array, value)` fills the entire `array` with `value`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillAll(9)\nmyArray == [9, 9, 9, 9]\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `fill` instead\n\n\n`fillAll(array, value)` fills the entire `array` with `value`.\n\nBeware this will *mutate* the array.\n\nSee [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN.\n\n## Examples\n\n```rescript\nlet myArray = [1, 2, 3, 4]\nmyArray->Array.fillAll(9)\nmyArray == [9, 9, 9, 9]\n```\n"} }, { "label": "set", "kind": 12, @@ -475,9 +475,9 @@ Path Array. }, { "label": "copyWithinToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, ~target: int, ~start: int) => array<'a>", - "documentation": null + "documentation": {"kind": "markdown", "value": "Deprecated: Use `copyWithin` instead\n\n"} }, { "label": "unshift", "kind": 12, @@ -488,8 +488,8 @@ Path Array. "label": "indexOf", "kind": 12, "tags": [], - "detail": "(array<'a>, 'a) => int", - "documentation": {"kind": "markdown", "value": "\n`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.\n\nReturns `-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.\n\nSee [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN.\n\n## Examples\n\n```rescript\n[1, 2]->Array.indexOf(2) == 1\n[1, 2]->Array.indexOf(3) == -1\n\n[{\"language\": \"ReScript\"}]->Array.indexOf({\"language\": \"ReScript\"}) == -1 // -1, because of strict equality\n```\n"} + "detail": "(array<'a>, 'a, ~from: int=?) => int", + "documentation": {"kind": "markdown", "value": "\n`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.\n\nReturns `-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.\n\nSee [`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) on MDN.\n\n## Examples\n\n```rescript\n[1, 2]->Array.indexOf(2) == 1\n[1, 2]->Array.indexOf(3) == -1\n[1, 2, 1, 2]->Array.indexOf(2, ~from=2) == 3\n\n[{\"language\": \"ReScript\"}]->Array.indexOf({\"language\": \"ReScript\"}) == -1 // -1, because of strict equality\n```\n"} }, { "label": "push", "kind": 12, @@ -523,9 +523,9 @@ Path Array. }, { "label": "copyAllWithin", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, ~target: int) => array<'a>", - "documentation": null + "documentation": {"kind": "markdown", "value": "Deprecated: Use `copyWithin` instead\n\n"} }, { "label": "keepSome", "kind": 12, @@ -595,9 +595,9 @@ Path Array. }, { "label": "indexOfFrom", "kind": 12, - "tags": [], + "tags": [1], "detail": "(array<'a>, 'a, int) => int", - "documentation": null + "documentation": {"kind": "markdown", "value": "Deprecated: Use `indexOf` instead\n\n"} }] Complete src/Completion.res 5:10 diff --git a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt index dc885d8485..898253f44f 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt @@ -570,14 +570,14 @@ Path slic "label": "String.slice", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```\n"} + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n"} }, { "label": "String.sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} }] Complete src/CompletionInferValues.res 91:82 @@ -693,14 +693,14 @@ Path slic "label": "String.slice", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```\n"} + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n"} }, { "label": "String.sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} }] Complete src/CompletionInferValues.res 107:89 @@ -722,14 +722,14 @@ Path slic "label": "String.slice", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```\n"} + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n"} }, { "label": "String.sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} }] Complete src/CompletionInferValues.res 111:80 @@ -751,14 +751,14 @@ Path slic "label": "String.slice", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```\n"} + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n"} }, { "label": "String.sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"} }] Complete src/CompletionInferValues.res 115:53 diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt index e9907b0a2b..d89ae7cde6 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt @@ -813,8 +813,8 @@ Path s "label": "->String.slice", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\n```\n"}, + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`slice(str, ~start, ~end)` returns the substring of `str` starting at\ncharacter `start` up to but not including `end`.\n- If either `start` or `end` is negative, then it is evaluated as\n `length(str - start)` or `length(str - end)`.\n- If `end` is greater than the length of `str`, then it is treated as\n `length(str)`.\n- If `start` is greater than `end`, slice returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.slice(\"abcdefg\", ~start=2, ~end=5) == \"cde\"\nString.slice(\"abcdefg\", ~start=2, ~end=9) == \"cdefg\"\nString.slice(\"abcdefg\", ~start=-4, ~end=-2) == \"de\"\nString.slice(\"abcdefg\", ~start=5, ~end=1) == \"\"\nString.slice(\"abcdefg\", ~start=2) == \"cdefg\"\nString.slice(\"Hello World\", ~start=6) == \"World\"\n```\n"}, "sortText": "slice", "insertText": "->String.slice", "additionalTextEdits": [{ @@ -824,9 +824,9 @@ Path s }, { "label": "->String.substringToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\n is returned.\n See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```\n"}, + "documentation": {"kind": "markdown", "value": "Deprecated: Use `substring` instead\n\n\n`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\n is returned.\n See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```\n"}, "sortText": "substringToEnd", "insertText": "->String.substringToEnd", "additionalTextEdits": [{ @@ -860,9 +860,9 @@ Path s }, { "label": "->String.sliceToEnd", "kind": 12, - "tags": [], + "tags": [1], "detail": "(string, ~start: int) => string", - "documentation": {"kind": "markdown", "value": "\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"}, + "documentation": {"kind": "markdown", "value": "Deprecated: Use `slice` instead\n\n\n`sliceToEnd(str, ~start)` returns the substring of `str` starting at character\n`start` to the end of the string.\n- If `start` is negative, then it is evaluated as `length(str - start)`.\n- If `start` is greater than the length of `str`, then sliceToEnd returns the empty string.\n See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN.\n\n## Examples\n\n```rescript\nString.sliceToEnd(\"abcdefg\", ~start=4) == \"efg\"\nString.sliceToEnd(\"abcdefg\", ~start=-2) == \"fg\"\nString.sliceToEnd(\"abcdefg\", ~start=7) == \"\"\n```\n"}, "sortText": "sliceToEnd", "insertText": "->String.sliceToEnd", "additionalTextEdits": [{ @@ -909,8 +909,8 @@ Path s "label": "->String.substring", "kind": 12, "tags": [], - "detail": "(string, ~start: int, ~end: int) => string", - "documentation": {"kind": "markdown", "value": "\n`substring(str, ~start, ~end)` returns characters `start` up to but not\nincluding end from `str`.\n- If `start` is less than zero, it is treated as zero.\n- If `end` is zero or negative, the empty string is returned.\n- If `start` is greater than `end`, the `start` and `end` points are swapped.\n See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substring(\"playground\", ~start=3, ~end=6) == \"ygr\"\nString.substring(\"playground\", ~start=6, ~end=3) == \"ygr\"\nString.substring(\"playground\", ~start=4, ~end=12) == \"ground\"\n```\n"}, + "detail": "(string, ~start: int, ~end: int=?) => string", + "documentation": {"kind": "markdown", "value": "\n`substring(str, ~start, ~end)` returns characters `start` up to but not\nincluding end from `str`.\n- If `start` is less than zero, it is treated as zero.\n- If `end` is zero or negative, the empty string is returned.\n- If `start` is greater than `end`, the `start` and `end` points are swapped.\n See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substring(\"playground\", ~start=3, ~end=6) == \"ygr\"\nString.substring(\"playground\", ~start=6, ~end=3) == \"ygr\"\nString.substring(\"playground\", ~start=4, ~end=12) == \"ground\"\nString.substring(\"playground\", ~start=4) == \"ground\"\nString.substring(\"Hello World\", ~start=6) == \"World\"\n```\n"}, "sortText": "substring", "insertText": "->String.substring", "additionalTextEdits": [{