Skip to content

Commit

Permalink
Remove string table from Transformer and derived classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Jul 14, 2024
1 parent 0f32a92 commit 3fb7370
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.
21 changes: 6 additions & 15 deletions lib/Compressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@ export class Compressor extends Transformer {
* @param {object} options - The options to use.
* @param {documentLoaderFunction} options.documentLoader -The document
* loader to use when resolving JSON-LD Context URLs.
* @param {Map} options.stringTable - A map of string values and
* their associated CBOR-LD integer values.
* @param {Map} options.typeTable - A map of JSON-LD types
* to maps that map values of that type to their associated CBOR-LD
* integer values.
* @param {Map} options.typeTable - A map of possible value types, including
* `context`, `url`, `none`, and any JSON-LD type, each of which maps to
* another map of values of that type to their associated CBOR-LD integer
* values.
*/
constructor({
documentLoader,
stringTable,
typeTable
} = {}) {
super({
documentLoader,
stringTable,
typeTable
});
constructor({documentLoader, typeTable} = {}) {
super({documentLoader, typeTable});
}

/**
Expand Down
27 changes: 8 additions & 19 deletions lib/Decompressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,16 @@ export class Decompressor extends Transformer {
* @param {object} options - The options to use.
* @param {documentLoaderFunction} options.documentLoader -The document
* loader to use when resolving JSON-LD Context URLs.
* @param {Map} options.stringTable - A map of string values and
* their associated CBOR-LD integer values.
* @param {Map} options.typeTable - A map of JSON-LD types
* to maps that map values of that type to their associated CBOR-LD
* integer values.
* @param {Map} options.typeTable - A map of possible value types, including
* `context`, `url`, `none`, and any JSON-LD type, each of which maps to
* another map of values of that type to their associated CBOR-LD integer
* values.
*/
constructor({
documentLoader,
stringTable,
typeTable
} = {}) {
super({
documentLoader,
stringTable,
typeTable
});
constructor({documentLoader, typeTable} = {}) {
super({documentLoader, typeTable});

// build reverse compression tables
this.reverseStringTable = reverseMap(stringTable);

// typed literal table is map of maps, process inner map not outer
// build reverse compression tables, the `typeTable` is a map of maps,
// just reverse each inner map
this.reverseTypeTable = new Map();
if(typeTable) {
for(const [k, map] of typeTable) {
Expand Down
17 changes: 5 additions & 12 deletions lib/Transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ export class Transformer {
* @param {object} options - The options to use.
* @param {documentLoaderFunction} options.documentLoader -The document
* loader to use when resolving JSON-LD Context URLs.
* @param {Map} options.stringTable - A map of string values and
* their associated CBOR-LD integer values.
* @param {Map} options.typeTable - A map of JSON-LD types
* to maps that map values of that type to their associated CBOR-LD
* integer values.
* @param {Map} options.typeTable - A map of possible value types, including
* `context`, `url`, `none`, and any JSON-LD type, each of which maps to
* another map of values of that type to their associated CBOR-LD integer
* values.
*/
constructor({
documentLoader,
stringTable,
typeTable
} = {}) {
constructor({documentLoader, typeTable} = {}) {
this.documentLoader = documentLoader;
this.termToId = new Map(KEYWORDS_TABLE);
// FIXME: remove `stringTable`
this.stringTable = stringTable;
// FIXME: remove `new Map()`?
this.typeTable = typeTable ?? new Map();

Expand Down

0 comments on commit 3fb7370

Please sign in to comment.