Skip to content

Commit

Permalink
Improve formatting and style.
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-smith committed Jul 12, 2024
1 parent 7076a6e commit d3626f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
14 changes: 5 additions & 9 deletions lib/Compressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,15 @@ export class Compressor extends Transformer {
}

_transformTypedValue({entries, termType, value, termInfo}) {
let encoder;

encoder = TypedLiteralEncoder.createEncoder({
const encoder = TypedLiteralEncoder.createEncoder({
value,
transformer: this,
termType
}) || TYPE_ENCODERS.get(termType)?.createEncoder({
value,
transformer: this,
termInfo
});
if(!encoder) {
const EncoderClass = TYPE_ENCODERS.get(termType);
encoder = EncoderClass && EncoderClass.createEncoder(
{value, transformer: this, termInfo});
}
if(encoder) {
entries.push(encoder);
return true;
Expand Down Expand Up @@ -240,7 +237,6 @@ export class Compressor extends Transformer {
const {termId, plural} = termInfo;
transformMap.set(termId, plural ? entries : entries[0]);
}

}

/**
Expand Down
13 changes: 5 additions & 8 deletions lib/Decompressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Decompressor extends Transformer {
this.reverseStringTable = _reverseMap(stringTable);
this.reverseUrlSchemeTable = _reverseMap(urlSchemeTable);

//typed literal table is map of maps, process inner map not outer
// typed literal table is map of maps, process inner map not outer
this.reverseTypedLiteralTable = new Map();
if(typedLiteralTable) {
for(const [k, map] of typedLiteralTable) {
Expand Down Expand Up @@ -259,17 +259,14 @@ export class Decompressor extends Transformer {
}

_transformTypedValue({entries, termType, value}) {
let decoder;
decoder = TypedLiteralDecoder.createDecoder({
const decoder = TypedLiteralDecoder.createDecoder({
value,
transformer: this,
termType
}) || TYPE_DECODERS.get(termType)?.createDecoder({
value,
transformer: this
});
if(!decoder) {
const DecoderClass = TYPE_DECODERS.get(termType);
decoder = DecoderClass && DecoderClass.createDecoder(
{value, transformer: this});
}

if(decoder) {
entries.push(decoder.decode({value}));
Expand Down
2 changes: 0 additions & 2 deletions lib/Transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,8 @@ export class Transformer {
}

_getIdForTerm({term, plural}) {

// check term to id table
const id = this.termToId.get(term);

if(id === undefined) {
/*
throw new CborldError(
Expand Down

0 comments on commit d3626f8

Please sign in to comment.