All files LdoDataset.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  2x 2x 2x             2x           2x     32x 32x   2x  
import { Quad } from "@rdfjs/types";
import jsonldDatasetProxy from "jsonld-dataset-proxy";
import { WrapperSubscribableDataset } from "o-dataset-pack";
import { LdoBuilder } from "./LdoBuilder";
import { ShapeType } from "./ShapeType";
import { LdoBase } from "./util";
 
/**
 * Utility for building a linked data object
 */
export class LdoDataset extends WrapperSubscribableDataset<Quad> {
  /**
   * Gets a builder for a given type
   * @param shapeType A ShapeType
   * @returns A builder for the given type
   */
  public usingType<Type extends LdoBase>(
    shapeType: ShapeType<Type>
  ): LdoBuilder<Type> {
    const proxyBuilder = jsonldDatasetProxy(this, shapeType.context);
    return new LdoBuilder(proxyBuilder, shapeType);
  }
}