@types/clownface
Advanced tools
Comparing version 1.5.2 to 2.0.0
import { Literal } from 'rdf-js'; | ||
import { FilterCallback } from './'; | ||
import { FilterCallback } from './index.js'; | ||
@@ -10,2 +10,2 @@ declare function taggedLiteral(language: string | string[]): FilterCallback<any, any, Literal | Literal[]>; | ||
export = filters; | ||
export default filters; |
@@ -1,2 +0,2 @@ | ||
// Type definitions for clownface 1.5 | ||
// Type definitions for clownface 2.0 | ||
// Project: https://github.com/rdf-ext/clownface | ||
@@ -8,51 +8,50 @@ // Definitions by: tpluscode <https://github.com/tpluscode> | ||
import { Term, DatasetCore, Quad_Graph, NamedNode, BlankNode, Literal } from 'rdf-js'; | ||
import { Context } from './lib/Context'; | ||
import { Term, DatasetCore, Quad_Graph, NamedNode, BlankNode, Literal, DatasetCoreFactory } from 'rdf-js'; | ||
import Context from './lib/Context.js'; | ||
declare namespace clownface { | ||
type AnyContext = Term | Term[] | undefined; | ||
export type AnyContext = Term | Term[] | undefined; | ||
type TermOrClownface<X extends Term = Term> = MultiPointer<X> | X; | ||
type TermOrLiteral<X extends Term = Term> = TermOrClownface<X> | string | number | boolean; | ||
type TermOrClownface<X extends Term = Term> = MultiPointer<X> | X; | ||
type TermOrLiteral<X extends Term = Term> = TermOrClownface<X> | string | number | boolean; | ||
type AddCallback<D extends DatasetCore, X extends Term> = (added: AnyPointer<X, D>) => void; | ||
type SingleOrArray<T> = T | readonly T[]; | ||
type SingleOrOneElementArray<T> = T | readonly [T]; | ||
type AddCallback<D extends DatasetCore, X extends Term> = (added: AnyPointer<X, D>) => void; | ||
type SingleOrArray<T> = T | readonly T[]; | ||
type SingleOrOneElementArray<T> = T | readonly [T]; | ||
type SingleOrArrayOfTerms<X extends Term> = SingleOrArray<X> | MultiPointer<X>; | ||
type SingleOrArrayOfTermsOrLiterals<X extends Term> = SingleOrArray<TermOrLiteral<X>>; | ||
type SingleOrArrayOfTerms<X extends Term> = SingleOrArray<X> | MultiPointer<X>; | ||
type SingleOrArrayOfTermsOrLiterals<X extends Term> = SingleOrArray<TermOrLiteral<X>>; | ||
interface NodeOptions { | ||
interface NodeOptions { | ||
type?: 'BlankNode' | 'Literal' | 'NamedNode' | undefined; | ||
datatype?: Term | { toString(): string } | undefined; | ||
language?: string | undefined; | ||
} | ||
} | ||
type ClownfaceInit<D extends DatasetCore = DatasetCore> | ||
export type ClownfaceInit<D extends DatasetCore = DatasetCore> | ||
= Partial<Pick<AnyPointer<AnyContext, D>, 'dataset' | '_context'> & { graph: Quad_Graph }>; | ||
type Iteratee<T extends AnyContext = undefined, D extends DatasetCore = DatasetCore> = | ||
type Iteratee<T extends AnyContext = undefined, D extends DatasetCore = DatasetCore> = | ||
T extends undefined | ||
? never | ||
: T extends any[] | ||
? AnyPointer<T[0], D> | ||
: AnyPointer<T, D>; | ||
? never | ||
: T extends any[] | ||
? AnyPointer<T[0], D> | ||
: AnyPointer<T, D>; | ||
type Predicate<T extends AnyContext = undefined, D extends DatasetCore = DatasetCore> = | ||
type Predicate<T extends AnyContext = undefined, D extends DatasetCore = DatasetCore> = | ||
T extends undefined | ||
? never | ||
: T extends any[] | ||
? Iteratee<T[0], D> | ||
: Iteratee<T, D>; | ||
? never | ||
: T extends any[] | ||
? Iteratee<T[0], D> | ||
: Iteratee<T, D>; | ||
type ExtractContext<T extends AnyContext> = T extends undefined ? never : T extends any[] ? T[0] : T; | ||
type ExtractContext<T extends AnyContext> = T extends undefined ? never : T extends any[] ? T[0] : T; | ||
type FilterCallback<T extends AnyContext = AnyContext, D extends DatasetCore = DatasetCore, S extends T = T> | ||
= (ptr: Iteratee<T, D>, index: number, pointers: Array<GraphPointer<ExtractContext<T>>>) => ptr is Predicate<S, any>; | ||
export type FilterCallback<T extends AnyContext = AnyContext, D extends DatasetCore = DatasetCore, S extends T = T> | ||
= (ptr: Iteratee<T, D>, index: number, pointers: Array<GraphPointer<ExtractContext<T>>>) => ptr is Predicate<S, any>; | ||
interface OutOptions { | ||
interface OutOptions { | ||
language?: string | string[] | undefined; | ||
} | ||
} | ||
interface AnyPointer<T extends AnyContext = AnyContext, D extends DatasetCore = DatasetCore> { | ||
export interface AnyPointer<T extends AnyContext = AnyContext, D extends DatasetCore = DatasetCore> { | ||
readonly term: T extends undefined ? undefined : T extends any[] ? undefined | T[0] : T; | ||
@@ -65,20 +64,33 @@ readonly terms: T extends undefined ? Term[] : T extends any[] ? T : [T]; | ||
readonly _context: Array<Context<D, Term>>; | ||
any(): AnyPointer<AnyContext, D>; | ||
list(): Iterable<GraphPointer<Term, D>> | null; | ||
isList(): this is T extends BlankNode | NamedNode ? ListPointer<T, D> : never; | ||
toArray(): Array<AnyPointer<ExtractContext<T>, D>>; | ||
filter<S extends T>(cb: FilterCallback<T, D, S>): AnyPointer<S, D>; | ||
filter(cb: (ptr: Iteratee<T, D>, index: number, pointers: Array<GraphPointer<ExtractContext<T>>>) => boolean): AnyPointer<T, D>; | ||
forEach(cb: (quad: Iteratee<T, D>) => void): this; | ||
map<X>(cb: (quad: Iteratee<T, D>, index: number) => X): X[]; | ||
node(value: SingleOrOneElementArray<boolean | string | number>, options?: NodeOptions): AnyPointer<Literal, D>; | ||
node(values: Array<boolean | string | number>, options?: NodeOptions): AnyPointer<Literal[], D>; | ||
node<X extends Term>(value: SingleOrOneElementArray<X> | AnyPointer<X, D>, options?: NodeOptions): AnyPointer<X, D>; | ||
node<X extends Term>(value: MultiPointer<X, D> | Iterable<X>, options?: NodeOptions): AnyPointer<X[], D>; | ||
node<X extends Term>(value: Iterable<GraphPointer<X, D>>, options?: NodeOptions): MultiPointer<X, D>; | ||
node<X extends Term[]>(values: X, options?: NodeOptions): AnyPointer<X, D>; | ||
node(value: null, options?: NodeOptions): AnyPointer<BlankNode, D>; | ||
node(values: Array<null> | Iterable<BlankNode>, options?: NodeOptions): AnyPointer<BlankNode[], D>; | ||
@@ -89,15 +101,20 @@ | ||
blankNode(value?: SingleOrOneElementArray<string> | AnyPointer<BlankNode, D>): AnyPointer<BlankNode, D>; | ||
blankNode(values: string[] | MultiPointer<BlankNode, D> | Iterable<BlankNode> | Iterable<GraphPointer<BlankNode, D>>): AnyPointer<BlankNode[], D>; | ||
literal(value: SingleOrOneElementArray<boolean | string | number | Term | null> | AnyPointer<Literal, D>, languageOrDatatype?: string | NamedNode): AnyPointer<Literal, D>; | ||
literal( | ||
values: Array<boolean | string | number | null> | MultiPointer<Literal, D> | Iterable<Literal> | Iterable<GraphPointer<Literal, D>>, | ||
languageOrDatatype?: string | NamedNode | ||
values: Array<boolean | string | number | null> | MultiPointer<Literal, D> | Iterable<Literal> | Iterable<GraphPointer<Literal, D>>, | ||
languageOrDatatype?: string | NamedNode | ||
): AnyPointer<Literal[], D>; | ||
namedNode<Iri extends string = string>(value: SingleOrOneElementArray<string | NamedNode<Iri> | AnyPointer<NamedNode<Iri>, D>>): AnyPointer<NamedNode<Iri>, D>; | ||
namedNode(values: Array<string | NamedNode> | MultiPointer<NamedNode, D> | Iterable<NamedNode> | Iterable<GraphPointer<NamedNode, D>>): AnyPointer<NamedNode[], D>; | ||
in(predicates?: SingleOrArrayOfTerms<Term>): MultiPointer<T extends undefined ? never : NamedNode | BlankNode, D>; | ||
out(predicates?: SingleOrArrayOfTerms<Term>): MultiPointer<T extends undefined ? never : Term, D>; | ||
out(predicates?: SingleOrArrayOfTerms<Term>, options?: OutOptions): MultiPointer<T extends undefined ? never : Literal, D>; | ||
@@ -108,7 +125,11 @@ | ||
addIn(predicates: SingleOrArrayOfTerms<Term>, callback?: AddCallback<D, BlankNode>): AnyPointer<T, D>; | ||
addIn(predicates: SingleOrArrayOfTerms<Term>, bnode: SingleOrOneElementArray<null | undefined>, callback?: AddCallback<D, BlankNode>): AnyPointer<T, D>; | ||
addIn<X extends Term = Term>(predicates: SingleOrArrayOfTerms<Term>, subjects: SingleOrArrayOfTermsOrLiterals<X>, callback?: AddCallback<D, X>): AnyPointer<T, D>; | ||
addOut(predicates: SingleOrArrayOfTerms<Term>, callback?: AddCallback<D, BlankNode>): AnyPointer<T, D>; | ||
addOut(predicates: SingleOrArrayOfTerms<Term>, bnode: SingleOrOneElementArray<null | undefined>, callback?: AddCallback<D, BlankNode>): AnyPointer<T, D>; | ||
addOut<X extends Term = Term>(predicates: SingleOrArrayOfTerms<Term>, objects: SingleOrArrayOfTermsOrLiterals<X>, callback?: AddCallback<D, X>): AnyPointer<T, D>; | ||
@@ -119,24 +140,45 @@ | ||
deleteIn(predicates?: SingleOrArrayOfTerms<Term>, subjects?: SingleOrArrayOfTerms<Term>): AnyPointer<T, D>; | ||
deleteOut(predicates?: SingleOrArrayOfTerms<Term>, objects?: SingleOrArrayOfTerms<Term>): AnyPointer<T, D>; | ||
deleteList(predicates: SingleOrArrayOfTerms<Term>): AnyPointer<T, D>; | ||
} | ||
} | ||
interface ListPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> extends GraphPointer<T, D> { | ||
export interface ListPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> extends GraphPointer<T, D> { | ||
list(): Iterable<Iteratee<Term, D>>; | ||
} | ||
} | ||
type MultiPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> = AnyPointer<T | T[], D>; | ||
type GraphPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> = AnyPointer<T, D>; | ||
export type MultiPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> = AnyPointer<T | T[], D>; | ||
export type GraphPointer<T extends Term = Term, D extends DatasetCore = DatasetCore> = AnyPointer<T, D>; | ||
type ClownfaceInitWithTerms<T extends Term | Term[], D extends DatasetCore> = ClownfaceInit<D> & { term: T }; | ||
type ClownfaceInitWithValue<D extends DatasetCore> = ClownfaceInit<D> & { value: string }; | ||
type ClownfaceInitWithValues<D extends DatasetCore> = ClownfaceInit<D> & { value: string[] }; | ||
export type ClownfaceInitWithTerms<T extends Term | Term[], D extends DatasetCore> = ClownfaceInit<D> & { term: T }; | ||
export type ClownfaceInitWithValue<D extends DatasetCore> = ClownfaceInit<D> & { value: string }; | ||
export type ClownfaceInitWithValues<D extends DatasetCore> = ClownfaceInit<D> & { value: string[] }; | ||
export interface InitClonePointer { | ||
<D extends DatasetCore, T extends AnyContext>(other: AnyPointer<T, D>): AnyPointer<T, D>; | ||
} | ||
declare function clownface<D extends DatasetCore, T extends clownface.AnyContext>(other: clownface.AnyPointer<T, D>): clownface.AnyPointer<T, D>; | ||
declare function clownface<D extends DatasetCore>(options: clownface.ClownfaceInitWithValue<D>): clownface.AnyPointer<Literal, D>; | ||
declare function clownface<D extends DatasetCore>(options: clownface.ClownfaceInitWithValues<D>): clownface.AnyPointer<Literal[], D>; | ||
declare function clownface<D extends DatasetCore, T extends Term | Term[]>(options: clownface.ClownfaceInitWithTerms<T, D>): clownface.AnyPointer<T, D>; | ||
declare function clownface<D extends DatasetCore>(options: clownface.ClownfaceInit<D>): clownface.AnyPointer<clownface.AnyContext, D>; | ||
export interface InitLiteralPointer { | ||
<D extends DatasetCore>(options: ClownfaceInitWithValue<D>): AnyPointer<Literal, D>; | ||
} | ||
export = clownface; | ||
export interface InitLiteralMultiPointer { | ||
<D extends DatasetCore>(options: ClownfaceInitWithValues<D>): AnyPointer<Literal[], D>; | ||
} | ||
export interface InitPointerFromTerms { | ||
<D extends DatasetCore, T extends Term | Term[]>(options: ClownfaceInitWithTerms<T, D>): AnyPointer<T, D>; | ||
} | ||
interface InitAnyPointer { | ||
<D extends DatasetCore>(options: ClownfaceInit<D>): AnyPointer<AnyContext, D>; | ||
} | ||
declare const clownface: InitClonePointer | ||
& InitLiteralPointer | ||
& InitLiteralMultiPointer | ||
& InitPointerFromTerms | ||
& InitAnyPointer; | ||
export default clownface; |
import { DatasetCore, Quad_Graph, Term } from 'rdf-js'; | ||
declare namespace Context { | ||
interface Context<D extends DatasetCore, T extends Term> { | ||
dataset: D; | ||
graph?: Quad_Graph | undefined; | ||
term: T; | ||
} | ||
} | ||
interface Context<D extends DatasetCore, T extends Term> extends Context.Context<D, T> {} | ||
// tslint:disable-next-line no-unnecessary-class | ||
declare class Context<D extends DatasetCore, T extends Term> { | ||
export default class Context<D extends DatasetCore, T extends Term> { | ||
constructor(dataset: D, graph: Quad_Graph | undefined, value: any); | ||
dataset: D; | ||
graph?: Quad_Graph | undefined; | ||
term: T; | ||
} | ||
export = Context; |
{ | ||
"name": "@types/clownface", | ||
"version": "1.5.2", | ||
"version": "2.0.0", | ||
"description": "TypeScript definitions for clownface", | ||
@@ -30,4 +30,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/clownface", | ||
}, | ||
"typesPublisherContentHash": "66373ead1808bfb268f8bdb4d84cdb8e73bd2fc481f3968b24b83e025939a4e5", | ||
"typeScriptVersion": "4.2" | ||
"typesPublisherContentHash": "80722269726e8e0464e61e06473c0d61e76757f88efdfff6cc32ec4ae8199581", | ||
"typeScriptVersion": "4.3", | ||
"type": "module" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Wed, 01 Mar 2023 11:32:40 GMT | ||
* Last updated: Tue, 25 Jul 2023 07:32:54 GMT | ||
* Dependencies: [@types/rdf-js](https://npmjs.com/package/@types/rdf-js) | ||
@@ -14,0 +14,0 @@ * Global values: none |
13162
162
Yes