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

ranger-lang

v0.3.0

Published

A Test data generator

Readme

Ranger: A test data generator

Ranger is a test data generator that lets you create customized, correlated test data using the Ranger language.

This example Ranger file

produces such an output

{"age":37,"sex":"female","name":"Lucy","id":"Lucy123","pin":"1683","eyes":"brown"}
{"age":57,"sex":"male","name":"Robert","id":"Robert123","pin":"4242","eyes":"brown"}
{"age":42,"sex":"female","name":"Lisa","id":"Lisa123","pin":"2016","eyes":"brown"}
{"age":60,"sex":"female","name":"Emily","id":"Emily123","pin":"8119","eyes":"brown"}
{"age":50,"sex":"male","name":"Max","id":"Max123","pin":"4061","eyes":"brown"}
{"age":54,"sex":"male","name":"Robert","id":"Robert123","pin":"5378","eyes":"brown"}
{"age":52,"sex":"female","name":"Emily","id":"Emily123","pin":"4765","eyes":"brown"}
{"age":38,"sex":"male","name":"Robert","id":"Robert123","pin":"8901","eyes":"brown"}
{"age":39,"sex":"female","name":"Emily","id":"Emily123","pin":"6529","eyes":"blue"}
{"age":28,"sex":"male","name":"Max","id":"Max123","pin":"6623","eyes":"brown"}

Find more examples here.

How does it work?

You design test entities in a .ranger file.

Then, there are two ways to generate data:

  • Use the ranger command line tool to create CSV or JSONL files.
  • Use the Node.js library to generate JavaScript objects and use them in your code.

Get editing assistance via the Visual Studio Code Extension.

Command Line Interface

To setup the ranger command line tool, you have two options.

Option 1: Download binary

Download one of the prebuilt binaries (Windows and Linux x86 only).

Option 2: Install via npm

Install Node.js.

Open a terminal and execute

npm install -g ranger-lang

Test it

Create test file Customer.ranger.

Open a terminal and execute

ranger Customer.ranger -c 100000 -f jsonl

It will generate 100'000 rows and save the output to file generated/Customer.jsonl.

Node.js Library

Setup

Open a terminal inside the Node.js project folder and execute

npm install ranger-lang

In order to follow the examples below, create the test file Customer.ranger.

ObjectGenerator API

Create an ObjectGenerator, call next() to retrieve the next generated object.

import { createObjectGenerator } from 'ranger-lang';

const generator = await createObjectGenerator({ filePath: './Customer.ranger' });

for (let i = 1; i <= 1000; i++) {
    console.log(generator.next());
}

Node.js Streams API

Create a Readable Node.js Stream and pipe it to a Writable Stream.

import { createObjectStream } from 'ranger-lang';
import stream from 'stream';

const source = await createObjectStream({ filePath: './Customer.ranger' }, 1000);   // yields 1000 elements

const sink = new stream.Writable({
    objectMode: true,
    write(chunk, _encoding, callback) {
        console.log(chunk);
        callback();
    },
});

stream.pipeline(source, sink, (error) => console.log(error || 'Success!'));

Test file

Create a new file Customer.ranger and paste the following content into it:

Entity Customer {
    age: random(20..60)
    sex: random("male", "female")
    name: map(sex => [
        random("James", "Robert", "Max"),
        random("Emily", "Lucy", "Lisa"),
    ])
    id: f"{name}123"
    pin: /\d{4}/
    eyes: weighted("brown":80, "blue":20)
}