Code Monkey home page Code Monkey logo

fast-sexpr's Introduction

fast-sexpr

Build Status Coverage Status

A lightweight s-expression parser for JavaScript.

fast-sexpr's People

Contributors

benthepoet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fast-sexpr's Issues

Infinite loop on really huge outputs due to integer size limitation

This line

return data.sexpr[data.index++];

will push the cursor forward in the sexpr's text. However, due to integer size limitations, the number will no longer be able to increase when the integer cap is hit (in my computer, that number is 1048576), which means the condition if (data.index === data.sexpr.length) return null; is never hit, and therefore the parser gets stuck in an infinite loop for really large inputs.

Solution: I was able to get through this with just a small change

  var data = {
-   index: 0,
+   index: BigInt(0),
    sexpr: sexpr
  }

As far as compatibility goes, according to what I read in https://www.npmjs.com/package/big-integer, BigInt is natively supported in recent versions of Node. I am able to confirm this because I'm using Node 13.5 and didn't have to install anything extra.

I wanted to ask if you think this change is warranted and/or needed, or if I should look into other packages from other languages for my use-case (speed matters).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.