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

bds.js

v1.1.1

Published

A simple interpreter written to simulate and run BDScript Language in JavaScript

Readme

bds.js

Run and simulate string-based BDScript language in JavaScript

Prerequisites

This project requires a JavaScript runtime which supports ES2020 and ESModules.

Changelog v1.1.1

Added / New

  • Rewritten code for easy to use
  • Reworked Context
  • Reworked Lexer
  • Reworked Parser
  • Added Evaluator
  • Added Runtime
  • Fixed operator type breaks punctuations
  • Readded some utility calls
  • Added $async, $wait, $safejs, $if

Breaking

  • Removed FNHandler
  • Removed Script
  • Removed Nodes

Table of Contents

Installation

Install bds.js with npm:

$ npm install bds.js

or getting releases from github

API & Usage

Example

const lib = require('bds.js');
const runtime = new lib.Runtime();

const input = '$async[$swait $print[Hello world!]] This bottom text is async output!'
const result = runtime.runInput('helloWorld.bds', input);
result.then(output => console.log(output));

Runtime

v1.1 is using Runtime and Evaluator, different from v1.0 This approach is used for the reason; Runtime error and error tracing within code for easier debugging

const runtime = new lib.Runtime();
const input = "$print[Hello World!]";
// Running an input
runtime.runInput('myInput.js', input);

Evaluator

Currently v1.1 use Interpreter system which can impact the performance for large-scale productions. Later versions to be improved, can also be a change of system.

// Creating a AST
const input = "> This is the code$print[> Hello World!]"
const lexer = new lib.Lexer(input);
const parser = new lib.Parser();
const Ast = parser.parseToAst(lexer.main() /* Tokenizing input */) // Parsing tokens to AST

// Evaluating the AST as simple as possible
const evaluator = lib.Evaluator.singleton // One instance is for one process
const result = evaluator.evaluate(Ast) // Evaluating AST

// Printing the output of input
result.then(output => console.log(output))

Context

Context instance are usually used to handle functions in code

const env = new lib.Environment();
env.set('luckyfn', async (context) => {
  context.argsCheck(1); // Check if has required arguments (1), throws error if below from required
  const arguments = context.getArgs() // Getting arguments
  const minimum_chance = await context.evaluateArgs(arguments)[0] // Get the first argument of evaluated arguments
  // Calling other identifiers (Advanced use)
  const chance = await context.callIdentifier({type: "call", value: "$random"}) * 100;
  if (chance > minimum_chance) {
    return 'You are lucky!'
  } else {
    return 'A sad day for no luck...'
  }
});

Variables

In bds.js, variables are accessed from the Environment class instance

const os = require("node:os");
const env = new lib.Environment();
// Creating static variables
env.set('myname', 'Nivry'); // result in string
env.set('myage', 14); // result in number
env.set('mycats', ['Kitty', 'Rivi']) // result in array
env.set('totalmem', os.totalmem); // Run function
env.set('lowercase', async (ctx) => {
  ctx.argsCheck(1); // Built-in args check, automatically throws error if arguments size is below the required
  const arguments = ctx.getArgs();
  // Evaluate / Run the arguments beforehand
  const text = await ctx.evaluateArgs(arguments)[0] // The first compiled arg
  return text.toLowerCase();
});

Global Variables

Global variables are sourced from Runtime.global, allowing many codes to access the global environment while also keeping its own.

const runtime = new lib.Runtime();
runtime.global.set('$helloWorld', 'Hello World!');

Goals

  • [x] Usable
  • [ ] Basic utility Functions (4%)
  • [x] Conditions / Logic support
  • [x] Arithmetic support
  • [ ] Compile-able code to JavaScript
  • [x] Friendly-code for beginners
  • [x] Native code (JavaScript) support
  • [ ] Import & Export
  • [ ] Runtime Error
  • [x] Async promise support

MIT License

License can be found here