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

tueson

v0.0.1

Published

Simple indentation-based object notation matching the JSON object model.

Downloads

2

Readme

tueson

A simple indentation-based data notation that uses the JSON data model.

Status

Experimental.

Goals & corresponding design decisions

  • Easy for a human to read, write, and manipulate.
    • Indentation makes document hierarchy clear. Each field of an object or item in a list goes on a separate line.
    • Offers a multiline string notation that does not require/use escape characters.
    • All lines of a multiline string are indented past the parent element so that the document's hierarchy is visually clear. The parser will automatically remove the appropriate amount of indentation.
    • Typical field names do not require quotation. Field names with special characters always use the entire line, and the value is indented on the following line.
    • Single-line strings always run to the end of the line - no closing quotes.
    • Numbers and strings are always explicitly distinguished (unlike in YAML) to reduce errors.
  • Easy to parse and generate.
    • Two-space indentation is enforced.
    • No intra-document referencing functionality.
    • Not many variant ways of expressing the same data.
  • Can convert losslessly to and from JSON.
    • No additional data types such as you'd find in YAML.
    • No comment syntax.

Example

The following tueson:

record
  favoriteColor 'light green
  aFewFavoriteBooks list
    record
      title 'Educated
      author 'Tara Westover
    record
      title 'Jonathan Strange & Mr. Norrell
      author 'Susanna Clarke
    record
      title 'The Dispossessed
      author 'Ursula K. Le Guin
  bio text
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in ultrices quam. Pellentesque congue purus nec purus vehicula pellentesque.

    Etiam a risus ultricies, tincidunt mauris ut, pharetra erat. Morbi imperdiet ipsum vel mi cursus suscipit. Proin aliquam at tortor eu facilisis.

    Phasellus dignissim lorem volutpat bibendum tempor.

Is equivalent to the following json:

{
  "favoriteColor": "light green",
  "aFewFavoriteBooks": [
    {
      "title": "Educated",
      "author": "Tara Westover"
    },
    {
      "title": "Jonathan Strange & Mr. Norrell",
      "author": "Susanna Clarke"
    },
    {
      "title": "The Dispossessed",
      "author": "Ursula K. Le Guin"
    }
  ],
  "bio": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in ultrices quam. Pellentesque congue purus nec purus vehicula pellentesque.\n\nEtiam a risus ultricies, tincidunt mauris ut, pharetra erat. Morbi imperdiet ipsum vel mi cursus suscipit. Proin aliquam at tortor eu facilisis.\n\nPhasellus dignissim lorem volutpat bibendum tempor."
}

See the test-cases folder for more examples.

Non-obvious cases

Field names with special characters

To use the default syntax, field names must match the regex /^[a-zA-Z][a-zA-Z0-9_]*$/ (i.e., start with a letter, followed by zero or more alphanumeric characters or underscores).

Fields with other names can be indicated like this:

record
  @this field name contains spaces and ends with a newline\n
    42

Equivalent JSON:

{
  "this field name contains spaces and ends with a newline\n": 42
}

Multiline text ending with blank lines

When parsing text and esctext values, any blank lines at the end are ignored, and no trailing newline is included in the string.

If you want one or more trailing newlines, use esctext and escape them:

esctext
  First line

  Third line.\n\n\n

Equivalent JSON:

"First line\n\nThird line.\n\n\n"

Specification

TODO

Usage

CLI for converting between json and tueson

npm i -g tueson
tueson test-cases/a.tueson # prints the corresponding json
tueson test-cases/a.json # prints the corresponding tueson

Library usage

npm i tueson
import * as tueson from 'tueson';
const original = { foo: 'bar' };
const serialized = tueson.stringify(sample);
const deserialized = tueson.parse(serialized);
// original and deserialized should be equivalent

Why is it called tueson?

I worked on it on a Tuesday once.

License

This is available as open source under the terms of the MIT License.