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

nestedtext

v1.1.1

Published

Human friendly representation of data, similar to YAML or JSON

Downloads

9

Readme

NestedText

Please see NestedText for more information about this format.

In brief, it allows software to have data stored as text, similar to YAML and JSON, but without the ambiguity and quoting that's necessary with either one of those.

Here's a short example.

Katheryn McDaniel:
    position: president
    address:
        > 138 Almond Street
        > Topeka, Kansas 20697
    phone:
        cell: 1-210-555-5297
        home: 1-210-555-8470
            # Katheryn prefers that we always call her on her cell phone.
    email: [email protected]
    additional roles:
        - board member

This is a native JavaScript implementation of NestedText. There is also @rmw/nestedtext, which is much heavier (about 2 megs of WASM).

API

Start by loading the library. Choose your favorite method.

// CommonJS
const NestedText = require('nestedtext').NestedText;
// Modules
import NestedText from 'nestedtext';

// Alternately, load just the parts you need. This is the best for tree-shaking.
import { dump, load } from 'nestedtext';
<!-- Browser, HTML, loaded as window.NestedText -->
<script src="https://unpkg.com/nestedtext"></script>
<!-- Browser, loaded as a module -->
<script>
import NestedText from 'https://unpkg.com/inject-hooks?module';

// Or just load the parts you need
import { dump, load } from 'https://unpkg.com/inject-hooks?module';
</script>

NestedText.load(input: string)

Convert NestedText to native data structures.

NestedText.loadMin(input: string)

Convert Minimal NestedText to native data structures. This uses significantly less verbose error messages to help with minifying the bundle size when using loadMin.

NestedText.dump(input: string, options: DumpOptions)

Convert native data to NestedText.

The options can have the following properties:

  • indent: What to use for indent. This must contain only spaces and must contain at least one space, otherwise it generates invalid NestedText. Defaults to four spaces to match the official tests.
  • newline: The newline character to use. Defaults to \n.