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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@yaml/yamlscript

v0.2.7

Published

Program in YAML — Code is Data

Downloads

86

Readme

YAMLScript

Add Logic to Your YAML Files

Quick Start

This library lets you load YAML files that may or may not contain YAMLScript functional programming logic. You can use it as a drop-in replacement for your current YAML loader.

Here's an example config.yaml that makes use of YAMLScript functions.

# config.yaml with YAMLScript:
!ys-0:

# Define variables
db-host =: ENV.DB_HOST || 'localhost'
db-port =: ENV.DB_PORT || 5432
deploy =: ENV.DEPLOYMENT || 'dev'
:when deploy !~ /^(dev|stage|prod)/:
  die: |
    Invalid deployment value '$deploy'.
    Must be one of: dev | stage | prod

# Normal YAML data
description: Dynamic application configuration

# Dynamic data values
database:
  host:: db-host
  port:: db-port:num
  name:: "app_$deploy"

# Import external data
features:: load('common.yaml').features

# Use logic and conditions
cache:
  # Variable scoped to this mapping
  enabled =: deploy == 'production'

  directory: .cache
  enabled:: enabled
  limit: 100
  # Conditional key/value pairs
  :when enabled::
    limit:: 1000
    ttl:: 60 * 60  # 3600

What is YAMLScript?

YAMLScript is a functional programming language that can be embedded in YAML. Its syntax is 100% YAML so files that embed it are still valid YAML files.

The YAMLScript project provides YAML loader libraries for many programming languages. They can be used to load any YAML config files properly, whether or not they contain functional programming logic.

It's perfect for:

  • Configuration files that need logic, variables, and dynamic values
  • Data transformation with built-in functions for JSON, YAML, and text processing
  • Templating with powerful string interpolation and data manipulation
  • Scripting as a complete functional programming language

Key Features

  • Drop-in YAML replacement – Works with your existing YAML files
  • Variables & functions – Define and reuse values throughout your files
  • External data loading – Import JSON, YAML, or data from URLs
  • Conditional logic – Use if/then/else and pattern matching
  • Data transformation – Built-ins for transforming & manipulating data
  • String interpolation – Embed expressions/variables directly in strings
  • No JVM required – Runs as a native library despite compiling to Clojure

How It Works

YAMLScript extends YAML with a simple, elegant syntax:

# file.yaml
!ys-0:               # Enable YAMLScript

name =: 'World'       # Variable assignment
nums =:: [1, 2, 3]    # Any YAML value

# Literal YAML with ':'
a key: a value

# Evaluated expressions with '::'
message:: "Hello, $name!"
sum:: nums.reduce(+)
timestamp:: now():str

You can load this file from a program as described below, or you can use the ys YAMLScript binary to load the file from the command line:

$ ys -Y file.yaml
a key: a value
message: Hello, World!
sum: 6
timestamp: '2025-09-14T22:35:42.832470203Z'

Under the hood, YAMLScript compiles YAML to Clojure and evaluates it, giving you access to a rich functional programming environment.

NodeJS Usage

Use @yaml/yamlscript as a drop-in replacement for your current YAML loader:

// program.js
const YS = require('@yaml/yamlscript');
const fs = require('fs');

const ys = new YS();

// Load from file
const input = fs.readFileSync('config.yaml', 'utf8');
const config = ys.load(input);

// Convert to JSON
console.log(JSON.stringify(config, null, 2));

Installation

Install YAMLScript for Node.js and the libys.so shared library:

npm install @yaml/yamlscript
curl -sSL https://yamlscript.org/install | bash

See https://yamlscript.org/doc/install/ for more info.

Requirements

  • Node.js v18.0.0 or higher

See Also

Authors

License & Copyright

Copyright 2022-2025 Ingy döt Net [email protected]

This project is licensed under the terms of the MIT license. See LICENSE for more details.