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

toml-j0.4

v1.1.1

Published

A parser only compliant with TOML v0.4.0

Downloads

81,713

Readme

TOML-j0.4

Build Status NPM version

As its name TOML-j0.4 says, this is a TOML v0.4.0 compliant parser built with PEG.js. You can customize it easily by modifying the grammar file toml.pegjs.

Live Demo

http://jakwings.github.io/toml-j0.4/

Usage

You can install it via npm install toml-j0.4, or just include the script dist/toml-browser.js in your web pages.

var toml = toml || require('toml-j0.4');

try {
    var data = toml.parse(src);
} catch (err) {
    if (err instanceof toml.SyntaxError) {
        // do something
    }
}
  • toml.parse only accept one argument — data text in TOML
  • The instance of toml.SyntaxError has these properties:
    • line: the line number
    • column: the column number
    • offset: the zero-based offset from the start of the text
    • message: error message

There is no other API for now. Simple?

Known Problems

  • JavaScript does not have real integers.

    All numbers are floats in JavaScript. Any integer bigger than Number.MAX_SAFE_INTEGER (9007199254740991 < 2^63 - 1) or smaller than Number.MIN_SAFE_INTEGER (-9007199254740991 > -(2^63 - 1)) is not safe when being converted or used as pure integer! Enhancement is welcome!

    I suggest storing big integers in strings.

  • RFC 3339 is not the sole criterion of truth.

    You can't imagine how terrible all minitue details of the standard are! So don't expect some date-times will work anytime and anywhere, for instance, "2015-02-29T00:00:00Z", "2015-12-25T24:00:00Z", "2015-11-10T00:60:00Z", "2015-11-10T00:00:60Z", "2015-12-25T24:00:00+24:00", "0000-01-01T00:00:00Z". Enhancement is welcome!

Contribute

If you found bugs, welcome to send me a pull request with (only) updated test scripts/fixtures!

In order to test this package thoroughly, you have to do these first:

  1. Clone this project with git.
  2. Excute this command in the project directory: npm install

The scripts lib/parser.js and dist/toml-browser.js are generated via this command:

npm run build

Then you can test them via this command:

npm test

You can also do some benchmarks with other TOML parsers:

npm run benchmark

Others

This package is also used by other projects: