Open stefaanMLB opened 1 year ago
how would this work? ra
is a plain object and doesn't have a mapEntries
member.
Can be done with this code. Example for the unique
function
declare global {
interface Array<T> {
unique(toKey?: SelectFn<T>): Array<T>
}
}
export interface Array<T> {
unique(toKey?: SelectFn<T>): Array<T>
}
Array.prototype.unique = function <T>(toKey?: SelectFn<T>) {
return unique(this, toKey)
}
The unique
function can then be used like this:
const u = fish.unique(f => f.name)
Some people prefer this fluent
type of API. It also aligns better with the built-in array functions.
Would be nice to have a fluent API, f. i.