Skip to content

Commit

Permalink
chore: remove json namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mabels committed Dec 5, 2024
1 parent 938cd77 commit 46b6aaf
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 27 deletions.
6 changes: 4 additions & 2 deletions cborg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { encode } from './lib/encode.js'
import { decode, decodeFirst, Tokeniser, tokensToObject } from './lib/decode.js'
import { Token, Type } from './lib/token.js'

import * as json from './lib/json/json.js'
// is this needed for the json module and other independ encoders
export { encodeCustom } from './lib/encode.js'
export { encodeErrPrefix, decodeErrPrefix } from './lib/common.js'
export { asU8A, fromString, decodeCodePointsArray } from './lib/byte-utils.js'

/**
* Export the types that were present in the original manual cborg.d.ts
Expand All @@ -18,7 +21,6 @@ export {
// due to the fact that token.js is used in lib/json and so in
// cborg/json which ends up on bundling to have two copies of token.js
// which will fail stmts like token.type === Type.array
json,
decode,
decodeFirst,
Tokeniser as Tokenizer,
Expand Down
10 changes: 6 additions & 4 deletions lib/json/decode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { decode as _decode, decodeFirst as _decodeFirst } from '../decode.js'
import { Token, Type } from '../token.js'
import { decodeCodePointsArray } from '../byte-utils.js'
import { decodeErrPrefix } from '../common.js'
// never reference the file directly to ensure the
// indepency of the json module
import { decode as _decode, decodeFirst as _decodeFirst } from 'cborg'
import { Token, Type } from 'cborg'
import { decodeCodePointsArray } from 'cborg'
import { decodeErrPrefix } from 'cborg'

/**
* @typedef {import('../../interface').DecodeOptions} DecodeOptions
Expand Down
10 changes: 6 additions & 4 deletions lib/json/encode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Type } from '../token.js'
import { encodeCustom } from '../encode.js'
import { encodeErrPrefix } from '../common.js'
import { asU8A, fromString } from '../byte-utils.js'
// never reference the file directly to ensure the
// indepency of the json module
import { Type } from 'cborg'
import { encodeCustom } from 'cborg'
import { encodeErrPrefix } from 'cborg'
import { asU8A, fromString } from 'cborg'

/**
* @typedef {import('../../interface').EncodeOptions} EncodeOptions
Expand Down
9 changes: 0 additions & 9 deletions lib/json/forward-cborg.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"types": "./types/taglib.d.ts"
},
"./json": {
"import": "./lib/json/forward-cborg.js",
"types": "./types/lib/json/forward-cborg.d.ts"
"import": "./lib/json/json.js",
"types": "./types/lib/json/json.d.ts"
},
"./interface": {
"types": "./types/interface.d.ts"
Expand Down
6 changes: 4 additions & 2 deletions types/cborg.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { encodeCustom } from "./lib/encode.js";
/**
* There was originally just `TypeEncoder` so don't break types by renaming or not exporting
*/
Expand All @@ -14,13 +15,14 @@ export type DecodeOptions = import("./interface").DecodeOptions;
* Export the types that were present in the original manual cborg.d.ts
*/
export type EncodeOptions = import("./interface").EncodeOptions;
import * as json from './lib/json/json.js';
import { decode } from './lib/decode.js';
import { decodeFirst } from './lib/decode.js';
import { Tokeniser } from './lib/decode.js';
import { tokensToObject } from './lib/decode.js';
import { encode } from './lib/encode.js';
import { Token } from './lib/token.js';
import { Type } from './lib/token.js';
export { json, decode, decodeFirst, Tokeniser as Tokenizer, tokensToObject, encode, Token, Type };
export { decode, decodeFirst, Tokeniser as Tokenizer, tokensToObject, encode, Token, Type };
export { encodeErrPrefix, decodeErrPrefix } from "./lib/common.js";
export { asU8A, fromString, decodeCodePointsArray } from "./lib/byte-utils.js";
//# sourceMappingURL=cborg.d.ts.map
2 changes: 1 addition & 1 deletion types/cborg.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/json/decode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ export class Tokenizer implements DecodeTokenizer {
*/
next(): Token;
}
import { Token } from '../token.js';
import { Token } from 'cborg';
//# sourceMappingURL=decode.d.ts.map
2 changes: 1 addition & 1 deletion types/lib/json/decode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/json/encode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46b6aaf

Please sign in to comment.