Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove string table from Transformer and derived classes.
Browse files Browse the repository at this point in the history
dlongley committed Jul 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0f32a92 commit 3fb7370
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
@@ -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});
}

/**
27 changes: 8 additions & 19 deletions lib/Decompressor.js
Original file line number Diff line number Diff line change
@@ -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) {
17 changes: 5 additions & 12 deletions lib/Transformer.js
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 3fb7370

Please sign in to comment.