
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
npm install esvalid
esvalid.isValid(node)
:: Spidermonkey AST Node → BooleanReturns true if and only if the given AST node represents a valid ECMAScript program.
esvalid.isValidExpression(node)
:: Spidermonkey AST Node → BooleanReturns true if and only if the given AST node represents a valid ECMAScript expression.
esvalid.errors(node)
:: Spidermonkey AST Node → [InvalidAstError]Returns an array of InvalidAstError
objects representing the errors in the
given AST. An effort is made to continue collecting errors in the face of
malformed ASTs. If an empty array is returned, it is implied that the given AST
node is error free.
new esvalid.InvalidAstError(node, message)
:: Node -> String -> InvalidAstErrorConstructs a new InvalidAstError
instance. node
must be non-null.
var esvalid = require("esvalid");
var esprima = require("esprima");
var program = esprima.parse(fs.readFileSync(require.resolve("esprima")));
esvalid.isValid(program); // true
esvalid.isValid({type: "Program", body: []}); // true
esvalid.isValid({type: "Program", body: null}); // false
esvalid.isValidExpression({type: "Program", body: []}); // false
esvalid.isValidExpression({type: "Literal", value: 0}); // true
esvalid.errors({type: "Program", body: []}); // []
var error = esvalid.errors({type: "Program", body: null})[0];
error instanceof esvalid.InvalidAstError; // true
error.node; // {type: "Program", body: null}
error.message; // "Program `body` member must be non-null"
This is a list of all esvalid validity tests other than null
tests and type checks.
name
member must be a valid IdentifierNamename
member must not be a ReservedWordalternate
must not be the consequent
of an IfStatement with a non-null alternate
property
member must have a valid IdentifierName name
membervalue
member must have zero parametersvalue
member must have exactly one parameterexpressions
member length must be >= 2cases
member must contain no more than one SwitchCase with a null test
memberhandler
member or a non-null finalizer
memberdelete
with unqualified identifier not allowed in strict modedeclarations
member must be non-emptyFAQs
confirm that a SpiderMonkey format AST represents an ECMAScript program
The npm package esvalid receives a total of 395 weekly downloads. As such, esvalid popularity was classified as not popular.
We found that esvalid 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.