Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@streamparser/json

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@streamparser/json - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

dist/cjs/index.d.ts.map

9

dist/cjs/index.d.ts

@@ -1,4 +0,4 @@

export { default as JSONParser, JSONParserOptions } from "./jsonparser.js";
export { default as Tokenizer, TokenizerOptions, TokenizerError, } from "./tokenizer.js";
export { default as TokenParser, TokenParserOptions, TokenParserError, } from "./tokenparser.js";
export { default as JSONParser, type JSONParserOptions } from "./jsonparser.js";
export { default as Tokenizer, type TokenizerOptions, TokenizerError, } from "./tokenizer.js";
export { default as TokenParser, type TokenParserOptions, TokenParserError, } from "./tokenparser.js";
export * as utf8 from "./utils/utf-8.js";

@@ -8,3 +8,4 @@ export * as JsonTypes from "./utils/types/jsonTypes.js";

export * as ParsedElementInfo from "./utils/types/parsedElementInfo.js";
export { TokenParserMode, StackElement } from "./utils/types/stackElement.js";
export { TokenParserMode, type StackElement, } from "./utils/types/stackElement.js";
export { default as TokenType } from "./utils/types/tokenType.js";
//# sourceMappingURL=index.d.ts.map

@@ -1,5 +0,5 @@

import { TokenizerOptions } from "./tokenizer.js";
import { TokenParserOptions } from "./tokenparser.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import { type TokenizerOptions } from "./tokenizer.js";
import { type TokenParserOptions } from "./tokenparser.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
export interface JSONParserOptions extends TokenizerOptions, TokenParserOptions {

@@ -19,1 +19,2 @@ }

}
//# sourceMappingURL=jsonparser.d.ts.map

@@ -1,2 +0,2 @@

import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
export interface TokenizerOptions {

@@ -35,1 +35,2 @@ stringBufferSize?: number;

}
//# sourceMappingURL=tokenizer.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +9,3 @@ exports.TokenizerError = void 0;

const bufferedString_js_1 = require("./utils/bufferedString.js");
const tokenType_js_1 = __importDefault(require("./utils/types/tokenType.js"));
// Tokenizer States

@@ -137,3 +141,3 @@ var TokenizerStates;

this.onToken({
token: 11 /* TokenType.SEPARATOR */,
token: tokenType_js_1.default.SEPARATOR,
value: this.separator,

@@ -156,3 +160,3 @@ offset: this.offset + this.separatorBytes.length - 1,

this.onToken({
token: 0 /* TokenType.LEFT_BRACE */,
token: tokenType_js_1.default.LEFT_BRACE,
value: "{",

@@ -165,3 +169,3 @@ offset: this.offset,

this.onToken({
token: 1 /* TokenType.RIGHT_BRACE */,
token: tokenType_js_1.default.RIGHT_BRACE,
value: "}",

@@ -174,3 +178,3 @@ offset: this.offset,

this.onToken({
token: 2 /* TokenType.LEFT_BRACKET */,
token: tokenType_js_1.default.LEFT_BRACKET,
value: "[",

@@ -183,3 +187,3 @@ offset: this.offset,

this.onToken({
token: 3 /* TokenType.RIGHT_BRACKET */,
token: tokenType_js_1.default.RIGHT_BRACKET,
value: "]",

@@ -192,3 +196,3 @@ offset: this.offset,

this.onToken({
token: 4 /* TokenType.COLON */,
token: tokenType_js_1.default.COLON,
value: ":",

@@ -201,3 +205,3 @@ offset: this.offset,

this.onToken({
token: 5 /* TokenType.COMMA */,
token: tokenType_js_1.default.COMMA,
value: ",",

@@ -250,3 +254,3 @@ offset: this.offset,

this.onToken({
token: 9 /* TokenType.STRING */,
token: tokenType_js_1.default.STRING,
value: string,

@@ -353,2 +357,3 @@ offset: this.offset,

}
break;
// Number

@@ -425,2 +430,3 @@ case 20 /* TokenizerStates.NUMBER_AFTER_INITIAL_MINUS */:

continue;
// @ts-ignore fall through case
case 25 /* TokenizerStates.NUMBER_AFTER_E */:

@@ -466,3 +472,3 @@ if (n === 43 /* charset.PLUS_SIGN */ || n === 45 /* charset.HYPHEN_MINUS */) {

this.onToken({
token: 6 /* TokenType.TRUE */,
token: tokenType_js_1.default.TRUE,
value: true,

@@ -498,3 +504,3 @@ offset: this.offset,

this.onToken({
token: 7 /* TokenType.FALSE */,
token: tokenType_js_1.default.FALSE,
value: false,

@@ -524,3 +530,3 @@ offset: this.offset,

this.onToken({
token: 8 /* TokenType.NULL */,
token: tokenType_js_1.default.NULL,
value: null,

@@ -542,3 +548,3 @@ offset: this.offset,

this.onToken({
token: 11 /* TokenType.SEPARATOR */,
token: tokenType_js_1.default.SEPARATOR,
value: this.separator,

@@ -569,3 +575,3 @@ offset: this.offset + this.separatorIndex,

this.onToken({
token: 10 /* TokenType.NUMBER */,
token: tokenType_js_1.default.NUMBER,
value: this.parseNumber(this.bufferedNumber.toString()),

@@ -572,0 +578,0 @@ offset: this.offset,

@@ -1,3 +0,3 @@

import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
export interface TokenParserOptions {

@@ -33,1 +33,2 @@ paths?: string[];

}
//# sourceMappingURL=tokenparser.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenParserError = void 0;
const tokenType_js_1 = require("./utils/types/tokenType.js");
const tokenType_js_1 = __importDefault(require("./utils/types/tokenType.js"));
// Parser States

@@ -130,7 +133,7 @@ var TokenParserState;

if (this.state === 0 /* TokenParserState.VALUE */) {
if (token === 9 /* TokenType.STRING */ ||
token === 10 /* TokenType.NUMBER */ ||
token === 6 /* TokenType.TRUE */ ||
token === 7 /* TokenType.FALSE */ ||
token === 8 /* TokenType.NULL */) {
if (token === tokenType_js_1.default.STRING ||
token === tokenType_js_1.default.NUMBER ||
token === tokenType_js_1.default.TRUE ||
token === tokenType_js_1.default.FALSE ||
token === tokenType_js_1.default.NULL) {
if (this.mode === 0 /* TokenParserMode.OBJECT */) {

@@ -147,3 +150,3 @@ this.value[this.key] = value;

}
if (token === 0 /* TokenType.LEFT_BRACE */) {
if (token === tokenType_js_1.default.LEFT_BRACE) {
this.push();

@@ -166,3 +169,3 @@ if (this.mode === 0 /* TokenParserMode.OBJECT */) {

}
if (token === 2 /* TokenType.LEFT_BRACKET */) {
if (token === tokenType_js_1.default.LEFT_BRACKET) {
this.push();

@@ -186,3 +189,3 @@ if (this.mode === 0 /* TokenParserMode.OBJECT */) {

if (this.mode === 1 /* TokenParserMode.ARRAY */ &&
token === 3 /* TokenType.RIGHT_BRACKET */ &&
token === tokenType_js_1.default.RIGHT_BRACKET &&
this.value.length === 0) {

@@ -194,3 +197,3 @@ this.pop();

if (this.state === 1 /* TokenParserState.KEY */) {
if (token === 9 /* TokenType.STRING */) {
if (token === tokenType_js_1.default.STRING) {
this.key = value;

@@ -200,3 +203,3 @@ this.state = 2 /* TokenParserState.COLON */;

}
if (token === 1 /* TokenType.RIGHT_BRACE */ &&
if (token === tokenType_js_1.default.RIGHT_BRACE &&
Object.keys(this.value).length === 0) {

@@ -208,3 +211,3 @@ this.pop();

if (this.state === 2 /* TokenParserState.COLON */) {
if (token === 4 /* TokenType.COLON */) {
if (token === tokenType_js_1.default.COLON) {
this.state = 0 /* TokenParserState.VALUE */;

@@ -215,3 +218,3 @@ return;

if (this.state === 3 /* TokenParserState.COMMA */) {
if (token === 5 /* TokenType.COMMA */) {
if (token === tokenType_js_1.default.COMMA) {
if (this.mode === 1 /* TokenParserMode.ARRAY */) {

@@ -228,5 +231,5 @@ this.state = 0 /* TokenParserState.VALUE */;

}
if ((token === 1 /* TokenType.RIGHT_BRACE */ &&
if ((token === tokenType_js_1.default.RIGHT_BRACE &&
this.mode === 0 /* TokenParserMode.OBJECT */) ||
(token === 3 /* TokenType.RIGHT_BRACKET */ &&
(token === tokenType_js_1.default.RIGHT_BRACKET &&
this.mode === 1 /* TokenParserMode.ARRAY */)) {

@@ -238,3 +241,3 @@ this.pop();

if (this.state === 6 /* TokenParserState.SEPARATOR */) {
if (token === 11 /* TokenType.SEPARATOR */ && value === this.separator) {
if (token === tokenType_js_1.default.SEPARATOR && value === this.separator) {
this.state = 0 /* TokenParserState.VALUE */;

@@ -244,3 +247,3 @@ return;

}
throw new TokenParserError(`Unexpected ${(0, tokenType_js_1.TokenTypeToString)(token)} (${JSON.stringify(value)}) in state ${TokenParserStateToString(this.state)}`);
throw new TokenParserError(`Unexpected ${tokenType_js_1.default[token]} (${JSON.stringify(value)}) in state ${TokenParserStateToString(this.state)}`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -247,0 +250,0 @@ }

@@ -30,1 +30,2 @@ export interface StringBuilder {

}
//# sourceMappingURL=bufferedString.d.ts.map

@@ -8,1 +8,2 @@ export type JsonPrimitive = string | number | boolean | null;

export type JsonStruct = JsonObject | JsonArray;
//# sourceMappingURL=jsonTypes.d.ts.map

@@ -1,3 +0,3 @@

import { StackElement } from "./stackElement.js";
import { JsonPrimitive, JsonKey, JsonObject, JsonArray, JsonStruct } from "./jsonTypes.js";
import type { StackElement } from "./stackElement.js";
import type { JsonPrimitive, JsonKey, JsonObject, JsonArray, JsonStruct } from "./jsonTypes.js";
export interface ParsedElementInfo {

@@ -27,1 +27,2 @@ value: JsonPrimitive | JsonStruct;

}
//# sourceMappingURL=parsedElementInfo.d.ts.map
import TokenType from "./tokenType.js";
import { JsonPrimitive } from "./jsonTypes.js";
import type { JsonPrimitive } from "./jsonTypes.js";
export interface ParsedTokenInfo {

@@ -56,1 +56,2 @@ token: TokenType;

}
//# sourceMappingURL=parsedTokenInfo.d.ts.map

@@ -1,2 +0,2 @@

import { JsonKey, JsonStruct } from "./jsonTypes.js";
import type { JsonKey, JsonStruct } from "./jsonTypes.js";
export declare const enum TokenParserMode {

@@ -12,1 +12,2 @@ OBJECT = 0,

}
//# sourceMappingURL=stackElement.d.ts.map

@@ -1,2 +0,2 @@

declare const enum TokenType {
declare enum TokenType {
LEFT_BRACE = 0,

@@ -17,1 +17,2 @@ RIGHT_BRACE = 1,

export default TokenType;
//# sourceMappingURL=tokenType.d.ts.map

@@ -106,1 +106,2 @@ export declare const enum charset {

};
//# sourceMappingURL=utf-8.d.ts.map

@@ -1,5 +0,5 @@

export { default as JSONParser, JSONParserOptions } from "./jsonparser.ts";
export { default as JSONParser, type JSONParserOptions } from "./jsonparser.ts";
export {
default as Tokenizer,
TokenizerOptions,
type TokenizerOptions,
TokenizerError,

@@ -9,3 +9,3 @@ } from "./tokenizer.ts";

default as TokenParser,
TokenParserOptions,
type TokenParserOptions,
TokenParserError,

@@ -18,3 +18,6 @@ } from "./tokenparser.ts";

export * as ParsedElementInfo from "./utils/types/parsedElementInfo.ts";
export { TokenParserMode, StackElement } from "./utils/types/stackElement.ts";
export {
TokenParserMode,
type StackElement,
} from "./utils/types/stackElement.ts";
export { default as TokenType } from "./utils/types/tokenType.ts";

@@ -1,5 +0,5 @@

import Tokenizer, { TokenizerOptions } from "./tokenizer.ts";
import TokenParser, { TokenParserOptions } from "./tokenparser.ts";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.ts";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";
import Tokenizer, { type TokenizerOptions } from "./tokenizer.ts";
import TokenParser, { type TokenParserOptions } from "./tokenparser.ts";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.ts";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";

@@ -6,0 +6,0 @@ export interface JSONParserOptions

@@ -13,3 +13,3 @@ # @streamparser/json

```javascript
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -55,3 +55,3 @@ const parser = new JSONParser();

```javascript
import { Tokenizer } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { Tokenizer } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -167,3 +167,3 @@ const tokenizer = new Tokenizer(opts);

```javascript
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -228,3 +228,3 @@ const parser = new JSONParser();

```javascript
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -247,3 +247,3 @@ const parser = new JSONParser({ stringBufferSize: undefined, paths: ['$'] });

```javascript
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -263,3 +263,3 @@ const parser = new JSONParser({ stringBufferSize: undefined });

```javascript
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -302,3 +302,3 @@ const parser = new JSONParser({ stringBufferSize: undefined });

```js
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.13/index.ts";/
import { JSONParser } from "https://deno.land/x/streamparser_json@v0.0.14/index.ts";/

@@ -305,0 +305,0 @@ const jsonparser = new JSONParser({ stringBufferSize: undefined, paths: ['$.*'] });

import { charset, escapedSequences } from "./utils/utf-8.ts";
import {
StringBuilder,
type StringBuilder,
NonBufferedString,

@@ -8,3 +8,3 @@ BufferedString,

import TokenType from "./utils/types/tokenType.ts";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";

@@ -414,2 +414,3 @@ // Tokenizer States

}
break;
// Number

@@ -502,2 +503,3 @@ case TokenizerStates.NUMBER_AFTER_INITIAL_MINUS:

continue;
// @ts-ignore fall through case
case TokenizerStates.NUMBER_AFTER_E:

@@ -504,0 +506,0 @@ if (n === charset.PLUS_SIGN || n === charset.HYPHEN_MINUS) {

@@ -1,3 +0,3 @@

import TokenType, { TokenTypeToString } from "./utils/types/tokenType.ts";
import {
import TokenType from "./utils/types/tokenType.ts";
import type {
JsonPrimitive,

@@ -9,5 +9,8 @@ JsonKey,

} from "./utils/types/jsonTypes.ts";
import { StackElement, TokenParserMode } from "./utils/types/stackElement.ts";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.ts";
import {
type StackElement,
TokenParserMode,
} from "./utils/types/stackElement.ts";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.ts";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.ts";

@@ -287,3 +290,3 @@ // Parser States

throw new TokenParserError(
`Unexpected ${TokenTypeToString(token)} (${JSON.stringify(
`Unexpected ${TokenType[token]} (${JSON.stringify(
value

@@ -290,0 +293,0 @@ )}) in state ${TokenParserStateToString(this.state)}`

@@ -1,3 +0,3 @@

import { StackElement } from "./stackElement.ts";
import {
import type { StackElement } from "./stackElement.ts";
import type {
JsonPrimitive,

@@ -4,0 +4,0 @@ JsonKey,

import TokenType from "./tokenType.ts";
import { JsonPrimitive } from "./jsonTypes.ts";
import type { JsonPrimitive } from "./jsonTypes.ts";

@@ -4,0 +4,0 @@ export interface ParsedTokenInfo {

@@ -1,2 +0,2 @@

import { JsonKey, JsonStruct } from "./jsonTypes.ts";
import type { JsonKey, JsonStruct } from "./jsonTypes.ts";

@@ -3,0 +3,0 @@ export const enum TokenParserMode {

@@ -1,2 +0,2 @@

const enum TokenType {
enum TokenType {
LEFT_BRACE,

@@ -3,0 +3,0 @@ RIGHT_BRACE,

@@ -1,4 +0,4 @@

export { default as JSONParser, JSONParserOptions } from "./jsonparser.js";
export { default as Tokenizer, TokenizerOptions, TokenizerError, } from "./tokenizer.js";
export { default as TokenParser, TokenParserOptions, TokenParserError, } from "./tokenparser.js";
export { default as JSONParser, type JSONParserOptions } from "./jsonparser.js";
export { default as Tokenizer, type TokenizerOptions, TokenizerError, } from "./tokenizer.js";
export { default as TokenParser, type TokenParserOptions, TokenParserError, } from "./tokenparser.js";
export * as utf8 from "./utils/utf-8.js";

@@ -8,3 +8,4 @@ export * as JsonTypes from "./utils/types/jsonTypes.js";

export * as ParsedElementInfo from "./utils/types/parsedElementInfo.js";
export { TokenParserMode, StackElement } from "./utils/types/stackElement.js";
export { TokenParserMode, type StackElement, } from "./utils/types/stackElement.js";
export { default as TokenType } from "./utils/types/tokenType.js";
//# sourceMappingURL=index.d.ts.map

@@ -8,4 +8,4 @@ export { default as JSONParser } from "./jsonparser.js";

export * as ParsedElementInfo from "./utils/types/parsedElementInfo.js";
export { TokenParserMode } from "./utils/types/stackElement.js";
export { TokenParserMode, } from "./utils/types/stackElement.js";
export { default as TokenType } from "./utils/types/tokenType.js";
//# sourceMappingURL=index.js.map

@@ -1,5 +0,5 @@

import { TokenizerOptions } from "./tokenizer.js";
import { TokenParserOptions } from "./tokenparser.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import { type TokenizerOptions } from "./tokenizer.js";
import { type TokenParserOptions } from "./tokenparser.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
export interface JSONParserOptions extends TokenizerOptions, TokenParserOptions {

@@ -19,1 +19,2 @@ }

}
//# sourceMappingURL=jsonparser.d.ts.map

@@ -1,3 +0,3 @@

import Tokenizer from "./tokenizer.js";
import TokenParser from "./tokenparser.js";
import Tokenizer, {} from "./tokenizer.js";
import TokenParser, {} from "./tokenparser.js";
export default class JSONParser {

@@ -4,0 +4,0 @@ constructor(opts = {}) {

@@ -1,2 +0,2 @@

import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
export interface TokenizerOptions {

@@ -35,1 +35,2 @@ stringBufferSize?: number;

}
//# sourceMappingURL=tokenizer.d.ts.map

@@ -1,3 +0,4 @@

import { escapedSequences } from "./utils/utf-8.js";
import { charset, escapedSequences } from "./utils/utf-8.js";
import { NonBufferedString, BufferedString, } from "./utils/bufferedString.js";
import TokenType from "./utils/types/tokenType.js";
// Tokenizer States

@@ -83,3 +84,3 @@ var TokenizerStates;

constructor(opts) {
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.separatorIndex = 0;

@@ -106,3 +107,3 @@ this.bytes_remaining = 0; // number of bytes remaining in multi byte utf8 char to read after split boundary

get isEnded() {
return this.state === 1 /* TokenizerStates.ENDED */;
return this.state === TokenizerStates.ENDED;
}

@@ -128,9 +129,9 @@ write(input) {

switch (this.state) {
case 0 /* TokenizerStates.START */:
case TokenizerStates.START:
this.offset += 1;
if (this.separatorBytes && n === this.separatorBytes[0]) {
if (this.separatorBytes.length === 1) {
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.onToken({
token: 11 /* TokenType.SEPARATOR */,
token: TokenType.SEPARATOR,
value: this.separator,

@@ -141,15 +142,15 @@ offset: this.offset + this.separatorBytes.length - 1,

}
this.state = 28 /* TokenizerStates.SEPARATOR */;
this.state = TokenizerStates.SEPARATOR;
continue;
}
if (n === 32 /* charset.SPACE */ ||
n === 10 /* charset.NEWLINE */ ||
n === 13 /* charset.CARRIAGE_RETURN */ ||
n === 9 /* charset.TAB */) {
if (n === charset.SPACE ||
n === charset.NEWLINE ||
n === charset.CARRIAGE_RETURN ||
n === charset.TAB) {
// whitespace
continue;
}
if (n === 123 /* charset.LEFT_CURLY_BRACKET */) {
if (n === charset.LEFT_CURLY_BRACKET) {
this.onToken({
token: 0 /* TokenType.LEFT_BRACE */,
token: TokenType.LEFT_BRACE,
value: "{",

@@ -160,5 +161,5 @@ offset: this.offset,

}
if (n === 125 /* charset.RIGHT_CURLY_BRACKET */) {
if (n === charset.RIGHT_CURLY_BRACKET) {
this.onToken({
token: 1 /* TokenType.RIGHT_BRACE */,
token: TokenType.RIGHT_BRACE,
value: "}",

@@ -169,5 +170,5 @@ offset: this.offset,

}
if (n === 91 /* charset.LEFT_SQUARE_BRACKET */) {
if (n === charset.LEFT_SQUARE_BRACKET) {
this.onToken({
token: 2 /* TokenType.LEFT_BRACKET */,
token: TokenType.LEFT_BRACKET,
value: "[",

@@ -178,5 +179,5 @@ offset: this.offset,

}
if (n === 93 /* charset.RIGHT_SQUARE_BRACKET */) {
if (n === charset.RIGHT_SQUARE_BRACKET) {
this.onToken({
token: 3 /* TokenType.RIGHT_BRACKET */,
token: TokenType.RIGHT_BRACKET,
value: "]",

@@ -187,5 +188,5 @@ offset: this.offset,

}
if (n === 58 /* charset.COLON */) {
if (n === charset.COLON) {
this.onToken({
token: 4 /* TokenType.COLON */,
token: TokenType.COLON,
value: ":",

@@ -196,5 +197,5 @@ offset: this.offset,

}
if (n === 44 /* charset.COMMA */) {
if (n === charset.COMMA) {
this.onToken({
token: 5 /* TokenType.COMMA */,
token: TokenType.COMMA,
value: ",",

@@ -205,35 +206,35 @@ offset: this.offset,

}
if (n === 116 /* charset.LATIN_SMALL_LETTER_T */) {
this.state = 3 /* TokenizerStates.TRUE1 */;
if (n === charset.LATIN_SMALL_LETTER_T) {
this.state = TokenizerStates.TRUE1;
continue;
}
if (n === 102 /* charset.LATIN_SMALL_LETTER_F */) {
this.state = 6 /* TokenizerStates.FALSE1 */;
if (n === charset.LATIN_SMALL_LETTER_F) {
this.state = TokenizerStates.FALSE1;
continue;
}
if (n === 110 /* charset.LATIN_SMALL_LETTER_N */) {
this.state = 10 /* TokenizerStates.NULL1 */;
if (n === charset.LATIN_SMALL_LETTER_N) {
this.state = TokenizerStates.NULL1;
continue;
}
if (n === 34 /* charset.QUOTATION_MARK */) {
if (n === charset.QUOTATION_MARK) {
this.bufferedString.reset();
this.state = 13 /* TokenizerStates.STRING_DEFAULT */;
this.state = TokenizerStates.STRING_DEFAULT;
continue;
}
if (n >= 49 /* charset.DIGIT_ONE */ && n <= 57 /* charset.DIGIT_NINE */) {
if (n >= charset.DIGIT_ONE && n <= charset.DIGIT_NINE) {
this.bufferedNumber.reset();
this.bufferedNumber.appendChar(n);
this.state = 22 /* TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO */;
this.state = TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO;
continue;
}
if (n === 48 /* charset.DIGIT_ZERO */) {
if (n === charset.DIGIT_ZERO) {
this.bufferedNumber.reset();
this.bufferedNumber.appendChar(n);
this.state = 21 /* TokenizerStates.NUMBER_AFTER_INITIAL_ZERO */;
this.state = TokenizerStates.NUMBER_AFTER_INITIAL_ZERO;
continue;
}
if (n === 45 /* charset.HYPHEN_MINUS */) {
if (n === charset.HYPHEN_MINUS) {
this.bufferedNumber.reset();
this.bufferedNumber.appendChar(n);
this.state = 20 /* TokenizerStates.NUMBER_AFTER_INITIAL_MINUS */;
this.state = TokenizerStates.NUMBER_AFTER_INITIAL_MINUS;
continue;

@@ -243,8 +244,8 @@ }

// STRING
case 13 /* TokenizerStates.STRING_DEFAULT */:
if (n === 34 /* charset.QUOTATION_MARK */) {
case TokenizerStates.STRING_DEFAULT:
if (n === charset.QUOTATION_MARK) {
const string = this.bufferedString.toString();
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.onToken({
token: 9 /* TokenType.STRING */,
token: TokenType.STRING,
value: string,

@@ -256,4 +257,4 @@ offset: this.offset,

}
if (n === 92 /* charset.REVERSE_SOLIDUS */) {
this.state = 14 /* TokenizerStates.STRING_AFTER_BACKSLASH */;
if (n === charset.REVERSE_SOLIDUS) {
this.state = TokenizerStates.STRING_AFTER_BACKSLASH;
continue;

@@ -281,6 +282,6 @@ }

i = buffer.length - 1;
this.state = 19 /* TokenizerStates.STRING_INCOMPLETE_CHAR */;
this.state = TokenizerStates.STRING_INCOMPLETE_CHAR;
continue;
}
if (n >= 32 /* charset.SPACE */) {
if (n >= charset.SPACE) {
this.bufferedString.appendChar(n);

@@ -290,3 +291,3 @@ continue;

break;
case 19 /* TokenizerStates.STRING_INCOMPLETE_CHAR */:
case TokenizerStates.STRING_INCOMPLETE_CHAR:
// check for carry over of a multi byte char split between data chunks

@@ -297,25 +298,25 @@ // & fill temp buffer it with start of this data chunk up to the boundary limit set in the last iteration

i = this.bytes_remaining - 1;
this.state = 13 /* TokenizerStates.STRING_DEFAULT */;
this.state = TokenizerStates.STRING_DEFAULT;
continue;
case 14 /* TokenizerStates.STRING_AFTER_BACKSLASH */:
case TokenizerStates.STRING_AFTER_BACKSLASH:
const controlChar = escapedSequences[n];
if (controlChar) {
this.bufferedString.appendChar(controlChar);
this.state = 13 /* TokenizerStates.STRING_DEFAULT */;
this.state = TokenizerStates.STRING_DEFAULT;
continue;
}
if (n === 117 /* charset.LATIN_SMALL_LETTER_U */) {
if (n === charset.LATIN_SMALL_LETTER_U) {
this.unicode = "";
this.state = 15 /* TokenizerStates.STRING_UNICODE_DIGIT_1 */;
this.state = TokenizerStates.STRING_UNICODE_DIGIT_1;
continue;
}
break;
case 15 /* TokenizerStates.STRING_UNICODE_DIGIT_1 */:
case 16 /* TokenizerStates.STRING_UNICODE_DIGIT_2 */:
case 17 /* TokenizerStates.STRING_UNICODE_DIGIT_3 */:
if ((n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) ||
(n >= 65 /* charset.LATIN_CAPITAL_LETTER_A */ &&
n <= 70 /* charset.LATIN_CAPITAL_LETTER_F */) ||
(n >= 97 /* charset.LATIN_SMALL_LETTER_A */ &&
n <= 102 /* charset.LATIN_SMALL_LETTER_F */)) {
case TokenizerStates.STRING_UNICODE_DIGIT_1:
case TokenizerStates.STRING_UNICODE_DIGIT_2:
case TokenizerStates.STRING_UNICODE_DIGIT_3:
if ((n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) ||
(n >= charset.LATIN_CAPITAL_LETTER_A &&
n <= charset.LATIN_CAPITAL_LETTER_F) ||
(n >= charset.LATIN_SMALL_LETTER_A &&
n <= charset.LATIN_SMALL_LETTER_F)) {
this.unicode += String.fromCharCode(n);

@@ -326,8 +327,8 @@ this.state += 1;

break;
case 18 /* TokenizerStates.STRING_UNICODE_DIGIT_4 */:
if ((n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) ||
(n >= 65 /* charset.LATIN_CAPITAL_LETTER_A */ &&
n <= 70 /* charset.LATIN_CAPITAL_LETTER_F */) ||
(n >= 97 /* charset.LATIN_SMALL_LETTER_A */ &&
n <= 102 /* charset.LATIN_SMALL_LETTER_F */)) {
case TokenizerStates.STRING_UNICODE_DIGIT_4:
if ((n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) ||
(n >= charset.LATIN_CAPITAL_LETTER_A &&
n <= charset.LATIN_CAPITAL_LETTER_F) ||
(n >= charset.LATIN_SMALL_LETTER_A &&
n <= charset.LATIN_SMALL_LETTER_F)) {
const intVal = parseInt(this.unicode + String.fromCharCode(n), 16);

@@ -353,92 +354,94 @@ if (this.highSurrogate === undefined) {

}
this.state = 13 /* TokenizerStates.STRING_DEFAULT */;
this.state = TokenizerStates.STRING_DEFAULT;
continue;
}
break;
// Number
case 20 /* TokenizerStates.NUMBER_AFTER_INITIAL_MINUS */:
if (n === 48 /* charset.DIGIT_ZERO */) {
case TokenizerStates.NUMBER_AFTER_INITIAL_MINUS:
if (n === charset.DIGIT_ZERO) {
this.bufferedNumber.appendChar(n);
this.state = 21 /* TokenizerStates.NUMBER_AFTER_INITIAL_ZERO */;
this.state = TokenizerStates.NUMBER_AFTER_INITIAL_ZERO;
continue;
}
if (n >= 49 /* charset.DIGIT_ONE */ && n <= 57 /* charset.DIGIT_NINE */) {
if (n >= charset.DIGIT_ONE && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);
this.state = 22 /* TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO */;
this.state = TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO;
continue;
}
break;
case 21 /* TokenizerStates.NUMBER_AFTER_INITIAL_ZERO */:
if (n === 46 /* charset.FULL_STOP */) {
case TokenizerStates.NUMBER_AFTER_INITIAL_ZERO:
if (n === charset.FULL_STOP) {
this.bufferedNumber.appendChar(n);
this.state = 23 /* TokenizerStates.NUMBER_AFTER_FULL_STOP */;
this.state = TokenizerStates.NUMBER_AFTER_FULL_STOP;
continue;
}
if (n === 101 /* charset.LATIN_SMALL_LETTER_E */ ||
n === 69 /* charset.LATIN_CAPITAL_LETTER_E */) {
if (n === charset.LATIN_SMALL_LETTER_E ||
n === charset.LATIN_CAPITAL_LETTER_E) {
this.bufferedNumber.appendChar(n);
this.state = 25 /* TokenizerStates.NUMBER_AFTER_E */;
this.state = TokenizerStates.NUMBER_AFTER_E;
continue;
}
i -= 1;
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.emitNumber();
continue;
case 22 /* TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO */:
if (n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) {
case TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO:
if (n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);
continue;
}
if (n === 46 /* charset.FULL_STOP */) {
if (n === charset.FULL_STOP) {
this.bufferedNumber.appendChar(n);
this.state = 23 /* TokenizerStates.NUMBER_AFTER_FULL_STOP */;
this.state = TokenizerStates.NUMBER_AFTER_FULL_STOP;
continue;
}
if (n === 101 /* charset.LATIN_SMALL_LETTER_E */ ||
n === 69 /* charset.LATIN_CAPITAL_LETTER_E */) {
if (n === charset.LATIN_SMALL_LETTER_E ||
n === charset.LATIN_CAPITAL_LETTER_E) {
this.bufferedNumber.appendChar(n);
this.state = 25 /* TokenizerStates.NUMBER_AFTER_E */;
this.state = TokenizerStates.NUMBER_AFTER_E;
continue;
}
i -= 1;
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.emitNumber();
continue;
case 23 /* TokenizerStates.NUMBER_AFTER_FULL_STOP */:
if (n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) {
case TokenizerStates.NUMBER_AFTER_FULL_STOP:
if (n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);
this.state = 24 /* TokenizerStates.NUMBER_AFTER_DECIMAL */;
this.state = TokenizerStates.NUMBER_AFTER_DECIMAL;
continue;
}
break;
case 24 /* TokenizerStates.NUMBER_AFTER_DECIMAL */:
if (n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) {
case TokenizerStates.NUMBER_AFTER_DECIMAL:
if (n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);
continue;
}
if (n === 101 /* charset.LATIN_SMALL_LETTER_E */ ||
n === 69 /* charset.LATIN_CAPITAL_LETTER_E */) {
if (n === charset.LATIN_SMALL_LETTER_E ||
n === charset.LATIN_CAPITAL_LETTER_E) {
this.bufferedNumber.appendChar(n);
this.state = 25 /* TokenizerStates.NUMBER_AFTER_E */;
this.state = TokenizerStates.NUMBER_AFTER_E;
continue;
}
i -= 1;
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.emitNumber();
continue;
case 25 /* TokenizerStates.NUMBER_AFTER_E */:
if (n === 43 /* charset.PLUS_SIGN */ || n === 45 /* charset.HYPHEN_MINUS */) {
// @ts-ignore fall through case
case TokenizerStates.NUMBER_AFTER_E:
if (n === charset.PLUS_SIGN || n === charset.HYPHEN_MINUS) {
this.bufferedNumber.appendChar(n);
this.state = 26 /* TokenizerStates.NUMBER_AFTER_E_AND_SIGN */;
this.state = TokenizerStates.NUMBER_AFTER_E_AND_SIGN;
continue;
}
// Allow cascading
case 26 /* TokenizerStates.NUMBER_AFTER_E_AND_SIGN */:
if (n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) {
case TokenizerStates.NUMBER_AFTER_E_AND_SIGN:
if (n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);
this.state = 27 /* TokenizerStates.NUMBER_AFTER_E_AND_DIGIT */;
this.state = TokenizerStates.NUMBER_AFTER_E_AND_DIGIT;
continue;
}
break;
case 27 /* TokenizerStates.NUMBER_AFTER_E_AND_DIGIT */:
if (n >= 48 /* charset.DIGIT_ZERO */ && n <= 57 /* charset.DIGIT_NINE */) {
case TokenizerStates.NUMBER_AFTER_E_AND_DIGIT:
if (n >= charset.DIGIT_ZERO && n <= charset.DIGIT_NINE) {
this.bufferedNumber.appendChar(n);

@@ -448,23 +451,23 @@ continue;

i -= 1;
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.emitNumber();
continue;
// TRUE
case 3 /* TokenizerStates.TRUE1 */:
if (n === 114 /* charset.LATIN_SMALL_LETTER_R */) {
this.state = 4 /* TokenizerStates.TRUE2 */;
case TokenizerStates.TRUE1:
if (n === charset.LATIN_SMALL_LETTER_R) {
this.state = TokenizerStates.TRUE2;
continue;
}
break;
case 4 /* TokenizerStates.TRUE2 */:
if (n === 117 /* charset.LATIN_SMALL_LETTER_U */) {
this.state = 5 /* TokenizerStates.TRUE3 */;
case TokenizerStates.TRUE2:
if (n === charset.LATIN_SMALL_LETTER_U) {
this.state = TokenizerStates.TRUE3;
continue;
}
break;
case 5 /* TokenizerStates.TRUE3 */:
if (n === 101 /* charset.LATIN_SMALL_LETTER_E */) {
this.state = 0 /* TokenizerStates.START */;
case TokenizerStates.TRUE3:
if (n === charset.LATIN_SMALL_LETTER_E) {
this.state = TokenizerStates.START;
this.onToken({
token: 6 /* TokenType.TRUE */,
token: TokenType.TRUE,
value: true,

@@ -478,25 +481,25 @@ offset: this.offset,

// FALSE
case 6 /* TokenizerStates.FALSE1 */:
if (n === 97 /* charset.LATIN_SMALL_LETTER_A */) {
this.state = 7 /* TokenizerStates.FALSE2 */;
case TokenizerStates.FALSE1:
if (n === charset.LATIN_SMALL_LETTER_A) {
this.state = TokenizerStates.FALSE2;
continue;
}
break;
case 7 /* TokenizerStates.FALSE2 */:
if (n === 108 /* charset.LATIN_SMALL_LETTER_L */) {
this.state = 8 /* TokenizerStates.FALSE3 */;
case TokenizerStates.FALSE2:
if (n === charset.LATIN_SMALL_LETTER_L) {
this.state = TokenizerStates.FALSE3;
continue;
}
break;
case 8 /* TokenizerStates.FALSE3 */:
if (n === 115 /* charset.LATIN_SMALL_LETTER_S */) {
this.state = 9 /* TokenizerStates.FALSE4 */;
case TokenizerStates.FALSE3:
if (n === charset.LATIN_SMALL_LETTER_S) {
this.state = TokenizerStates.FALSE4;
continue;
}
break;
case 9 /* TokenizerStates.FALSE4 */:
if (n === 101 /* charset.LATIN_SMALL_LETTER_E */) {
this.state = 0 /* TokenizerStates.START */;
case TokenizerStates.FALSE4:
if (n === charset.LATIN_SMALL_LETTER_E) {
this.state = TokenizerStates.START;
this.onToken({
token: 7 /* TokenType.FALSE */,
token: TokenType.FALSE,
value: false,

@@ -510,19 +513,19 @@ offset: this.offset,

// NULL
case 10 /* TokenizerStates.NULL1 */:
if (n === 117 /* charset.LATIN_SMALL_LETTER_U */) {
this.state = 11 /* TokenizerStates.NULL2 */;
case TokenizerStates.NULL1:
if (n === charset.LATIN_SMALL_LETTER_U) {
this.state = TokenizerStates.NULL2;
continue;
}
break;
case 11 /* TokenizerStates.NULL2 */:
if (n === 108 /* charset.LATIN_SMALL_LETTER_L */) {
this.state = 12 /* TokenizerStates.NULL3 */;
case TokenizerStates.NULL2:
if (n === charset.LATIN_SMALL_LETTER_L) {
this.state = TokenizerStates.NULL3;
continue;
}
break;
case 12 /* TokenizerStates.NULL3 */:
if (n === 108 /* charset.LATIN_SMALL_LETTER_L */) {
this.state = 0 /* TokenizerStates.START */;
case TokenizerStates.NULL3:
if (n === charset.LATIN_SMALL_LETTER_L) {
this.state = TokenizerStates.START;
this.onToken({
token: 8 /* TokenType.NULL */,
token: TokenType.NULL,
value: null,

@@ -535,3 +538,3 @@ offset: this.offset,

break;
case 28 /* TokenizerStates.SEPARATOR */:
case TokenizerStates.SEPARATOR:
this.separatorIndex += 1;

@@ -543,5 +546,5 @@ if (!this.separatorBytes ||

if (this.separatorIndex === this.separatorBytes.length - 1) {
this.state = 0 /* TokenizerStates.START */;
this.state = TokenizerStates.START;
this.onToken({
token: 11 /* TokenType.SEPARATOR */,
token: TokenType.SEPARATOR,
value: this.separator,

@@ -553,7 +556,7 @@ offset: this.offset + this.separatorIndex,

continue;
case 1 /* TokenizerStates.ENDED */:
if (n === 32 /* charset.SPACE */ ||
n === 10 /* charset.NEWLINE */ ||
n === 13 /* charset.CARRIAGE_RETURN */ ||
n === 9 /* charset.TAB */) {
case TokenizerStates.ENDED:
if (n === charset.SPACE ||
n === charset.NEWLINE ||
n === charset.CARRIAGE_RETURN ||
n === charset.TAB) {
// whitespace

@@ -573,3 +576,3 @@ continue;

this.onToken({
token: 10 /* TokenType.NUMBER */,
token: TokenType.NUMBER,
value: this.parseNumber(this.bufferedNumber.toString()),

@@ -584,4 +587,4 @@ offset: this.offset,

error(err) {
if (this.state !== 1 /* TokenizerStates.ENDED */) {
this.state = 2 /* TokenizerStates.ERROR */;
if (this.state !== TokenizerStates.ENDED) {
this.state = TokenizerStates.ERROR;
}

@@ -592,14 +595,14 @@ this.onError(err);

switch (this.state) {
case 21 /* TokenizerStates.NUMBER_AFTER_INITIAL_ZERO */:
case 22 /* TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO */:
case 24 /* TokenizerStates.NUMBER_AFTER_DECIMAL */:
case 27 /* TokenizerStates.NUMBER_AFTER_E_AND_DIGIT */:
this.state = 1 /* TokenizerStates.ENDED */;
case TokenizerStates.NUMBER_AFTER_INITIAL_ZERO:
case TokenizerStates.NUMBER_AFTER_INITIAL_NON_ZERO:
case TokenizerStates.NUMBER_AFTER_DECIMAL:
case TokenizerStates.NUMBER_AFTER_E_AND_DIGIT:
this.state = TokenizerStates.ENDED;
this.emitNumber();
this.onEnd();
break;
case 0 /* TokenizerStates.START */:
case 2 /* TokenizerStates.ERROR */:
case 28 /* TokenizerStates.SEPARATOR */:
this.state = 1 /* TokenizerStates.ENDED */;
case TokenizerStates.START:
case TokenizerStates.ERROR:
case TokenizerStates.SEPARATOR:
this.state = TokenizerStates.ENDED;
this.onEnd();

@@ -606,0 +609,0 @@ break;

@@ -1,3 +0,3 @@

import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
export interface TokenParserOptions {

@@ -33,1 +33,2 @@ paths?: string[];

}
//# sourceMappingURL=tokenparser.d.ts.map

@@ -1,2 +0,3 @@

import { TokenTypeToString } from "./utils/types/tokenType.js";
import TokenType from "./utils/types/tokenType.js";
import { TokenParserMode, } from "./utils/types/stackElement.js";
// Parser States

@@ -30,3 +31,3 @@ var TokenParserState;

constructor(opts) {
this.state = 0 /* TokenParserState.VALUE */;
this.state = TokenParserState.VALUE;
this.mode = undefined;

@@ -93,3 +94,3 @@ this.key = undefined;

this.state =
this.mode !== undefined ? 3 /* TokenParserState.COMMA */ : 0 /* TokenParserState.VALUE */;
this.mode !== undefined ? TokenParserState.COMMA : TokenParserState.VALUE;
this.emit(value, emit);

@@ -114,3 +115,3 @@ }

if (this.separator) {
this.state = 6 /* TokenParserState.SEPARATOR */;
this.state = TokenParserState.SEPARATOR;
}

@@ -124,19 +125,19 @@ else if (this.separator === undefined) {

get isEnded() {
return this.state === 4 /* TokenParserState.ENDED */;
return this.state === TokenParserState.ENDED;
}
write({ token, value }) {
try {
if (this.state === 0 /* TokenParserState.VALUE */) {
if (token === 9 /* TokenType.STRING */ ||
token === 10 /* TokenType.NUMBER */ ||
token === 6 /* TokenType.TRUE */ ||
token === 7 /* TokenType.FALSE */ ||
token === 8 /* TokenType.NULL */) {
if (this.mode === 0 /* TokenParserMode.OBJECT */) {
if (this.state === TokenParserState.VALUE) {
if (token === TokenType.STRING ||
token === TokenType.NUMBER ||
token === TokenType.TRUE ||
token === TokenType.FALSE ||
token === TokenType.NULL) {
if (this.mode === TokenParserMode.OBJECT) {
this.value[this.key] = value;
this.state = 3 /* TokenParserState.COMMA */;
this.state = TokenParserState.COMMA;
}
else if (this.mode === 1 /* TokenParserMode.ARRAY */) {
else if (this.mode === TokenParserMode.ARRAY) {
this.value.push(value);
this.state = 3 /* TokenParserState.COMMA */;
this.state = TokenParserState.COMMA;
}

@@ -146,8 +147,8 @@ this.emit(value, this.shouldEmit());

}
if (token === 0 /* TokenType.LEFT_BRACE */) {
if (token === TokenType.LEFT_BRACE) {
this.push();
if (this.mode === 0 /* TokenParserMode.OBJECT */) {
if (this.mode === TokenParserMode.OBJECT) {
this.value = this.value[this.key] = {};
}
else if (this.mode === 1 /* TokenParserMode.ARRAY */) {
else if (this.mode === TokenParserMode.ARRAY) {
const val = {};

@@ -160,13 +161,13 @@ this.value.push(val);

}
this.mode = 0 /* TokenParserMode.OBJECT */;
this.state = 1 /* TokenParserState.KEY */;
this.mode = TokenParserMode.OBJECT;
this.state = TokenParserState.KEY;
this.key = undefined;
return;
}
if (token === 2 /* TokenType.LEFT_BRACKET */) {
if (token === TokenType.LEFT_BRACKET) {
this.push();
if (this.mode === 0 /* TokenParserMode.OBJECT */) {
if (this.mode === TokenParserMode.OBJECT) {
this.value = this.value[this.key] = [];
}
else if (this.mode === 1 /* TokenParserMode.ARRAY */) {
else if (this.mode === TokenParserMode.ARRAY) {
const val = [];

@@ -179,9 +180,9 @@ this.value.push(val);

}
this.mode = 1 /* TokenParserMode.ARRAY */;
this.state = 0 /* TokenParserState.VALUE */;
this.mode = TokenParserMode.ARRAY;
this.state = TokenParserState.VALUE;
this.key = 0;
return;
}
if (this.mode === 1 /* TokenParserMode.ARRAY */ &&
token === 3 /* TokenType.RIGHT_BRACKET */ &&
if (this.mode === TokenParserMode.ARRAY &&
token === TokenType.RIGHT_BRACKET &&
this.value.length === 0) {

@@ -192,9 +193,9 @@ this.pop();

}
if (this.state === 1 /* TokenParserState.KEY */) {
if (token === 9 /* TokenType.STRING */) {
if (this.state === TokenParserState.KEY) {
if (token === TokenType.STRING) {
this.key = value;
this.state = 2 /* TokenParserState.COLON */;
this.state = TokenParserState.COLON;
return;
}
if (token === 1 /* TokenType.RIGHT_BRACE */ &&
if (token === TokenType.RIGHT_BRACE &&
Object.keys(this.value).length === 0) {

@@ -205,12 +206,12 @@ this.pop();

}
if (this.state === 2 /* TokenParserState.COLON */) {
if (token === 4 /* TokenType.COLON */) {
this.state = 0 /* TokenParserState.VALUE */;
if (this.state === TokenParserState.COLON) {
if (token === TokenType.COLON) {
this.state = TokenParserState.VALUE;
return;
}
}
if (this.state === 3 /* TokenParserState.COMMA */) {
if (token === 5 /* TokenType.COMMA */) {
if (this.mode === 1 /* TokenParserMode.ARRAY */) {
this.state = 0 /* TokenParserState.VALUE */;
if (this.state === TokenParserState.COMMA) {
if (token === TokenType.COMMA) {
if (this.mode === TokenParserMode.ARRAY) {
this.state = TokenParserState.VALUE;
this.key += 1;

@@ -220,11 +221,11 @@ return;

/* istanbul ignore else */
if (this.mode === 0 /* TokenParserMode.OBJECT */) {
this.state = 1 /* TokenParserState.KEY */;
if (this.mode === TokenParserMode.OBJECT) {
this.state = TokenParserState.KEY;
return;
}
}
if ((token === 1 /* TokenType.RIGHT_BRACE */ &&
this.mode === 0 /* TokenParserMode.OBJECT */) ||
(token === 3 /* TokenType.RIGHT_BRACKET */ &&
this.mode === 1 /* TokenParserMode.ARRAY */)) {
if ((token === TokenType.RIGHT_BRACE &&
this.mode === TokenParserMode.OBJECT) ||
(token === TokenType.RIGHT_BRACKET &&
this.mode === TokenParserMode.ARRAY)) {
this.pop();

@@ -234,9 +235,9 @@ return;

}
if (this.state === 6 /* TokenParserState.SEPARATOR */) {
if (token === 11 /* TokenType.SEPARATOR */ && value === this.separator) {
this.state = 0 /* TokenParserState.VALUE */;
if (this.state === TokenParserState.SEPARATOR) {
if (token === TokenType.SEPARATOR && value === this.separator) {
this.state = TokenParserState.VALUE;
return;
}
}
throw new TokenParserError(`Unexpected ${TokenTypeToString(token)} (${JSON.stringify(value)}) in state ${TokenParserStateToString(this.state)}`);
throw new TokenParserError(`Unexpected ${TokenType[token]} (${JSON.stringify(value)}) in state ${TokenParserStateToString(this.state)}`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -249,4 +250,4 @@ }

error(err) {
if (this.state !== 4 /* TokenParserState.ENDED */) {
this.state = 5 /* TokenParserState.ERROR */;
if (this.state !== TokenParserState.ENDED) {
this.state = TokenParserState.ERROR;
}

@@ -256,4 +257,4 @@ this.onError(err);

end() {
if ((this.state !== 0 /* TokenParserState.VALUE */ &&
this.state !== 6 /* TokenParserState.SEPARATOR */) ||
if ((this.state !== TokenParserState.VALUE &&
this.state !== TokenParserState.SEPARATOR) ||
this.stack.length > 0) {

@@ -263,3 +264,3 @@ this.error(new Error(`Parser ended in mid-parsing (state: ${TokenParserStateToString(this.state)}). Either not all the data was received or the data was invalid.`));

else {
this.state = 4 /* TokenParserState.ENDED */;
this.state = TokenParserState.ENDED;
this.onEnd();

@@ -266,0 +267,0 @@ }

@@ -30,1 +30,2 @@ export interface StringBuilder {

}
//# sourceMappingURL=bufferedString.d.ts.map

@@ -8,1 +8,2 @@ export type JsonPrimitive = string | number | boolean | null;

export type JsonStruct = JsonObject | JsonArray;
//# sourceMappingURL=jsonTypes.d.ts.map

@@ -1,3 +0,3 @@

import { StackElement } from "./stackElement.js";
import { JsonPrimitive, JsonKey, JsonObject, JsonArray, JsonStruct } from "./jsonTypes.js";
import type { StackElement } from "./stackElement.js";
import type { JsonPrimitive, JsonKey, JsonObject, JsonArray, JsonStruct } from "./jsonTypes.js";
export interface ParsedElementInfo {

@@ -27,1 +27,2 @@ value: JsonPrimitive | JsonStruct;

}
//# sourceMappingURL=parsedElementInfo.d.ts.map
import TokenType from "./tokenType.js";
import { JsonPrimitive } from "./jsonTypes.js";
import type { JsonPrimitive } from "./jsonTypes.js";
export interface ParsedTokenInfo {

@@ -56,1 +56,2 @@ token: TokenType;

}
//# sourceMappingURL=parsedTokenInfo.d.ts.map

@@ -1,2 +0,2 @@

export {};
import TokenType from "./tokenType.js";
//# sourceMappingURL=parsedTokenInfo.js.map

@@ -1,2 +0,2 @@

import { JsonKey, JsonStruct } from "./jsonTypes.js";
import type { JsonKey, JsonStruct } from "./jsonTypes.js";
export declare const enum TokenParserMode {

@@ -12,1 +12,2 @@ OBJECT = 0,

}
//# sourceMappingURL=stackElement.d.ts.map

@@ -1,2 +0,2 @@

declare const enum TokenType {
declare enum TokenType {
LEFT_BRACE = 0,

@@ -17,1 +17,2 @@ RIGHT_BRACE = 1,

export default TokenType;
//# sourceMappingURL=tokenType.d.ts.map

@@ -106,1 +106,2 @@ export declare const enum charset {

};
//# sourceMappingURL=utf-8.d.ts.map

@@ -105,11 +105,11 @@ export var charset;

export const escapedSequences = {
[34 /* charset.QUOTATION_MARK */]: 34 /* charset.QUOTATION_MARK */,
[92 /* charset.REVERSE_SOLIDUS */]: 92 /* charset.REVERSE_SOLIDUS */,
[47 /* charset.SOLIDUS */]: 47 /* charset.SOLIDUS */,
[98 /* charset.LATIN_SMALL_LETTER_B */]: 8 /* charset.BACKSPACE */,
[102 /* charset.LATIN_SMALL_LETTER_F */]: 12 /* charset.FORM_FEED */,
[110 /* charset.LATIN_SMALL_LETTER_N */]: 10 /* charset.NEWLINE */,
[114 /* charset.LATIN_SMALL_LETTER_R */]: 13 /* charset.CARRIAGE_RETURN */,
[116 /* charset.LATIN_SMALL_LETTER_T */]: 9 /* charset.TAB */,
[charset.QUOTATION_MARK]: charset.QUOTATION_MARK,
[charset.REVERSE_SOLIDUS]: charset.REVERSE_SOLIDUS,
[charset.SOLIDUS]: charset.SOLIDUS,
[charset.LATIN_SMALL_LETTER_B]: charset.BACKSPACE,
[charset.LATIN_SMALL_LETTER_F]: charset.FORM_FEED,
[charset.LATIN_SMALL_LETTER_N]: charset.NEWLINE,
[charset.LATIN_SMALL_LETTER_R]: charset.CARRIAGE_RETURN,
[charset.LATIN_SMALL_LETTER_T]: charset.TAB,
};
//# sourceMappingURL=utf-8.js.map
{
"name": "@streamparser/json",
"description": "Streaming JSON parser in Javascript for Node.js, Deno and the browser",
"version": "0.0.13",
"version": "0.0.14",
"main": "./dist/mjs/index.js",

@@ -9,10 +9,2 @@ "module": "./dist/mjs/index.js",

"types": "./dist/mjs/index.d.ts",
"typesVersions": {
"*": {
"*": [
"./src/*",
"./src/index.ts"
]
}
},
"type": "module",

@@ -39,4 +31,4 @@ "exports": {

"format": "npm run lint -- --fix",
"build:cjs": "tsc --module commonjs --outDir ./dist/cjs && node ../../build-cjs.js plainjs",
"build:mjs": "tsc --module esnext --outDir ./dist/mjs",
"build:cjs": "tsc --module commonjs --verbatimModuleSyntax false --outDir ./dist/cjs && node ../../build-cjs.js plainjs",
"build:mjs": "tsc --module esnext --verbatimModuleSyntax --outDir ./dist/mjs",
"build:deno": "node ../../build.deno.js . ./dist/deno",

@@ -43,0 +35,0 @@ "build": "npm run build:mjs && npm run build:cjs && npm run build:deno",

@@ -1,5 +0,5 @@

export { default as JSONParser, JSONParserOptions } from "./jsonparser.js";
export { default as JSONParser, type JSONParserOptions } from "./jsonparser.js";
export {
default as Tokenizer,
TokenizerOptions,
type TokenizerOptions,
TokenizerError,

@@ -9,3 +9,3 @@ } from "./tokenizer.js";

default as TokenParser,
TokenParserOptions,
type TokenParserOptions,
TokenParserError,

@@ -18,3 +18,6 @@ } from "./tokenparser.js";

export * as ParsedElementInfo from "./utils/types/parsedElementInfo.js";
export { TokenParserMode, StackElement } from "./utils/types/stackElement.js";
export {
TokenParserMode,
type StackElement,
} from "./utils/types/stackElement.js";
export { default as TokenType } from "./utils/types/tokenType.js";

@@ -1,5 +0,5 @@

import Tokenizer, { TokenizerOptions } from "./tokenizer.js";
import TokenParser, { TokenParserOptions } from "./tokenparser.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import Tokenizer, { type TokenizerOptions } from "./tokenizer.js";
import TokenParser, { type TokenParserOptions } from "./tokenparser.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";

@@ -6,0 +6,0 @@ export interface JSONParserOptions

import { charset, escapedSequences } from "./utils/utf-8.js";
import {
StringBuilder,
type StringBuilder,
NonBufferedString,

@@ -8,3 +8,3 @@ BufferedString,

import TokenType from "./utils/types/tokenType.js";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";

@@ -414,2 +414,3 @@ // Tokenizer States

}
break;
// Number

@@ -502,2 +503,3 @@ case TokenizerStates.NUMBER_AFTER_INITIAL_MINUS:

continue;
// @ts-ignore fall through case
case TokenizerStates.NUMBER_AFTER_E:

@@ -504,0 +506,0 @@ if (n === charset.PLUS_SIGN || n === charset.HYPHEN_MINUS) {

@@ -1,3 +0,3 @@

import TokenType, { TokenTypeToString } from "./utils/types/tokenType.js";
import {
import TokenType from "./utils/types/tokenType.js";
import type {
JsonPrimitive,

@@ -9,5 +9,8 @@ JsonKey,

} from "./utils/types/jsonTypes.js";
import { StackElement, TokenParserMode } from "./utils/types/stackElement.js";
import { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";
import {
type StackElement,
TokenParserMode,
} from "./utils/types/stackElement.js";
import type { ParsedTokenInfo } from "./utils/types/parsedTokenInfo.js";
import type { ParsedElementInfo } from "./utils/types/parsedElementInfo.js";

@@ -287,3 +290,3 @@ // Parser States

throw new TokenParserError(
`Unexpected ${TokenTypeToString(token)} (${JSON.stringify(
`Unexpected ${TokenType[token]} (${JSON.stringify(
value

@@ -290,0 +293,0 @@ )}) in state ${TokenParserStateToString(this.state)}`

@@ -1,3 +0,3 @@

import { StackElement } from "./stackElement.js";
import {
import type { StackElement } from "./stackElement.js";
import type {
JsonPrimitive,

@@ -4,0 +4,0 @@ JsonKey,

import TokenType from "./tokenType.js";
import { JsonPrimitive } from "./jsonTypes.js";
import type { JsonPrimitive } from "./jsonTypes.js";

@@ -4,0 +4,0 @@ export interface ParsedTokenInfo {

@@ -1,2 +0,2 @@

import { JsonKey, JsonStruct } from "./jsonTypes.js";
import type { JsonKey, JsonStruct } from "./jsonTypes.js";

@@ -3,0 +3,0 @@ export const enum TokenParserMode {

@@ -1,2 +0,2 @@

const enum TokenType {
enum TokenType {
LEFT_BRACE,

@@ -3,0 +3,0 @@ RIGHT_BRACE,

@@ -1,2 +0,2 @@

import { runJSONParserTest, TestData } from "./utils/testRunner.js";
import { runJSONParserTest, type TestData } from "./utils/testRunner.js";
import JSONParser from "../src/jsonparser.js";

@@ -3,0 +3,0 @@ import { charset } from "../src/utils/utf-8.js";

@@ -1,2 +0,2 @@

import { runJSONParserTest, TestData } from "./utils/testRunner.js";
import { runJSONParserTest, type TestData } from "./utils/testRunner.js";
import JSONParser from "../src/jsonparser.js";

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import { runJSONParserTest, TestData } from "../utils/testRunner.js";
import { runJSONParserTest, type TestData } from "../utils/testRunner.js";
import JSONParser from "../../src/jsonparser.js";

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import { runJSONParserTest, TestData } from "../utils/testRunner.js";
import { runJSONParserTest, type TestData } from "../utils/testRunner.js";
import { readFileSync } from "fs";

@@ -3,0 +3,0 @@ import JSONParser from "../../src/jsonparser.js";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc