@typedefs/parser
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,8 +0,6 @@ | ||
const { debuglog } = require('util'); | ||
const { lex, parser } = require('./lib'); | ||
const LOG = debuglog('@typedefs/parser') | ||
/** | ||
* The Parser For JSDoc Types. | ||
* @param {string} type The type to parse, e.g., `!Promise<!Array<function(string)>>` | ||
*/ | ||
@@ -9,0 +7,0 @@ function parse(type) { |
const { Fn, fn, | ||
_null, _undefined, string, boolean, number, symbol, | ||
nullable, nonNullable, | ||
@@ -23,8 +22,2 @@ optional, any, | ||
case '*': return any | ||
case 'string': return string | ||
case 'number': return number | ||
case 'boolean': return boolean | ||
case 'symbol': return symbol | ||
case 'null': return _null | ||
case 'undefined': return _undefined | ||
} | ||
@@ -171,3 +164,2 @@ return a | ||
) { | ||
type.application = true | ||
consume() | ||
@@ -174,0 +166,0 @@ if (applicationWithDot) consume() |
@@ -7,11 +7,3 @@ const Fn = 'Function' | ||
const any = 'any' | ||
const _null = 'null' | ||
const _undefined = 'undefined' | ||
const boolean = 'boolean' | ||
const number = 'number' | ||
const string = 'string' | ||
const symbol = 'symbol' | ||
const primitives = [_null, _undefined, boolean, number, string, symbol] | ||
module.exports.Fn = Fn | ||
@@ -22,9 +14,2 @@ module.exports.fn = fn | ||
module.exports.optional = optional | ||
module.exports.any = any | ||
module.exports._null = _null | ||
module.exports._undefined = _undefined | ||
module.exports.boolean = boolean | ||
module.exports.number = number | ||
module.exports.string = string | ||
module.exports.symbol = symbol | ||
module.exports.primitives = primitives | ||
module.exports.any = any |
## 26 April 2019 | ||
### [1.0.3](https://github.com/artdecocode/parser/compare/v1.0.2...v1.0.3) | ||
- [doc] Fix types' links in documentation, using the parser via [_Typal_](https://artdecocode.com/typal/). | ||
- [types] Correct types for via _GCC_ warnings (remove primitive types). | ||
### [1.0.2](https://github.com/artdecocode/parser/compare/v1.0.1...v1.0.2) | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "@typedefs/parser", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "The Parser For JSDoc Types.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -38,20 +38,20 @@ # @typedefs/parser | ||
| Name | Type | Description | | ||
| ----------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| __args*__ | <em>!Array<!_typedefsParser.Type></em> | The arguments of the function. | | ||
| __return*__ | <em>[_typedefsParser.Type](#type-_typedefsparsertype)</em> | 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' }`. | | ||
| this | <em>[!_typedefsParser.Type](#type-_typedefsparsertype)</em> | The type of the `this` argument specified as `function(this: Type)`. | | ||
| new | <em>[!_typedefsParser.Type](#type-_typedefsparsertype)</em> | The type of the `new` argument specified as `function(new: Type)`. | | ||
| Name | Type | Description | | ||
| ----------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| __args*__ | <em>!Array<[!_typedefsParser.Type](#type-_typedefsparsertype)></em> | The arguments of the function. | | ||
| __return*__ | <em>[_typedefsParser.Type](#type-_typedefsparsertype)</em> | 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' }`. | | ||
| this | <em>[!_typedefsParser.Type](#type-_typedefsparsertype)</em> | The type of the `this` argument specified as `function(this: Type)`. | | ||
| new | <em>[!_typedefsParser.Type](#type-_typedefsparsertype)</em> | The type of the `new` argument specified as `function(new: Type)`. | | ||
__<a name="type-_typedefsparsertype">`_typedefsParser.Type`</a>__: The representation of a type. | ||
| Name | Type | Description | | ||
| ----------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| nullable | <em>boolean</em> | Whether the type is nullable. This is defined by writing `?` before the type name to state nullability and `!` otherwise. The parser does not infer nullability from types being primitive and `Function/function`. | | ||
| name | <em>string</em> | The name of the type. | | ||
| union | <em>!Array<!_typedefsParser.Type></em> | If the type is defined as a union, e.g., `(string\|number)`, contains the united types. Must include parenthesis. | | ||
| record | <em>!Object<string, _typedefsParser.Type></em> | If the type is a record, contains its representation. If a property of the record does not have a type, it will be set to null. | | ||
| application | <em>!Array<!_typedefsParser.Type></em> | The application of the type, e.g., the inner type of `Object<Application>`. | | ||
| function | <em>[!_typedefsParser.FunctionType](#type-_typedefsparserfunctiontype)</em> | The function info with args and return if the type is a function. | | ||
| optional | <em>boolean</em> | If the type is returned as an optional argument of a function (`function(string=)`), this will be set to true. | | ||
| Name | Type | Description | | ||
| ----------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| nullable | <em>boolean</em> | Whether the type is nullable. This is defined by writing `?` before the type name to state nullability and `!` otherwise. The parser does not infer nullability from types being primitive and `Function/function`. | | ||
| name | <em>string</em> | The name of the type. | | ||
| union | <em>!Array<[!_typedefsParser.Type](#type-_typedefsparsertype)></em> | If the type is defined as a union, e.g., `(string\|number)`, contains the united types. Must include parenthesis. | | ||
| record | <em>!Object<string, [_typedefsParser.Type](#type-_typedefsparsertype)></em> | If the type is a record, contains its representation. If a property of the record does not have a type, it will be set to null. | | ||
| application | <em>!Array<[!_typedefsParser.Type](#type-_typedefsparsertype)></em> | The application of the type, e.g., the inner type of `Object<Application>`. | | ||
| function | <em>[!_typedefsParser.FunctionType](#type-_typedefsparserfunctiontype)</em> | The function info with args and return if the type is a function. | | ||
| optional | <em>boolean</em> | If the type is returned as an optional argument of a function (`function(string=)`), this will be set to true. | | ||
@@ -75,3 +75,8 @@ ```js | ||
logHeading('Functions') | ||
log(parser(`function(this: Type, string, function()=): function(): null`)) | ||
log(parser(`function( | ||
this: Type, | ||
string, | ||
function(), | ||
function(): *= | ||
): function(): null`)) | ||
``` | ||
@@ -128,4 +133,5 @@ ```js | ||
[ { name: 'string' }, | ||
{ name: 'function', function: { return: null, args: [] } }, | ||
{ name: 'function', | ||
function: { return: null, args: [] }, | ||
function: { return: { name: 'any' }, args: [] }, | ||
optional: true } ], | ||
@@ -132,0 +138,0 @@ this: { name: 'Type' } } } |
@@ -1,8 +0,6 @@ | ||
import { debuglog } from 'util' | ||
import { lex, parser } from './lib' | ||
const LOG = debuglog('@typedefs/parser') | ||
/** | ||
* The Parser For JSDoc Types. | ||
* @param {string} type The type to parse, e.g., `!Promise<!Array<function(string)>>` | ||
*/ | ||
@@ -9,0 +7,0 @@ export default function parse(type) { |
import { Fn, fn, | ||
_null, _undefined, string, boolean, number, symbol, | ||
nullable, nonNullable, | ||
@@ -23,8 +22,2 @@ optional, any, | ||
case '*': return any | ||
case 'string': return string | ||
case 'number': return number | ||
case 'boolean': return boolean | ||
case 'symbol': return symbol | ||
case 'null': return _null | ||
case 'undefined': return _undefined | ||
} | ||
@@ -171,3 +164,2 @@ return a | ||
) { | ||
type.application = true | ||
consume() | ||
@@ -174,0 +166,0 @@ if (applicationWithDot) consume() |
@@ -6,10 +6,2 @@ export const Fn = 'Function' | ||
export const optional = '=' | ||
export const any = 'any' | ||
export const _null = 'null' | ||
export const _undefined = 'undefined' | ||
export const boolean = 'boolean' | ||
export const number = 'number' | ||
export const string = 'string' | ||
export const symbol = 'symbol' | ||
export const primitives = [_null, _undefined, boolean, number, string, symbol] | ||
export const any = 'any' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160
26734
450