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
2
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.8 to 1.1.1

2

dist/src/lexer/Token.d.ts

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

export declare type TokenType = '(' | ')' | '[' | ']' | '{' | '}' | '|' | '&' | '<' | '>' | ',' | '*' | '?' | '!' | '=' | ':' | '.' | '@' | '#' | '~' | '/' | '=>' | '...' | 'null' | 'undefined' | 'function' | 'this' | 'new' | 'module' | 'event' | 'external' | 'typeof' | 'keyof' | 'import' | 'Identifier' | 'StringValue' | 'Number' | 'EOF';
export declare type TokenType = '(' | ')' | '[' | ']' | '{' | '}' | '|' | '&' | '<' | '>' | ';' | ',' | '*' | '?' | '!' | '=' | ':' | '.' | '@' | '#' | '~' | '/' | '=>' | '...' | 'null' | 'undefined' | 'function' | 'this' | 'new' | 'module' | 'event' | 'external' | 'typeof' | 'keyof' | 'import' | 'Identifier' | 'StringValue' | 'Number' | 'EOF';
export interface Token {

@@ -3,0 +3,0 @@ type: TokenType;

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

import { InfixParslet, PrefixParslet } from './Parslet';
import { InfixParslet } from './Parslet';
import { TokenType } from '../lexer/Token';

@@ -8,11 +8,6 @@ import { Precedence } from '../Precedence';

import { IntermediateResult } from '../result/IntermediateResult';
export declare class ArrowFunctionWithoutParametersParslet implements PrefixParslet {
export declare class ArrowFunctionParslet extends BaseFunctionParslet implements InfixParslet {
accepts(type: TokenType, next: TokenType): boolean;
getPrecedence(): Precedence;
parsePrefix(parser: Parser): FunctionResult;
}
export declare class ArrowFunctionWithParametersParslet extends BaseFunctionParslet implements InfixParslet {
accepts(type: TokenType, next: TokenType): boolean;
getPrecedence(): Precedence;
parseInfix(parser: Parser, left: IntermediateResult): FunctionResult;
}

@@ -6,4 +6,3 @@ import { KeyValueResult } from '../result/NonTerminalResult';

protected getParameters(value: IntermediateResult): Array<TerminalResult | KeyValueResult>;
protected getNamedParameters(value: IntermediateResult): KeyValueResult[];
protected getUnnamedParameters(value: IntermediateResult): TerminalResult[];
}

@@ -134,2 +134,5 @@ import { JsdocObjectKeyValueResult, KeyValueResult, PropertyResult } from './NonTerminalResult';

elements: Array<KeyValueResult | JsdocObjectKeyValueResult>;
meta: {
separator: 'comma' | 'semicolon';
};
}

@@ -136,0 +139,0 @@ export declare type SpecialNamePathType = 'module' | 'event' | 'external';

{
"name": "jsdoc-type-pratt-parser",
"version": "1.0.8",
"version": "1.1.1",
"description": "",

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

"test:coverage": "nyc --all npm run test:spec",
"test:coveralls": "nyc report --reporter=lcov && coveralls",
"lint": "ts-standard",

@@ -31,3 +32,2 @@ "typecheck": "tsc --noEmit",

},
"dependencies": {},
"devDependencies": {

@@ -44,2 +44,3 @@ "@rollup/plugin-typescript": "^8.1.1",

"chai": "^4.3.0",
"coveralls": "^3.1.0",
"eslint-config-standard-with-typescript": "^20.0.0",

@@ -82,3 +83,6 @@ "jsdoctypeparser": "^9.0.0",

"main",
"dev"
{
"name": "dev",
"prerelease": true
}
],

@@ -85,0 +89,0 @@ "plugins": [

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

[![Test Status](https://github.com/simonseyock/jsdoc-type-pratt-parser/actions/workflows/test.js.yml/badge.svg?branch=main)](https://github.com/simonseyock/jsdoc-type-pratt-parser/actions?query=branch%3Amain)
[![Npm Package](https://badgen.net/npm/v/jsdoc-type-pratt-parser/alpha)](https://www.npmjs.com/package/jsdoc-type-pratt-parser)
[![Npm Package](https://badgen.net/npm/v/jsdoc-type-pratt-parser)](https://www.npmjs.com/package/jsdoc-type-pratt-parser)
[![Test Status](https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/actions?query=branch%3Amain)
[![Coverage Status](https://coveralls.io/repos/github/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/badge.svg?branch=main)](https://coveralls.io/github/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser?branch=main)
[![Code Style](https://badgen.net/badge/code%20style/ts-standard/blue?icon=typescript)](https://github.com/standard/ts-standard)

@@ -16,3 +17,3 @@ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

A simple live demo to test expressions can be found at: https://simonseyock.github.io/jsdoc-type-pratt-parser/
A simple live demo to test expressions can be found at: https://jsdoc-type-pratt-parser.github.io/jsdoc-type-pratt-parser/

@@ -115,3 +116,3 @@ Getting started

-----------------
An API documentation can be found here: https://simonseyock.github.io/jsdoc-type-pratt-parser/docs/modules.html
An API documentation can be found here: https://jsdoc-type-pratt-parser.github.io/jsdoc-type-pratt-parser/docs/modules.html

@@ -118,0 +119,0 @@ Performance

@@ -11,4 +11,3 @@ import { TupleParslet } from '../parslets/TupleParslet'

import {
ArrowFunctionWithoutParametersParslet,
ArrowFunctionWithParametersParslet
ArrowFunctionParslet
} from '../parslets/ArrowFunctionParslet'

@@ -45,3 +44,2 @@ import { NamePathParslet } from '../parslets/NamePathParslet'

new StringValueParslet(),
new ArrowFunctionWithoutParametersParslet(),
new FunctionParslet({

@@ -68,3 +66,3 @@ allowWithoutParenthesis: true,

new ArrayBracketsParslet(),
new ArrowFunctionWithParametersParslet(),
new ArrowFunctionParslet(),
new NamePathParslet({

@@ -71,0 +69,0 @@ allowJsdocNamePaths: false

@@ -59,5 +59,2 @@ import { Token, TokenType } from './Token'

} while (position < text.length)
if (position === 0) {
return null
}
return text.slice(0, position)

@@ -157,2 +154,3 @@ }

makePunctuationRule(','),
makePunctuationRule(';'),
makePunctuationRule('*'),

@@ -159,0 +157,0 @@ makePunctuationRule('?'),

@@ -12,2 +12,3 @@ export type TokenType =

| '>'
| ';'
| ','

@@ -14,0 +15,0 @@ | '*'

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

import { InfixParslet, PrefixParslet } from './Parslet'
import { InfixParslet } from './Parslet'
import { TokenType } from '../lexer/Token'

@@ -10,30 +10,4 @@ import { Precedence } from '../Precedence'

export class ArrowFunctionWithoutParametersParslet implements PrefixParslet {
export class ArrowFunctionParslet extends BaseFunctionParslet implements InfixParslet {
accepts (type: TokenType, next: TokenType): boolean {
return type === '(' && next === ')'
}
getPrecedence (): Precedence {
return Precedence.ARROW
}
parsePrefix (parser: Parser): FunctionResult {
const hasParenthesis = parser.consume('(')
parser.consume(')')
if (!parser.consume('=>')) {
throw new Error('Unexpected empty parenthesis. Expected \'=>\' afterwards.')
}
return {
type: 'JsdocTypeFunction',
parameters: [],
arrow: true,
parenthesis: hasParenthesis,
returnType: parser.parseType(Precedence.ALL)
}
}
}
export class ArrowFunctionWithParametersParslet extends BaseFunctionParslet implements InfixParslet {
accepts (type: TokenType, next: TokenType): boolean {
return type === '=>'

@@ -40,0 +14,0 @@ }

@@ -21,10 +21,2 @@ import { KeyValueResult, NonTerminalResult } from '../result/NonTerminalResult'

protected getNamedParameters (value: IntermediateResult): KeyValueResult[] {
const parameters = this.getParameters(value)
if (parameters.some(p => p.type !== 'JsdocTypeKeyValue')) {
throw new Error('All parameters should be named')
}
return parameters as KeyValueResult[]
}
protected getUnnamedParameters (value: IntermediateResult): TerminalResult[] {

@@ -31,0 +23,0 @@ const parameters = this.getParameters(value)

@@ -31,2 +31,5 @@ import { PrefixParslet } from './Parslet'

type: 'JsdocTypeObject',
meta: {
separator: 'comma'
},
elements: []

@@ -36,3 +39,5 @@ }

if (!parser.consume('}')) {
do {
let separator: 'comma' | 'semicolon' | undefined
while (true) {
let field = parser.parseIntermediateType(Precedence.OBJECT)

@@ -66,3 +71,13 @@

}
} while (parser.consume(','))
if (parser.consume(',')) {
separator = 'comma'
} else if (parser.consume(';')) {
separator = 'semicolon'
} else {
break
}
}
result.meta.separator = separator ?? 'comma'
if (!parser.consume('}')) {

@@ -69,0 +84,0 @@ throw new Error('Unterminated record type. Missing \'}\'')

@@ -174,2 +174,5 @@ import { JsdocObjectKeyValueResult, KeyValueResult, PropertyResult } from './NonTerminalResult'

elements: Array<KeyValueResult | JsdocObjectKeyValueResult>
meta: {
separator: 'comma' | 'semicolon'
}
}

@@ -176,0 +179,0 @@

@@ -71,2 +71,5 @@ import { TransformRules } from './transform'

type: 'JsdocTypeObject',
meta: {
separator: 'comma'
},
elements: result.elements.map(transform) as Array<KeyValueResult | JsdocObjectKeyValueResult>

@@ -73,0 +76,0 @@ }),

@@ -101,3 +101,3 @@ import { transform, TransformRules } from './transform'

JsdocTypeObject: (result, transform) => `{${result.elements.map(transform).join(', ')}}`,
JsdocTypeObject: (result, transform) => `{${result.elements.map(transform).join((result.meta.separator === 'comma' ? ',' : ';') + ' ')}}`,

@@ -104,0 +104,0 @@ JsdocTypeOptional: (result, transform) => applyPosition(result.meta.position, transform(result.element), '='),

Sorry, the diff of this file is too big to display

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