
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
A simple interpreter written to simulate and run BDScript Language in JavaScript
Run and simulate string-based BDScript language in JavaScript
This project requires a JavaScript runtime which supports ES2020 and ESModules.
ContextLexerParserEvaluatorRuntimeoperator type breaks punctuations$async, $wait, $safejs, $ifFNHandlerScriptNodesInstall bds.js with npm:
$ npm install bds.js
or getting releases from github
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));
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);
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 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...'
}
});
In bds.js, variables are accessed from the
Environmentclass 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 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!');
License can be found here
FAQs
A simple interpreter written to simulate and run BDScript Language in JavaScript
The npm package bds.js receives a total of 5 weekly downloads. As such, bds.js popularity was classified as not popular.
We found that bds.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.