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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yaml/yamlstar

v0.1.0

Published

Pure YAML 1.2 loader - Node.js bindings

Readme

YAMLStar Node.js Bindings

Node.js bindings for YAMLStar - a pure YAML 1.2 loader implemented in Clojure.

Features

  • YAML 1.2 Spec Compliance: 100% compliant with YAML 1.2 core schema
  • Pure Implementation: No dependencies on js-yaml or other external parsers
  • Fast Native Performance: Uses GraalVM native-image shared library
  • Simple API: Load YAML documents with a single method call
  • Multi-Document Support: Load multiple YAML documents from a single string

Installation

Prerequisites

First, build and install the shared library:

cd ../libyamlstar
make native
sudo make install PREFIX=/usr/local

Or install to user-local directory:

cd ../libyamlstar
make native
make install PREFIX=~/.local

Install Node.js Package

npm install @yaml/yamlstar

For development:

npm install

Quick Start

const YAMLStar = require('@yaml/yamlstar');

// Create a YAMLStar instance
const ys = new YAMLStar();

// Load a simple YAML string
const data = ys.load('key: value');
console.log(data);  // { key: 'value' }

// Clean up when done
ys.close();

Usage Examples

Basic Types

const YAMLStar = require('@yaml/yamlstar');
const ys = new YAMLStar();

// Strings
ys.load('hello');  // 'hello'

// Integers
ys.load('42');  // 42

// Floats
ys.load('3.14');  // 3.14

// Booleans
ys.load('true');   // true
ys.load('false');  // false

// Null
ys.load('null');  // null

Collections

// Mappings (objects)
const data = ys.load(`
name: Alice
age: 30
city: Seattle
`);
// { name: 'Alice', age: 30, city: 'Seattle' }

// Sequences (arrays)
const data = ys.load(`
- apple
- banana
- orange
`);
// ['apple', 'banana', 'orange']

// Flow style
const data = ys.load('[a, b, c]');
// ['a', 'b', 'c']

Nested Structures

const data = ys.load(`
person:
  name: Alice
  age: 30
  hobbies:
    - reading
    - coding
    - hiking
`);
// {
//   person: {
//     name: 'Alice',
//     age: 30,
//     hobbies: ['reading', 'coding', 'hiking']
//   }
// }

Multi-Document YAML

// Load all documents from a multi-document YAML string
const docs = ys.loadAll(`---
name: Document 1
---
name: Document 2
---
name: Document 3
`);
// [
//   { name: 'Document 1' },
//   { name: 'Document 2' },
//   { name: 'Document 3' }
// ]

Type Coercion

YAMLStar follows YAML 1.2 core schema type inference:

const data = ys.load(`
string: hello
integer: 42
float: 3.14
bool_true: true
bool_false: false
null_value: null
`);
// {
//   string: 'hello',
//   integer: 42,
//   float: 3.14,
//   bool_true: true,
//   bool_false: false,
//   null_value: null
// }

Error Handling

try {
  const data = ys.load('invalid: yaml: syntax');
} catch (error) {
  console.error('Error loading YAML:', error.message);
}

Version Information

// Get YAMLStar version
const version = ys.version();
console.log(`YAMLStar version: ${version}`);

Resource Cleanup

const ys = new YAMLStar();

// ... use ys ...

// Clean up GraalVM isolate when done
ys.close();

API Reference

YAMLStar Class

new YAMLStar()

Create a new YAMLStar instance. Each instance maintains its own GraalVM isolate.

const ys = new YAMLStar();

load(yamlInput)

Load a single YAML document.

Parameters:

  • yamlInput (string): String containing YAML content

Returns:

  • JavaScript value representing the YAML document (object, array, string, number, boolean, or null)

Throws:

  • Error if the YAML is malformed

Example:

const data = ys.load('key: value');

loadAll(yamlInput)

Load all YAML documents from a multi-document string.

Parameters:

  • yamlInput (string): String containing one or more YAML documents

Returns:

  • Array of JavaScript values, one per YAML document

Throws:

  • Error if the YAML is malformed

Example:

const docs = ys.loadAll('---\ndoc1\n---\ndoc2');

version()

Get the YAMLStar version string.

Returns:

  • string: Version string

Example:

const version = ys.version();

close()

Tear down the GraalVM isolate and free resources. Should be called when done using the instance.

Example:

ys.close();

Development

Running Tests

# Run all tests
make test

# Or directly with node
node test/test.js

Building libyamlstar

If you need to rebuild the shared library:

cd ../libyamlstar
make clean
make native

Requirements

  • Node.js: 18.0.0 or higher
  • libyamlstar: Shared library (installed separately)
  • System: Linux or macOS
  • Dependencies: @makeomatic/ffi-napi, ref-napi

Library Search Path

The module searches for libyamlstar.so (or .dylib on macOS) in:

  1. Development path (relative to module: ../../libyamlstar/lib/)
  2. Directories in LD_LIBRARY_PATH environment variable
  3. /usr/local/lib (default install location)
  4. ~/.local/lib (user-local install location)

Comparison to js-yaml

| Feature | YAMLStar | js-yaml | |---------|----------|---------| | YAML Version | 1.2 | 1.2 | | Implementation | Pure Clojure | JavaScript | | Type Inference | YAML 1.2 core schema | YAML 1.2 + custom | | Native Performance | Yes (GraalVM) | No | | Dependencies | libyamlstar.so | None |

License

MIT License - See License file

Credits

Created by Ingy döt Net, inventor of YAML.

YAMLStar is built on the YAML Reference Parser (pure Clojure implementation).

Links

  • GitHub: https://github.com/yaml/yamlstar
  • YAML Specification: https://yaml.org/spec/1.2/spec.html