New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jisu

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jisu

Work in progress JavaScript parser

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JISU

A work in progress JavaScript tokeniser and parser. Currently only supports a subset of the JavaScript language and is not ECMAScript compliant.

Install via npm install jisu

An online demo is available at https://ben-sb.github.io/jisu

About

JISU is a recursive descent parser (roughly). I say roughly as it uses the precedence climbing method to parse binary and logical expressions.

Currently I've been working on this in my free time, which I don't have a lot of right now, but I do plan to continue supporting more of the JS language, and may eventually start using this parser in production at my company (Ocule) if it reaches that level. I may also write some AST manipulation tools for the obfuscation/deobfuscation enjoyers out there.

Specs

The repo has two exports:

  • parse - Parses a full program
  • parseExpression - Parses a single expression

Both take the input as a string and optionally a set of parser options.

interface ParserOptions {
    emitLogs?: boolean;
    omitLocations?: boolean;
}

I'm a big fan of Babel and as a result the format of the AST JISU produces is extremely similar to Babel's. As a result @babel/generator can be used on the AST (as seen in src/demo.ts). I also took inspiration from the @babel/types package and implemented a similar system in src/parser/ast.

Tests

Unit tests can be run via npm test
Currently there are very few tests but I plan to add more.

To Do

  • Rewrite object member parsing
  • Allow semi-keywords (e.g. await, async, of) to be treated as identifiers
  • Support numbers expressed in hexadecimal, octal and scientific notation
  • Support regular expressions
  • Probably a lot more

To Fix

  • Object patterns are treated as normal object expressions even when not used as a pattern
  • Spread elements are allowed in sequence expressions
  • Spread elements are allowed on their own in parenthesised expressions

FAQs

Package last updated on 31 Jul 2022

Did you know?

Socket

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.

Install

Related posts

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