diff --git a/src/Fable.Core/CHANGELOG.md b/src/Fable.Core/CHANGELOG.md index 8aa8ac0b3..2d4624138 100644 --- a/src/Fable.Core/CHANGELOG.md +++ b/src/Fable.Core/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +* [JS] Add `ReadonlyArray` to `Fable.Core.JS` by (@MangelMaxime) + ## 4.3.0 - 2024-01-25 ### Added diff --git a/src/Fable.Core/Fable.Core.JS.fs b/src/Fable.Core/Fable.Core.JS.fs index 90e383dbf..7ceb73380 100644 --- a/src/Fable.Core/Fable.Core.JS.fs +++ b/src/Fable.Core/Fable.Core.JS.fs @@ -722,6 +722,214 @@ module JS = abstract table: ?data: obj -> unit + [] + [] + type ConcatArray<'T> = + abstract member length: int with get + + [] + abstract member Item: n: int -> 'T with get + + abstract member join: ?separator: string -> string + abstract member slice: ?start: int * ?``end``: int -> ResizeArray<'T> + + [] + [] + type ReadonlyArray<'T> = + /// + /// Gets the length of the array. This is a number one higher than the highest element defined in an array. + /// + abstract member length: int with get + /// + /// Returns a string representation of an array. + /// + abstract member toString: unit -> string + /// + /// Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. + /// + abstract member toLocaleString: unit -> string + /// + /// Combines two or more arrays. + /// + /// + /// Additional items to add to the end of array1. + /// + abstract member concat: [] items: ConcatArray<'T>[] -> ResizeArray<'T> + /// + /// Combines two or more arrays. + /// + /// + /// Additional items to add to the end of array1. + /// + abstract member concat: [] items: U2<'T, ConcatArray<'T>>[] -> ResizeArray<'T> + /// + /// Adds all the elements of an array separated by the specified separator string. + /// + /// + /// A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + /// + abstract member join: ?separator: string -> string + /// + /// Returns a section of an array. + /// + /// + /// The beginning of the specified portion of the array. + /// + /// + /// The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + /// + abstract member slice: ?start: int * ?``end``: int -> ResizeArray<'T> + /// + /// Returns the index of the first occurrence of a value in an array. + /// + /// + /// The value to locate in the array. + /// + /// + /// The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + /// + abstract member indexOf: searchElement: 'T * ?fromIndex: int -> int + /// + /// Returns the index of the last occurrence of a specified value in an array. + /// + /// + /// The value to locate in the array. + /// + /// + /// The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + /// + abstract member lastIndexOf: searchElement: 'T * ?fromIndex: int -> int + /// + /// Determines whether all the members of an array satisfy the specified test. + /// + /// + /// A function that accepts up to three arguments. The every method calls + /// the predicate function for each element in the array until the predicate returns a value + /// which is coercible to the Boolean value false, or until the end of the array. + /// + /// + /// An object to which the this keyword can refer in the predicate function. + /// If thisArg is omitted, undefined is used as the this value. + /// + abstract member every: predicate: ('T -> int -> ReadonlyArray<'T> -> bool) * ?thisArg: obj -> bool + /// + /// Determines whether all the members of an array satisfy the specified test. + /// + /// + /// A function that accepts up to three arguments. The every method calls + /// the predicate function for each element in the array until the predicate returns a value + /// which is coercible to the Boolean value false, or until the end of the array. + /// + /// + /// An object to which the this keyword can refer in the predicate function. + /// If thisArg is omitted, undefined is used as the this value. + /// + abstract member every: predicate: ('T -> int -> ReadonlyArray<'T> -> obj) * ?thisArg: obj -> bool + /// + /// Determines whether the specified callback function returns true for any element of an array. + /// + /// + /// A function that accepts up to three arguments. The some method calls + /// the predicate function for each element in the array until the predicate returns a value + /// which is coercible to the Boolean value true, or until the end of the array. + /// + /// + /// An object to which the this keyword can refer in the predicate function. + /// If thisArg is omitted, undefined is used as the this value. + /// + abstract member some: predicate: ('T -> int -> ReadonlyArray<'T> -> obj) * ?thisArg: obj -> bool + /// + /// Performs the specified action for each element in an array. + /// + /// + /// A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + /// + /// + /// An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + /// + abstract member forEach: callbackfn: ('T -> int -> ReadonlyArray<'T> -> unit) * ?thisArg: obj -> unit + /// + /// Calls a defined callback function on each element of an array, and returns an array that contains the results. + /// + /// + /// A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + /// + /// + /// An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + /// + abstract member map: callbackfn: ('T -> int -> ReadonlyArray<'T> -> 'U) * ?thisArg: obj -> ResizeArray<'U> + /// + /// Returns the elements of an array that meet the condition specified in a callback function. + /// + /// + /// A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. + /// + /// + /// An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. + /// + abstract member filter: predicate: ('T -> int -> ReadonlyArray<'T> -> bool) * ?thisArg: obj -> ResizeArray<'S> + /// + /// Returns the elements of an array that meet the condition specified in a callback function. + /// + /// + /// A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. + /// + /// + /// An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. + /// + abstract member filter: predicate: ('T -> int -> ReadonlyArray<'T> -> obj) * ?thisArg: obj -> ResizeArray<'T> + /// + /// Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + /// + /// A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + /// + /// + /// If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + /// + abstract member reduce: callbackfn: ('T -> 'T -> int -> ReadonlyArray<'T> -> 'T) -> 'T + /// + /// Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + abstract member reduce: callbackfn: ('T -> 'T -> int -> ReadonlyArray<'T> -> 'T) * initialValue: 'T -> 'T + /// + /// Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + /// + /// A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + /// + /// + /// If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + /// + abstract member reduce: callbackfn: ('U -> 'T -> int -> ReadonlyArray<'T> -> 'U) * initialValue: 'U -> 'U + /// + /// Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + /// + /// A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + /// + /// + /// If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + /// + abstract member reduceRight: callbackfn: ('T -> 'T -> int -> ReadonlyArray<'T> -> 'T) -> 'T + /// + /// Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + abstract member reduceRight: callbackfn: ('T -> 'T -> int -> ReadonlyArray<'T> -> 'T) * initialValue: 'T -> 'T + /// + /// Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + /// + /// + /// A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + /// + /// + /// If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + /// + abstract member reduceRight: callbackfn: ('U -> 'T -> int -> ReadonlyArray<'T> -> 'U) * initialValue: 'U -> 'U + + [] + abstract member Item: n: int -> 'T with get + [] let NaN: float = nativeOnly