-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[RFC]: achieve ndarray API parity with built-in JavaScript arrays #2656
Copy link
Copy link
Open
Labels
FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.Needs DiscussionNeeds further discussion.Needs further discussion.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.difficulty: 4Likely to be moderately difficult.Likely to be moderately difficult.priority: HighHigh priority concern or feature request.High priority concern or feature request.
Metadata
Metadata
Assignees
Labels
FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.Needs DiscussionNeeds further discussion.Needs further discussion.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.difficulty: 4Likely to be moderately difficult.Likely to be moderately difficult.priority: HighHigh priority concern or feature request.High priority concern or feature request.
Description
This RFC proposes achieving ndarray API parity with built-in JavaScript arrays. Built-in JavaScript
ArrayandTypedArrayobjects have a number of methods for searching, manipulating, sorting, and transforming array data.The goal of this RFC is to add functional APIs providing equivalent functionality for ndarrays. By providing these APIs, stdlib can offer a powerful toolset using a similar vocabulary and interface design as existing art for working with ndarrays. This should help reduce the barrier to ndarray adoption and encourage their more widespread use.
Note, however, that ndarrays have considerable additional complexity due to their multi-dimensional nature, and, in particular, element-wise iteration requires specialized kernels for handling non-contiguous underlying data.
There does exist precedent in stdlib for such kernels (e.g.,
ndarray/base/assign,ndarray/base/nullary, andndarray/base/unary). Those packages also provide C APIs which may or may not be relevant to the functional APIs proposed in this RFC.What follows is an initial list of
Array.prototype.*methods and notes regarding whether an equivalent already exists or what constraints we need to consider when designing ndarray equivalent packages.Top-level:
ndarray/*Array.prototype.atndarray/atArray.prototype.entriesndarray/iter/entriesArray.prototype.everyndarray/everyArray.prototype.forEachndarray/for-eachArray.prototype.mapndarray/mapArray.prototype.filterndarray/filterArray.prototype.slicendarray/sliceArray.prototype.keysndarray/iter/indicesArray.prototype.valuesndarray/iter/valuesArray.prototype.includesndarray/includesArray.prototype.indexOfblas/ext/index-ofArray.prototype.findndarray/base/findndarray/findArray.prototype.findIndexblas/ext/find-indexArray.prototype.lastIndexOfblas/ext/last-index-ofArray.prototype.somendarray/anyArray.prototype.findLastndarray/find-lastArray.prototype.findLastIndexblas/ext/find-last-indexArray.prototype.reversendarray/reverseArray.prototype.toReversedndarray/base/to-reversedndarray/reversedArray.prototype.sortblas/ext/sorthp.Array.prototype.toSortedblas/ext/to-sortedhpArray.prototype.fillndarray/fillandndarray/fill-byndarray/fill-sliceArray.prototype.flatndarray/flattenArray.prototype.reduceArray.prototype.concatndarray/concatArray.prototype.copyWithin(WIP)Array.prototype.reduceRightArray.prototype.flatMapndarray/flatten-byArray.prototype.joinblas/ext/joinArray.prototype.popndarray/popArray.prototype.pushndarray/concat1dArray.prototype.shiftndarray/shiftArray.prototype.splice(WIP)Array.prototype.toLocaleString(WIP)Array.prototype.toSpliced(WIP)Array.prototype.toString(WIP)ndarray.toString()?Array.prototype.unshiftndarray/unshiftArray.prototype.withndarray/withBase:
ndarray/base/*Array.prototype.fillndarray/base/fillArray.prototype.forEachndarray/base/for-eachArray.prototype.mapndarray/base/mapArray.prototype.reversendarray/base/reverseArray.prototype.slicendarray/base/sliceArray.prototype.toReversedndarray/base/to-reversedArray.prototype.everyndarray/base/every-byArray.prototype.somendarray/base/anyArray.prototype.findndarray/base/findArray.prototype.popndarray/base/popArray.prototype.shiftndarray/base/shiftRelated Issues
None.
Questions
No.
Other
No.
Checklist
RFC:.