refactor: simplify iteratee declarations (#41810)

This commit is contained in:
Tomasz Pluskiewicz
2020-01-23 10:03:14 -08:00
committed by Ben Lichtman
parent 42656c6bd0
commit 41a817a924
+6 -8
View File
@@ -23,8 +23,6 @@ import { EventEmitter } from "events";
*/
export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph;
type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];
/**
* Contains an IRI.
*/
@@ -531,21 +529,21 @@ export interface Dataset<Q extends BaseQuad = Quad> extends DatasetCore<Q> {
*
* This method is aligned with `Array.prototype.every()` in ECMAScript-262.
*/
every(iteratee: PropType<QuadFilterIteratee<Q>, 'test'>): boolean;
every(iteratee: QuadFilterIteratee<Q>['test']): boolean;
/**
* Creates a new dataset with all the quads that pass the test implemented by the provided `iteratee`.
*
* This method is aligned with Array.prototype.filter() in ECMAScript-262.
*/
filter(iteratee: PropType<QuadFilterIteratee<Q>, 'test'>): this;
filter(iteratee: QuadFilterIteratee<Q>['test']): this;
/**
* Executes the provided `iteratee` once on each quad in the dataset.
*
* This method is aligned with `Array.prototype.forEach()` in ECMAScript-262.
*/
forEach(iteratee: PropType<QuadRunIteratee<Q>, 'run'>): void;
forEach(iteratee: QuadRunIteratee<Q>['run']): void;
/**
* Imports all quads from the given stream into the dataset.
@@ -562,7 +560,7 @@ export interface Dataset<Q extends BaseQuad = Quad> extends DatasetCore<Q> {
/**
* Returns a new dataset containing all quads returned by applying `iteratee` to each quad in the current dataset.
*/
map(iteratee: PropType<QuadMapIteratee<Q>, 'map'>): this;
map(iteratee: QuadMapIteratee<Q>['map']): this;
/**
* This method calls the `iteratee` on each `quad` of the `Dataset`. The first time the `iteratee` is called, the
@@ -573,7 +571,7 @@ export interface Dataset<Q extends BaseQuad = Quad> extends DatasetCore<Q> {
*
* This method is aligned with `Array.prototype.reduce()` in ECMAScript-262.
*/
reduce<A = any>(iteratee: PropType<QuadReduceIteratee<A, Q>, 'run'>, initialValue?: A): A;
reduce<A = any>(iteratee: QuadReduceIteratee<A, Q>['run'], initialValue?: A): A;
/**
* Existential quantification method, tests whether some quads in the dataset pass the test implemented by the
@@ -583,7 +581,7 @@ export interface Dataset<Q extends BaseQuad = Quad> extends DatasetCore<Q> {
*
* This method is aligned with `Array.prototype.some()` in ECMAScript-262.
*/
some(iteratee: PropType<QuadFilterIteratee<Q>, 'test'>): boolean;
some(iteratee: QuadFilterIteratee<Q>['test']): boolean;
/**
* Returns the set of quads within the dataset as a host language native sequence, for example an `Array` in