Skip to content

Commit

Permalink
Upgrade to typescript 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Fletcher91 committed Oct 29, 2020
1 parent fd23569 commit eedaf1a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"ts-jest": "^24.3.0",
"tslint": "^5.20.1",
"typedoc": "^0.16.2",
"typescript": "^3.9.2"
"typescript": "^4.0.5"
},
"babel": {
"presets": [
Expand Down
17 changes: 12 additions & 5 deletions src/store/BasicStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ export default class BasicStore implements LowLevelStore {
public readonly dataCallbacks: Array<(quad: Quad) => void>;
public readonly removeCallback: ((quad: Quad) => void) | undefined;

/** Returns the number of quads in the store. */
public length: number = 0;

constructor(opts: Partial<IndexedFormulaOpts> = {}) {
this.dataCallbacks = [];
this.quads = opts.quads || [];
this.rdfFactory = opts.rdfFactory || rdfFactory;
this.rdfArrayRemove = this.rdfFactory.supports?.[Feature.identity]
? this.identityRemove
: this.searchRemove;

Object.defineProperty(this, "length", {
get(): number {
return this.quads.length;
},
set(value: number): void {
this.quads.length = value;
},
});
}

/** Add a quad to the store. */
Expand Down Expand Up @@ -78,11 +90,6 @@ export default class BasicStore implements LowLevelStore {
this.dataCallbacks.push(callback);
}

/** Returns the number of quads in the store. */
public get length(): number {
return this.quads.length;
}

/** Remove a quad from the store */
public remove(st: Quad): this {
const sts = this.match(
Expand Down
26 changes: 12 additions & 14 deletions src/store/RDFIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export type PropertyActionCallback = (quad: Quad) => void;

/** Query and modify an array of quads. */
export default class RDFIndex extends Equatable(Indexable(BasicStore)) implements LowLevelStore {
/** Returns the number of quads in the store. */
public length: number = 0;

private readonly propertyActions: PropertyActionCallback[][] = [];

/**
Expand All @@ -29,6 +32,15 @@ export default class RDFIndex extends Equatable(Indexable(BasicStore)) implement
*/
constructor(opts: Partial<IndexedFormulaOpts> = {}) {
super(opts);

Object.defineProperty(this, "length", {
get(): number {
return this.quads.length;
},
set(value: number): void {
this.quads.length = value;
},
});
}

public any(
Expand Down Expand Up @@ -63,20 +75,6 @@ export default class RDFIndex extends Equatable(Indexable(BasicStore)) implement
return this.match(subject, predicate, object, graph, true)?.[0];
}

/**
* Returns the number of quads contained in this IndexedFormula.
* (Getter proxy to this.quads).
* Usage:
* ```
* const kb = rdf.graph()
* kb.length // -> 0
* ```
* @returns {Number}
*/
public get length(): number {
return this.quads.length;
}

public holds(s: SomeNode, p: NamedNode, o: SomeTerm, g: SomeNode): boolean {
return this.match(s, p, o, g, true)?.[0] !== undefined;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6550,10 +6550,10 @@ typescript@3.7.x:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==

typescript@^3.9.2:
version "3.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.2.tgz#64e9c8e9be6ea583c54607677dd4680a1cf35db9"
integrity sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==
typescript@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==

uglify-js@^3.1.4:
version "3.8.0"
Expand Down

0 comments on commit eedaf1a

Please sign in to comment.