npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loose-sqlparser-wasm

v0.1.6

Published

A wasm wrapper for the loose-sqlparser crate

Downloads

4

Readme

A simple loose SQL parser for in Web Assembly

Based on a RUST implementation, loose-sqlparser-wasm is a non-validating SQL parser for Javascript. It provides support for parsing and splitting SQL statements.

Usage

import { parseSql, Statement } from "loose-sqlparser-wasm";
const statements = parseSql("SELECT 1; SELECT 2") as Array<Statement>;

Features

  • Support multiple sql statements.

    const statements = parseSql("SELECT 1; SELECT 2") as Array<Statement>;
    statements.len(); // => 2
  • SQL dialect agnostic. Intended to support a wild range of SQL dialects: mysql, postgresql, sqlite, oracle, ...

  • Collect an AST of tokens for each statement:

    const statements = parseSql("SELECT 1; SELECT 2") as Array<Statement>;
    statements[0].tokens; // => ["SELECT", "1", ";"]
    statements[1].tokens; // => ["SELECT", "2"]
  • For token, alongside of the value itself, capture line:column and byte offset of the start and line:column for the end.

    SELECT 1+(4*5)-3
      FROM DUAL
    ;
    start       end         offset  token
    ----------  ----------  ------  ------------------------------------------------
           1:1         1:6       0  SELECT
           1:8         1:8       7  1
           1:9         1:9       8  +
          1:10        1:10       9  (
          1:11        1:11      10    4
          1:12        1:12      11    *
          1:13        1:13      12    5
          1:14        1:14      13  )
          1:15        1:15      14  -
          1:16        1:16      15  3
           2:3         2:6      19  FROM
           2:8        2:11      24  DUAL
           3:1         3:1      29  ;
  • Invalid SQL syntaxes don't stop the tokenization.

    // The missing opening parenthesis won't stop the tokenization.
    const statements = parseSql("SELECT (1+2)*3) FROM employee") as Array<Statement>;
    statements[0].tokens; // => ["SELECT", "(", "1", "+", "2", ")", "*", "3", ")", "FROM", "employee"]