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

jsdoc-type-pratt-parser

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdoc-type-pratt-parser - npm Package Compare versions

Comparing version 1.0.0-alpha.6.0 to 1.0.0-alpha.7.0

dist/src/parslets/ObjectParslet.d.ts

50

dist/index.js

@@ -477,3 +477,3 @@ (function (global, factory) {

class RecordParslet {
class ObjectParslet {
accepts(type) {

@@ -683,3 +683,3 @@ return type === '{';

new OptionalParslet(),
new RecordParslet(),
new ObjectParslet(),
new NumberParslet(),

@@ -753,6 +753,4 @@ new ParenthesisParslet(),

parameters: [],
meta: {
arrow: false,
parenthesis: hasParenthesis
}
arrow: false,
parenthesis: hasParenthesis
};

@@ -836,5 +834,3 @@ if (hasParenthesis) {

right: next,
meta: {
type
}
pathType: type
};

@@ -1289,6 +1285,4 @@ }

parameters: [],
meta: {
arrow: true,
parenthesis: hasParenthesis
},
arrow: true,
parenthesis: hasParenthesis,
returnType: parser.parseType(Precedence.ALL)

@@ -1313,6 +1307,4 @@ };

parameters: this.getParameters(left).map(assertNamedKeyValueOrName),
meta: {
arrow: true,
parenthesis: true
},
arrow: true,
parenthesis: true,
returnType: parser.parseType(Precedence.ALL)

@@ -1366,3 +1358,3 @@ };

/**
* @public
* Objects of this class are parsers for a {@link ParserMode}. It maintains a parser engine working on a grammar corresponding to the mode.
*/

@@ -1382,2 +1374,6 @@ class Parser {

}
/**
* Parses the given type expression and produces a {@link ParseResult}
* @param text
*/
parse(text) {

@@ -1538,3 +1534,3 @@ return this.engine.parseText(text);

type: 'NameExpression',
name: `${leftResult.name}${result.meta.type}${rightResult.name}`
name: `${leftResult.name}${result.pathType}${rightResult.name}`
};

@@ -1669,3 +1665,3 @@ },

const transformed = {
type: result.meta.arrow ? 'ARROW' : 'FUNCTION',
type: result.arrow ? 'ARROW' : 'FUNCTION',
params: specialParams.params.map(param => {

@@ -1689,3 +1685,3 @@ if (param.type === 'KEY_VALUE') {

}
else if (!result.meta.arrow) {
else if (!result.arrow) {
transformed.this = null;

@@ -1710,3 +1706,3 @@ }

};
if (result.meta.brackets === '[]' && result.elements[0].type === 'FUNCTION' && !result.elements[0].meta.parenthesis) {
if (result.meta.brackets === '[]' && result.elements[0].type === 'FUNCTION' && !result.elements[0].parenthesis) {
transformed.objects[0] = {

@@ -1763,3 +1759,3 @@ type: 'NAME',

const transformed = {
type: getMemberType(result.meta.type),
type: getMemberType(result.pathType),
owner: transform(result.left),

@@ -1826,5 +1822,5 @@ name: `${result.right.value}`,

FUNCTION: (result, transform) => {
if (!result.meta.arrow) {
if (!result.arrow) {
let stringified = 'function';
if (!result.meta.parenthesis) {
if (!result.parenthesis) {
return stringified;

@@ -1850,3 +1846,3 @@ }

: applyPosition(result.meta.position, transform(result.element), '...'),
NAME_PATH: (result, transform) => `${transform(result.left)}${result.meta.type}${transform(result.right)}`,
NAME_PATH: (result, transform) => `${transform(result.left)}${result.pathType}${transform(result.right)}`,
STRING_VALUE: result => `${result.meta.quote}${result.value}${result.meta.quote}`,

@@ -1885,5 +1881,3 @@ ANY: () => '*',

exports.catharsisTransform = catharsisTransform;
exports.extractSpecialParams = extractSpecialParams;
exports.jtpTransform = jtpTransform;
exports.notAvailableTransform = notAvailableTransform;
exports.stringify = stringify;

@@ -1890,0 +1884,0 @@ exports.stringifyRules = stringifyRules;

@@ -7,5 +7,5 @@ /**

export * from './ParseResult';
export * from './transforms/transform';
export * from './transforms/catharsisTransform';
export * from './transforms/jtpTransform';
export * from './transforms/stringify';
export { transform, TransformRule, TransformFunction, TransformRules } from './transforms/transform';
export { catharsisTransform } from './transforms/catharsisTransform';
export { jtpTransform } from './transforms/jtpTransform';
export { stringify, stringifyRules } from './transforms/stringify';

@@ -7,3 +7,3 @@ import { ParseResult } from './ParseResult';

/**
* @public
* Objects of this class are parsers for a {@link ParserMode}. It maintains a parser engine working on a grammar corresponding to the mode.
*/

@@ -13,3 +13,7 @@ export declare class Parser {

constructor({ mode }?: ParserOptions);
/**
* Parses the given type expression and produces a {@link ParseResult}
* @param text
*/
parse(text: string): ParseResult;
}

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

export declare type ParseResult = NameResult | UnionResult | GenericResult | StringValueResult | NullResult | UndefinedResult | AnyResult | UnknownResult | FunctionResult | RecordResult | ModuleResult | NamePathResult | SymbolResult | TypeOfResult | KeyOfResult | ImportResult | TupleResult | OptionalResult<ParseResult> | NullableResult<ParseResult> | NotNullableResult<ParseResult> | VariadicResult<ParseResult> | ParenthesisResult;
/**
* A parse result that corresponds to a valid type expression.
*/
export declare type ParseResult = NameResult | UnionResult | GenericResult | StringValueResult | NullResult | UndefinedResult | AnyResult | UnknownResult | FunctionResult | ObjectResult | ModuleResult | NamePathResult | SymbolResult | TypeOfResult | KeyOfResult | ImportResult | TupleResult | OptionalResult<ParseResult> | NullableResult<ParseResult> | NotNullableResult<ParseResult> | VariadicResult<ParseResult> | ParenthesisResult;
/**
* A parse sub result that might not be a valid type expression on its own.
*/
export declare type NonTerminalResult = ParseResult | KeyValueResult<ParseResult | NameResult | NumberResult> | NumberResult | ParameterList;
/**
* `element` is optional.
*/
export interface OptionalResult<T extends ParseResult> {

@@ -10,2 +19,5 @@ type: 'OPTIONAL';

}
/**
* `element` is nullable.
*/
export interface NullableResult<T extends ParseResult> {

@@ -18,2 +30,5 @@ type: 'NULLABLE';

}
/**
* `element` is not nullable.
*/
export interface NotNullableResult<T extends ParseResult> {

@@ -26,2 +41,5 @@ type: 'NOT_NULLABLE';

}
/**
* `element` is a rest parameter.
*/
export interface VariadicResult<T extends ParseResult> {

@@ -35,2 +53,5 @@ type: 'VARIADIC';

}
/**
* Is a type name.
*/
export interface NameResult {

@@ -43,2 +64,5 @@ type: 'NAME';

}
/**
* Is a type union of `elements`.
*/
export interface UnionResult {

@@ -48,2 +72,8 @@ type: 'UNION';

}
/**
* `left` is a generic type that has `elements` as type values for its type parameters.
* Array types that are written as `Type[]` always have the name `Array` as the `left` type and `elements` will contain
* only one element (in this case the name `Type`). To differentiate `Type[]` and `Array<Type>` there is the meta property
* `brackets`.
*/
export interface GenericResult {

@@ -58,2 +88,5 @@ type: 'GENERIC';

}
/**
* A string value as a type.
*/
export interface StringValueResult {

@@ -66,14 +99,32 @@ type: 'STRING_VALUE';

}
/**
* Is `null`.
*/
export interface NullResult {
type: 'NULL';
}
/**
* Is `undefined`.
*/
export interface UndefinedResult {
type: 'UNDEFINED';
}
/**
* An any result that is represented by `*`.
*/
export interface AnyResult {
type: 'ANY';
}
/**
* An unknown result that is represented by `?`.
*/
export interface UnknownResult {
type: 'UNKNOWN';
}
/**
* Is a function. Has `parameters` which can be named, if the grammar supports it. Some grammars only allow named
* `this` and `new` parameters. Named parameters are returned as {@link KeyValueResult}s. It can have a `returnType`.
* It can be a normal function type or an arrow, which is indicated by `arrow`. If `parenthesis` is false, it is any
* kind of function without specified parameters or return type.
*/
export interface FunctionResult {

@@ -83,7 +134,9 @@ type: 'FUNCTION';

returnType?: ParseResult;
meta: {
arrow: boolean;
parenthesis: boolean;
};
arrow: boolean;
parenthesis: boolean;
}
/**
* A key value pair represented by a `:`. Can occur as a named parameter of a {@link FunctionResult} or as an entry for
* an {@link ObjectResult}. Is a {@link NonTerminalResult}.
*/
export interface KeyValueResult<KeyType = NameResult> {

@@ -94,6 +147,14 @@ type: 'KEY_VALUE';

}
export interface RecordResult {
/**
* An object. Contains entries which can be {@link KeyValueResult}s or {@link NameResult}s. In most grammars the keys
* need to be {@link NameResult}s. In some grammars it possible that an entry is only a {@link ParseResult} or a
* {@link NumberResult} without a key.
*/
export interface ObjectResult {
type: 'OBJECT';
elements: Array<KeyValueResult<ParseResult | NumberResult> | ParseResult | NumberResult>;
}
/**
* A module. Often this is a `left` type of a {@link NamePathResult}.
*/
export interface ModuleResult {

@@ -106,2 +167,5 @@ type: 'MODULE';

}
/**
* A name path. This can be a property path separated by `.` or an inner or static member (`~`, `#`).
*/
export interface NamePathResult {

@@ -111,6 +175,8 @@ type: 'NAME_PATH';

right: NameResult | NumberResult | StringValueResult;
meta: {
type: '~' | '#' | '.';
};
pathType: '~' | '#' | '.';
}
/**
* A number. Can be the key of an {@link ObjectResult} entry or the parameter of a {@link SymbolResult}.
* Is a {@link NonTerminalResult}.
*/
export interface NumberResult {

@@ -120,2 +186,5 @@ type: 'NUMBER';

}
/**
* A symbol.
*/
export interface SymbolResult {

@@ -126,2 +195,5 @@ type: 'SYMBOL';

}
/**
* A typeof. The `element` normally should be a name.
*/
export interface TypeOfResult {

@@ -131,2 +203,5 @@ type: 'TYPE_OF';

}
/**
* A keyof. The `element` normally should be a name.
*/
export interface KeyOfResult {

@@ -136,2 +211,6 @@ type: 'KEY_OF';

}
/**
* An import. The `element` is {@link StringValueResult} representing the path. Often the `left` side of an
* {@link NamePathResult}.
*/
export interface ImportResult {

@@ -141,2 +220,6 @@ type: 'IMPORT';

}
/**
* A parameter list of a function. This is a intermediate result that should never occur in a final result.
* Is a {@link NonTerminalResult}.
*/
export interface ParameterList {

@@ -146,2 +229,5 @@ type: 'PARAMETER_LIST';

}
/**
* A tuple containing multiple `elements`.
*/
export interface TupleResult {

@@ -151,2 +237,5 @@ type: 'TUPLE';

}
/**
* An `element` that is enclosed in parenthesis. Often {@link UnionResult}s.
*/
export interface ParenthesisResult {

@@ -153,0 +242,0 @@ type: 'PARENTHESIS';

import { FunctionResult, KeyValueResult, NonTerminalResult, ParseResult } from '../ParseResult';
declare type TransformFunction<TransformResult> = (parseResult: NonTerminalResult) => TransformResult;
declare type TransformRule<TransformResult, ParseResultType extends NonTerminalResult> = (parseResult: ParseResultType, transform: TransformFunction<TransformResult>) => TransformResult;
export declare type TransformFunction<TransformResult> = (parseResult: NonTerminalResult) => TransformResult;
export declare type TransformRule<TransformResult, ParseResultType extends NonTerminalResult> = (parseResult: ParseResultType, transform: TransformFunction<TransformResult>) => TransformResult;
export declare type TransformRules<TransformResult> = {

@@ -5,0 +5,0 @@ [P in NonTerminalResult as P['type']]: TransformRule<TransformResult, P>;

{
"name": "jsdoc-type-pratt-parser",
"version": "1.0.0-alpha.6.0",
"version": "1.0.0-alpha.7.0",
"description": "",

@@ -18,2 +18,3 @@ "main": "dist/index.js",

"preversion": "npm test",
"prepublish": "npm run build",
"postpublish": "./deploy.sh"

@@ -20,0 +21,0 @@ },

@@ -77,4 +77,6 @@ [![Test Status](https://github.com/simonseyock/jsdoc-type-pratt-parser/actions/workflows/node.js.yml/badge.svg?branch=main)](https://github.com/simonseyock/jsdoc-type-pratt-parser/actions?query=branch%3Amain)

const rules = stringifyRules()
rules.NAME = (result, transform) => 'something else' // `result` is the current node and `transform` is function to transform child nodes.
// `result` is the current node and `transform` is function to transform child nodes.
rules.NAME = (result, transform) => 'something else'
const val = transform(rules, { type: 'NAME', value: 'name'}) // -> 'something else'

@@ -88,7 +90,9 @@ ```

function onEnter(node, parent, property) { // property is the name of the property on parent that contains node
// property is the name of the property on parent that contains node
function onEnter(node, parent, property) {
console.log(node.type)
}
traverse({ type: 'NAME', value: 'name'}, onEnter, console.log) // an onEnter and/or an onLeave function can be supplied
traverse({ type: 'NAME', value: 'name'}, onEnter, console.log)
// an onEnter and/or an onLeave function can be supplied
```

@@ -99,3 +103,3 @@

At the moment there are 3 modes supported: 'jsdoc', 'closure' and 'typescipt'
Three different modes (grammars) are supported: `'jsdoc'`, `'closure'` and `'typescript'`

@@ -105,3 +109,3 @@ Tests Status

This parser runs most tests of https://github.com/hegemonic/catharsis and of
This parser runs most tests of https://github.com/hegemonic/catharsis and
https://github.com/jsdoctypeparser/jsdoctypeparser. It compares the results of the different parsing libraries. If you

@@ -111,6 +115,4 @@ want to find out where the output differs, look in the tests for the comments `// This seems to be an error of ...` or

It adds an increasing number of tests on its own, especially the tests to assure the differences between the modes.
API Documentation
-----------------
An API documentation can be found here: https://simonseyock.github.io/jsdoc-type-pratt-parser/docs/modules.html
import { Grammar } from './Grammar'
import { UnenclosedUnionParslet } from '../parslets/UnionParslets'
import { SpecialTypesParslet } from '../parslets/SpecialTypesParslet'
import { RecordParslet } from '../parslets/RecordParslet'
import { ObjectParslet } from '../parslets/ObjectParslet'
import { GenericParslet } from '../parslets/GenericParslet'

@@ -17,3 +17,3 @@ import { ParenthesisParslet } from '../parslets/ParenthesisParslet'

new OptionalParslet(),
new RecordParslet(),
new ObjectParslet(),
new NumberParslet(),

@@ -20,0 +20,0 @@ new ParenthesisParslet(),

@@ -8,5 +8,5 @@ /**

export * from './ParseResult'
export * from './transforms/transform'
export * from './transforms/catharsisTransform'
export * from './transforms/jtpTransform'
export * from './transforms/stringify'
export { transform, TransformRule, TransformFunction, TransformRules } from './transforms/transform'
export { catharsisTransform } from './transforms/catharsisTransform'
export { jtpTransform } from './transforms/jtpTransform'
export { stringify, stringifyRules } from './transforms/stringify'

@@ -14,3 +14,3 @@ import { ParserEngine } from './ParserEngine'

/**
* @public
* Objects of this class are parsers for a {@link ParserMode}. It maintains a parser engine working on a grammar corresponding to the mode.
*/

@@ -35,2 +35,6 @@ export class Parser {

/**
* Parses the given type expression and produces a {@link ParseResult}
* @param text
*/
parse (text: string): ParseResult {

@@ -37,0 +41,0 @@ return this.engine.parseText(text)

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

/**
* A parse result that corresponds to a valid type expression.
*/
export type ParseResult =

@@ -11,3 +14,3 @@ NameResult

| FunctionResult
| RecordResult
| ObjectResult
| ModuleResult

@@ -26,2 +29,5 @@ | NamePathResult

/**
* A parse sub result that might not be a valid type expression on its own.
*/
export type NonTerminalResult =

@@ -33,2 +39,5 @@ ParseResult

/**
* `element` is optional.
*/
export interface OptionalResult<T extends ParseResult> {

@@ -42,2 +51,5 @@ type: 'OPTIONAL'

/**
* `element` is nullable.
*/
export interface NullableResult<T extends ParseResult> {

@@ -51,2 +63,5 @@ type: 'NULLABLE'

/**
* `element` is not nullable.
*/
export interface NotNullableResult<T extends ParseResult> {

@@ -60,2 +75,5 @@ type: 'NOT_NULLABLE'

/**
* `element` is a rest parameter.
*/
export interface VariadicResult<T extends ParseResult> {

@@ -70,2 +88,5 @@ type: 'VARIADIC'

/**
* Is a type name.
*/
export interface NameResult {

@@ -79,2 +100,5 @@ type: 'NAME'

/**
* Is a type union of `elements`.
*/
export interface UnionResult {

@@ -85,2 +109,8 @@ type: 'UNION'

/**
* `left` is a generic type that has `elements` as type values for its type parameters.
* Array types that are written as `Type[]` always have the name `Array` as the `left` type and `elements` will contain
* only one element (in this case the name `Type`). To differentiate `Type[]` and `Array<Type>` there is the meta property
* `brackets`.
*/
export interface GenericResult {

@@ -96,2 +126,5 @@ type: 'GENERIC'

/**
* A string value as a type.
*/
export interface StringValueResult {

@@ -105,2 +138,5 @@ type: 'STRING_VALUE'

/**
* Is `null`.
*/
export interface NullResult {

@@ -110,2 +146,5 @@ type: 'NULL'

/**
* Is `undefined`.
*/
export interface UndefinedResult {

@@ -115,2 +154,5 @@ type: 'UNDEFINED'

/**
* An any result that is represented by `*`.
*/
export interface AnyResult {

@@ -120,2 +162,5 @@ type: 'ANY'

/**
* An unknown result that is represented by `?`.
*/
export interface UnknownResult {

@@ -125,2 +170,8 @@ type: 'UNKNOWN'

/**
* Is a function. Has `parameters` which can be named, if the grammar supports it. Some grammars only allow named
* `this` and `new` parameters. Named parameters are returned as {@link KeyValueResult}s. It can have a `returnType`.
* It can be a normal function type or an arrow, which is indicated by `arrow`. If `parenthesis` is false, it is any
* kind of function without specified parameters or return type.
*/
export interface FunctionResult {

@@ -130,8 +181,10 @@ type: 'FUNCTION'

returnType?: ParseResult
meta: {
arrow: boolean
parenthesis: boolean
}
arrow: boolean
parenthesis: boolean
}
/**
* A key value pair represented by a `:`. Can occur as a named parameter of a {@link FunctionResult} or as an entry for
* an {@link ObjectResult}. Is a {@link NonTerminalResult}.
*/
export interface KeyValueResult<KeyType = NameResult> {

@@ -143,3 +196,8 @@ type: 'KEY_VALUE'

export interface RecordResult {
/**
* An object. Contains entries which can be {@link KeyValueResult}s or {@link NameResult}s. In most grammars the keys
* need to be {@link NameResult}s. In some grammars it possible that an entry is only a {@link ParseResult} or a
* {@link NumberResult} without a key.
*/
export interface ObjectResult {
type: 'OBJECT'

@@ -149,2 +207,5 @@ elements: Array<KeyValueResult<ParseResult | NumberResult> | ParseResult | NumberResult>

/**
* A module. Often this is a `left` type of a {@link NamePathResult}.
*/
export interface ModuleResult {

@@ -158,2 +219,5 @@ type: 'MODULE'

/**
* A name path. This can be a property path separated by `.` or an inner or static member (`~`, `#`).
*/
export interface NamePathResult {

@@ -163,7 +227,9 @@ type: 'NAME_PATH'

right: NameResult | NumberResult | StringValueResult
meta: {
type: '~' | '#' | '.'
}
pathType: '~' | '#' | '.'
}
/**
* A number. Can be the key of an {@link ObjectResult} entry or the parameter of a {@link SymbolResult}.
* Is a {@link NonTerminalResult}.
*/
export interface NumberResult {

@@ -174,2 +240,5 @@ type: 'NUMBER'

/**
* A symbol.
*/
export interface SymbolResult {

@@ -181,2 +250,5 @@ type: 'SYMBOL'

/**
* A typeof. The `element` normally should be a name.
*/
export interface TypeOfResult {

@@ -187,2 +259,5 @@ type: 'TYPE_OF'

/**
* A keyof. The `element` normally should be a name.
*/
export interface KeyOfResult {

@@ -193,2 +268,6 @@ type: 'KEY_OF'

/**
* An import. The `element` is {@link StringValueResult} representing the path. Often the `left` side of an
* {@link NamePathResult}.
*/
export interface ImportResult {

@@ -199,2 +278,6 @@ type: 'IMPORT'

/**
* A parameter list of a function. This is a intermediate result that should never occur in a final result.
* Is a {@link NonTerminalResult}.
*/
export interface ParameterList {

@@ -205,2 +288,5 @@ type: 'PARAMETER_LIST'

/**
* A tuple containing multiple `elements`.
*/
export interface TupleResult {

@@ -211,2 +297,5 @@ type: 'TUPLE'

/**
* An `element` that is enclosed in parenthesis. Often {@link UnionResult}s.
*/
export interface ParenthesisResult {

@@ -213,0 +302,0 @@ type: 'PARENTHESIS'

@@ -29,6 +29,4 @@ import { InfixParslet, PrefixParslet } from './Parslet'

parameters: [],
meta: {
arrow: true,
parenthesis: hasParenthesis
},
arrow: true,
parenthesis: hasParenthesis,
returnType: parser.parseType(Precedence.ALL)

@@ -57,6 +55,4 @@ }

parameters: this.getParameters(left).map(assertNamedKeyValueOrName),
meta: {
arrow: true,
parenthesis: true
},
arrow: true,
parenthesis: true,
returnType: parser.parseType(Precedence.ALL)

@@ -63,0 +59,0 @@ }

@@ -46,6 +46,4 @@ import { PrefixParslet } from './Parslet'

parameters: [],
meta: {
arrow: false,
parenthesis: hasParenthesis
}
arrow: false,
parenthesis: hasParenthesis
}

@@ -52,0 +50,0 @@

@@ -51,7 +51,5 @@ import { InfixParslet } from './Parslet'

right: next,
meta: {
type
}
pathType: type
}
}
}

@@ -214,3 +214,3 @@ import { ParseResult } from '../ParseResult'

type: 'NameExpression',
name: `${leftResult.name}${result.meta.type}${rightResult.name}`
name: `${leftResult.name}${result.pathType}${rightResult.name}`
}

@@ -217,0 +217,0 @@ },

@@ -272,3 +272,3 @@ import { extractSpecialParams, notAvailableTransform, transform, TransformRules } from './transform'

const transformed: JtpFunctionResult = {
type: result.meta.arrow ? 'ARROW' : 'FUNCTION',
type: result.arrow ? 'ARROW' : 'FUNCTION',
params: specialParams.params.map(param => {

@@ -291,3 +291,3 @@ if (param.type === 'KEY_VALUE') {

transformed.this = transform(specialParams.this)
} else if (!result.meta.arrow) {
} else if (!result.arrow) {
transformed.this = null

@@ -317,3 +317,3 @@ }

if (result.meta.brackets === '[]' && result.elements[0].type === 'FUNCTION' && !result.elements[0].meta.parenthesis) {
if (result.meta.brackets === '[]' && result.elements[0].type === 'FUNCTION' && !result.elements[0].parenthesis) {
transformed.objects[0] = {

@@ -374,3 +374,3 @@ type: 'NAME',

const transformed: JtpMemberResult = {
type: getMemberType(result.meta.type),
type: getMemberType(result.pathType),
owner: transform(result.left),

@@ -377,0 +377,0 @@ name: `${result.right.value}`,

@@ -15,5 +15,5 @@ import { notAvailableTransform, transform, TransformRules } from './transform'

FUNCTION: (result, transform) => {
if (!result.meta.arrow) {
if (!result.arrow) {
let stringified = 'function'
if (!result.meta.parenthesis) {
if (!result.parenthesis) {
return stringified

@@ -42,3 +42,3 @@ }

NAME_PATH: (result, transform) => `${transform(result.left)}${result.meta.type}${transform(result.right)}`,
NAME_PATH: (result, transform) => `${transform(result.left)}${result.pathType}${transform(result.right)}`,

@@ -45,0 +45,0 @@ STRING_VALUE: result => `${result.meta.quote}${result.value}${result.meta.quote}`,

import { FunctionResult, KeyValueResult, NonTerminalResult, ParseResult } from '../ParseResult'
type TransformFunction<TransformResult> = (parseResult: NonTerminalResult) => TransformResult
export type TransformFunction<TransformResult> = (parseResult: NonTerminalResult) => TransformResult
type TransformRule<TransformResult, ParseResultType extends NonTerminalResult> = (parseResult: ParseResultType, transform: TransformFunction<TransformResult>) => TransformResult
export type TransformRule<TransformResult, ParseResultType extends NonTerminalResult> = (parseResult: ParseResultType, transform: TransformFunction<TransformResult>) => TransformResult

@@ -7,0 +7,0 @@ export type TransformRules<TransformResult> = {

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