Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@typedefs/parser
Advanced tools
@typedefs/parser
is The Parser For JSDoc Types.
yarn add @typedefs/parser
The package is available by importing its default function:
import parse from '@typedefs/parser'
parse(
type: string,
): Type
Parses the type recursively. Obeys the JSDoc rules, but also supports Google Closure Compiler annotations.
_typedefsParser.FunctionType
: The meta information about the function.
Name | Type | Description |
---|---|---|
args* | !Array<!_typedefsParser.Type> | The arguments of the function. |
return* | _typedefsParser.Type | 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 | !_typedefsParser.Type | The type of the this argument specified as function(this: Type) . |
new | !_typedefsParser.Type | The type of the new argument specified as function(new: Type) . |
_typedefsParser.Type
: The representation of a type.
Name | Type | Description |
---|---|---|
nullable | boolean | 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 | string | The name of the type. |
union | !Array<!_typedefsParser.Type> | If the type is defined as a union, e.g., (string|number) , contains the united types. Must include parenthesis. |
record | !Object<string, _typedefsParser.Type> | 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 | !Array<!_typedefsParser.Type> | The application of the type, e.g., the inner type of Object<Application> . |
function | !_typedefsParser.FunctionType | The function info with args and return if the type is a function. |
optional | boolean | If the type is returned as an optional argument of a function (function(string=) ), this will be set to true. |
import parser from '@typedefs/parser'
logHeading('Applications')
log(parser('!Object<string, Promise<Array<!Type>>>'))
logHeading('Unions (parenthesis are required)')
log(parser('(string | number | !Promise<?(string | symbol)>)'))
logHeading('Records')
log(parser(`{
a: string, b: ?number, c,
d: !Promise<Array<{e: number}>>,
f: { g: boolean }
}`))
logHeading('Functions')
log(parser(`function(this: Type, string, function()=): function(): null`))
Applications:
------------
{ nullable: false,
name: 'Object',
application:
[ { name: 'string' },
{ name: 'Promise',
application:
[ { name: 'Array',
application: [ { nullable: false, name: 'Type' } ] } ] } ] }
Unions (parenthesis are required):
---------------------------------
{ union:
[ { name: 'string' },
{ name: 'number' },
{ nullable: false,
name: 'Promise',
application:
[ { nullable: true,
union: [ { name: 'string' }, { name: 'symbol' } ] } ] } ] }
Records:
-------
{ record:
{ a: { name: 'string' },
b: { nullable: true, name: 'number' },
c: null,
d:
{ nullable: false,
name: 'Promise',
application:
[ { name: 'Array',
application: [ { record: { e: { name: 'number' } } } ] } ] },
f: { record: { g: { name: 'boolean' } } } } }
Functions:
---------
{ name: 'function',
function:
{ return:
{ name: 'function',
function: { return: { name: 'null' }, args: [] } },
args:
[ { name: 'string' },
{ name: 'function',
function: { return: null, args: [] },
optional: true } ],
this: { name: 'Type' } } }
© Art Deco 2019 | Tech Nation Visa Sucks |
---|
FAQs
The Parser For JSDoc Types.
The npm package @typedefs/parser receives a total of 34 weekly downloads. As such, @typedefs/parser popularity was classified as not popular.
We found that @typedefs/parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.