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.1.1 to 1.2.0

dist/src/parslets/ReadonlyPropertyParslet.d.ts

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' | 'readonly' | 'import' | 'Identifier' | 'StringValue' | 'Number' | 'EOF';
export interface Token {

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

@@ -10,2 +10,3 @@ import { InfixParslet } from './Parslet';

allowOptional: boolean;
allowReadonly: boolean;
}

@@ -15,2 +16,3 @@ export declare class KeyValueParslet implements InfixParslet {

private readonly allowOptional;
private readonly allowReadonly;
constructor(opts: KeyValueParsletOptions);

@@ -17,0 +19,0 @@ accepts(type: TokenType, next: TokenType): boolean;

import { KeyValueResult, NonTerminalResult } from './NonTerminalResult';
import { TerminalResult } from './TerminalResult';
export declare type IntermediateResult = NonTerminalResult | ParameterList | ReadonlyProperty;
export interface ParameterList {

@@ -7,2 +8,5 @@ type: 'JsdocTypeParameterList';

}
export declare type IntermediateResult = NonTerminalResult | ParameterList;
export interface ReadonlyProperty {
type: 'JsdocTypeReadonlyProperty';
element: TerminalResult;
}

@@ -16,2 +16,3 @@ import { QuoteStyle, TerminalResult } from './TerminalResult';

optional: boolean;
readonly: boolean;
meta: {

@@ -18,0 +19,0 @@ quote: QuoteStyle | undefined;

@@ -129,3 +129,3 @@ import { JsdocObjectKeyValueResult, KeyValueResult, PropertyResult } from './NonTerminalResult';

* need to be {@link NameResult}s. In some grammars it possible that an entry is only a {@link TerminalResult} or a
* {@link NumberResult} without a key.
* {@link NumberResult} without a key. The seperator is `'comma'` by default.
*/

@@ -132,0 +132,0 @@ export interface ObjectResult {

@@ -8,6 +8,6 @@ import 'mocha';

modes: ParseMode[];
jtp: {
jtp?: {
[K in JtpMode]: CompareMode;
};
catharsis: {
catharsis?: {
[K in CatharsisMode]: CompareMode;

@@ -14,0 +14,0 @@ };

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

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

}
if (result.type === 'JsdocTypeKeyValue' || result.type === 'JsdocTypeParameterList' || result.type === 'JsdocTypeProperty') {
if (result.type === 'JsdocTypeKeyValue' || result.type === 'JsdocTypeParameterList' || result.type === 'JsdocTypeProperty' || result.type === 'JsdocTypeReadonlyProperty') {
throw new UnexpectedTypeError(result)

@@ -13,0 +13,0 @@ }

@@ -51,3 +51,4 @@ import { GrammarFactory } from './Grammar'

allowKeyTypes: false,
allowOptional: false
allowOptional: false,
allowReadonly: false
}),

@@ -54,0 +55,0 @@ new SymbolParslet()

@@ -51,3 +51,4 @@ import { GrammarFactory } from './Grammar'

allowKeyTypes: true,
allowOptional: false
allowOptional: false,
allowReadonly: false
}),

@@ -54,0 +55,0 @@ new VariadicParslet({

@@ -21,2 +21,3 @@ import { TupleParslet } from '../parslets/TupleParslet'

import { SpecialNamePathParslet } from '../parslets/SpecialNamePathParslet'
import { ReadonlyPropertyParslet } from '../parslets/ReadonlyPropertyParslet'

@@ -60,3 +61,4 @@ export const typescriptGrammar: GrammarFactory = () => {

allowedTypes: ['module']
})
}),
new ReadonlyPropertyParslet()
],

@@ -72,3 +74,4 @@ infixParslets: [

allowKeyTypes: false,
allowOptional: true
allowOptional: true,
allowReadonly: true
}),

@@ -75,0 +78,0 @@ new IntersectionParslet()

@@ -175,2 +175,3 @@ import { Token, TokenType } from './Token'

makeKeyWordRule('keyof'),
makeKeyWordRule('readonly'),
makeKeyWordRule('import'),

@@ -177,0 +178,0 @@ identifierRule,

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

| 'keyof'
| 'readonly'
| 'import'

@@ -38,0 +39,0 @@ | 'Identifier'

@@ -13,2 +13,3 @@ import { InfixParslet } from './Parslet'

allowOptional: boolean
allowReadonly: boolean
}

@@ -19,2 +20,3 @@

private readonly allowOptional: boolean
private readonly allowReadonly: boolean

@@ -24,2 +26,3 @@ constructor (opts: KeyValueParsletOptions) {

this.allowOptional = opts.allowOptional
this.allowReadonly = opts.allowReadonly
}

@@ -37,2 +40,3 @@

let optional = false
let readonlyProperty = false

@@ -44,2 +48,7 @@ if (this.allowOptional && left.type === 'JsdocTypeNullable') {

if (this.allowReadonly && left.type === 'JsdocTypeReadonlyProperty') {
readonlyProperty = true
left = left.element
}
if (left.type === 'JsdocTypeNumber' || left.type === 'JsdocTypeName' || left.type === 'JsdocTypeStringValue') {

@@ -58,2 +67,3 @@ parser.consume(':')

optional: optional,
readonly: readonlyProperty,
meta: {

@@ -60,0 +70,0 @@ quote

@@ -60,2 +60,3 @@ import { PrefixParslet } from './Parslet'

optional: optional,
readonly: false,
meta: {

@@ -62,0 +63,0 @@ quote

import { KeyValueResult, NonTerminalResult } from './NonTerminalResult'
import { TerminalResult } from './TerminalResult'
export type IntermediateResult = NonTerminalResult | ParameterList | ReadonlyProperty
export interface ParameterList {

@@ -9,2 +11,5 @@ type: 'JsdocTypeParameterList'

export type IntermediateResult = NonTerminalResult | ParameterList
export interface ReadonlyProperty {
type: 'JsdocTypeReadonlyProperty'
element: TerminalResult
}

@@ -22,2 +22,3 @@ import { QuoteStyle, TerminalResult } from './TerminalResult'

optional: boolean
readonly: boolean
meta: {

@@ -24,0 +25,0 @@ quote: QuoteStyle | undefined

@@ -169,3 +169,3 @@ import { JsdocObjectKeyValueResult, KeyValueResult, PropertyResult } from './NonTerminalResult'

* need to be {@link NameResult}s. In some grammars it possible that an entry is only a {@link TerminalResult} or a
* {@link NumberResult} without a key.
* {@link NumberResult} without a key. The seperator is `'comma'` by default.
*/

@@ -172,0 +172,0 @@ export interface ObjectResult {

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

optional: result.optional,
readonly: result.readonly,
meta: result.meta

@@ -100,0 +101,0 @@ }

@@ -80,7 +80,15 @@ import { transform, TransformRules } from './transform'

if ('value' in result) {
const left = `${quote(result.value, result.meta.quote)}${result.optional ? '?' : ''}`
let text = ''
if (result.readonly) {
text += 'readonly '
}
text += quote(result.value, result.meta.quote)
if (result.optional) {
text += '?'
}
if (result.right === undefined) {
return left
return text
} else {
return left + `: ${transform(result.right)}`
return text + `: ${transform(result.right)}`
}

@@ -87,0 +95,0 @@ } else {

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