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

@typedefs/parser

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typedefs/parser - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

3

build/index.js

@@ -21,5 +21,6 @@ const { lex, parser } = require('./lib');

* @prop {!Array<!_typedefsParser.Type>} args The arguments of the function.
* @prop {_typedefsParser.Type} return The return type of the function. When the value is set to `null`, it menas the function does not have a return. If the return was actuall `null`, it would be specified as `return: { name: 'null' }`.
* @prop {?_typedefsParser.Type} return The return type of the function. When the value is set to `null`, it menas the function does not have a return. If the return was actuall `null`, it would be specified as `return: { name: 'null' }`.
* @prop {!_typedefsParser.Type} [this] The type of the `this` argument specified as `function(this: Type)`.
* @prop {!_typedefsParser.Type} [new] The type of the `new` argument specified as `function(new: Type)`.
* @prop {!_typedefsParser.Type} [variableArgs] The type of the variable arguments, e.g., `function(...Type)`.
*/

@@ -26,0 +27,0 @@ /**

@@ -35,2 +35,3 @@ const { Fn, fn,

const parseFunction = () => {
/** @type {_typedefsParser.FunctionType} */
const meta = { return: null, args: [] }

@@ -55,2 +56,9 @@ if (peek() != '(') throw new Error('Expecting opening (')

meta.new = parseType()
} else if (peek() == '.' && peekNext() == '.' && peekNext(2) == '.') {
consume()
consume()
consume()
const type = parseType()
if (peek() != ')') throw new Error('Variable args must come last')
meta.variableArgs = type
} else {

@@ -178,3 +186,5 @@ const arg = parseType()

}
return { union }
/** @type {!_typedefsParser.Type} */
const unionType = { union }
return unionType
}

@@ -189,4 +199,8 @@

*/
/**
* @suppress {nonStandardJsDocs}
* @typedef {import('.').FunctionType} _typedefsParser.FunctionType
*/
module.exports.lex = lex
module.exports.parser = parser

@@ -0,1 +1,7 @@

## 29 April 2019
### [1.3.0](https://github.com/artdecocode/parser/compare/v1.2.0...v1.3.0)
- [feature] Parse variable arguments of a function.
## 28 April 2019

@@ -2,0 +8,0 @@

@@ -6,3 +6,3 @@ /* typal types/index.xml */

* The meta information about the function.
* @typedef {{ args: !Array<!_typedefsParser.Type>, return: _typedefsParser.Type, this: (!_typedefsParser.Type|undefined), new: (!_typedefsParser.Type|undefined) }}
* @typedef {{ args: !Array<!_typedefsParser.Type>, return: ?_typedefsParser.Type, this: (!_typedefsParser.Type|undefined), new: (!_typedefsParser.Type|undefined), variableArgs: (!_typedefsParser.Type|undefined) }}
*/

@@ -9,0 +9,0 @@ _typedefsParser.FunctionType

{
"name": "@typedefs/parser",
"version": "1.2.0",
"version": "1.3.0",
"description": "The Parser For JSDoc Types.",

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

@@ -21,5 +21,6 @@ import { lex, parser } from './lib'

* @prop {!Array<!_typedefsParser.Type>} args The arguments of the function.
* @prop {_typedefsParser.Type} return The return type of the function. When the value is set to `null`, it menas the function does not have a return. If the return was actuall `null`, it would be specified as `return: { name: 'null' }`.
* @prop {?_typedefsParser.Type} return The return type of the function. When the value is set to `null`, it menas the function does not have a return. If the return was actuall `null`, it would be specified as `return: { name: 'null' }`.
* @prop {!_typedefsParser.Type} [this] The type of the `this` argument specified as `function(this: Type)`.
* @prop {!_typedefsParser.Type} [new] The type of the `new` argument specified as `function(new: Type)`.
* @prop {!_typedefsParser.Type} [variableArgs] The type of the variable arguments, e.g., `function(...Type)`.
*/

@@ -26,0 +27,0 @@ /**

@@ -35,2 +35,3 @@ import { Fn, fn,

const parseFunction = () => {
/** @type {_typedefsParser.FunctionType} */
const meta = { return: null, args: [] }

@@ -55,2 +56,9 @@ if (peek() != '(') throw new Error('Expecting opening (')

meta.new = parseType()
} else if (peek() == '.' && peekNext() == '.' && peekNext(2) == '.') {
consume()
consume()
consume()
const type = parseType()
if (peek() != ')') throw new Error('Variable args must come last')
meta.variableArgs = type
} else {

@@ -178,3 +186,5 @@ const arg = parseType()

}
return { union }
/** @type {!_typedefsParser.Type} */
const unionType = { union }
return unionType
}

@@ -188,2 +198,6 @@

* @typedef {import('.').Type} _typedefsParser.Type
*/
/**
* @suppress {nonStandardJsDocs}
* @typedef {import('.').FunctionType} _typedefsParser.FunctionType
*/
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