Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@darknoon/meriyah
Advanced tools
A 100% compliant, self-hosted javascript parser with high focus on both performance and stability
100% compliant, self-hosted javascript parser with high focus on both performance and stability. Stable and already used in production.
Note: These features need to be enabled with the next
option.
npm install meriyah --save-dev
Meriyah generates AST
according to ESTree AST format, and can be used to perform syntactic analysis (parsing) of a JavaScript program, and with ES2015
and later a JavaScript program can be either a script or a module.
The parse
method exposed by meriyah takes an optional options
object which allows you to specify whether to parse in script
mode (the default) or in module
mode.
This is the available options:
{
// The flag to allow module code
module: false;
// The flag to enable stage 3 support (ESNext)
next: false;
// The flag to enable start, end offsets and range: [start, end] to each node
ranges: false;
// Enable web compatibility
webcompat: false;
// The flag to enable line/column location information to each node
loc: false;
// The flag to attach raw property to each literal and identifier node
raw: false;
// Enabled directives
directives: false;
// The flag to allow return in the global scope
globalReturn: false;
// The flag to enable implied strict mode
impliedStrict: false;
// Allows comment extraction. Accepts either a function or array
onComment: []
// Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the charater offset where the semicolon was inserted
onInsertedSemicolon: (pos) => {}
// Allows token extraction. Accepts either a function or array
onToken: []
// Enable non-standard parenthesized expression node
preserveParens: false;
// Enable lexical binding and scope tracking
lexical: false;
// Adds a source attribute in every node’s loc object when the locations option is `true`
source: false;
// Distinguish Identifier from IdentifierPattern
identifierPattern: false;
// Enable React JSX parsing
jsx: false
// Allow edge cases that deviate from the spec
specDeviation: false
// Allow parsing a prefix of a valid program. Tries to always return a valid program, despite potentially invalid syntax due to missing code
prefix: false
}
If an array is supplied, comments/tokens will be pushed to the array, the item in the array contains start/end/range
information when ranges flag is true, it will also contain loc
information when loc flag is true.
If a function callback is supplied, the signature must be
declare function onComment(type: string, value: string, start: number, end: number, loc: SourceLocation): void;
declare function onToken(token: string, start: number, end: number, loc: SourceLocation): void;
Note the start/end/loc
information are provided to the function callback regardless of the settings on ranges and loc flags. onComment callback has one extra argument value: string
for the body string of the comment.
If a function callback is supplied, the signature must be
declare function onInsertedSemicolon(position: number): void;
import { parseScript } from './meriyah';
parseScript('({x: [y] = 0} = 1)');
This will return when serialized in json:
{
type: "Program",
sourceType: "script",
body: [
{
type: "ExpressionStatement",
expression: {
type: "AssignmentExpression",
left: {
type: "ObjectPattern",
properties: [
{
type: "Property",
key: {
type: "Identifier",
name: "x"
},
value: {
type: "AssignmentPattern",
left: {
type: "ArrayPattern",
elements: [
{
"type": "Identifier",
"name": "y"
}
]
},
right: {
type: "Literal",
value: 0
}
},
kind: "init",
computed: false,
method: false,
shorthand: false
}
]
},
operator: "=",
right: {
type: "Literal",
value: 1
}
}
}
]
}
FAQs
A 100% compliant, self-hosted javascript parser with high focus on both performance and stability
We found that @darknoon/meriyah demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.