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 🙏

© 2024 – Pkg Stats / Ryan Hefner

designscript.js

v0.0.3

Published

DesignScript in the browser

Downloads

10

Readme

Build Status

Installing from npm

# npm install designscript.js

DesignScript.js is generated with browserify, so you can use it with a variety of module systems (see below).

About

A DesignScript parser and interpreter that runs in the browser. You can use it to parse, generate, and run DesignScript code.

Most of the project is written in TypeScript.

This project currently includes:

  • AST
  • Parser
  • Interpreter (with debugging support)

Language features:

  • Language blocks (Imperative and Associative)
  • Replication
  • Replication guides
  • Type declaration for variables, function arguments
  • Range expressions

See src/AST.ts for a complete list.

Not yet implemented

  • For, while loops in imperative blocks
  • Classes

Usage

Code generation

var AST = require('./build/designscript').AST;

var sl = 
	new AST.StatementListNode(
		new AST.AssignmentNode(
			new AST.IdentifierNode("a", new AST.Type("number")),
			new AST.NumberNode("3.14159")));
		
console.log( sl.toString() ); // prints "a : number = 3.14159;"

Parser

var designscript = require('./build/designscript');

// parse some DesignScript
var ast = designscript.Parser.parse('w = [Imperative]{ return = 4; }'); 

Interpreter

Continuing from the Parser example:

var i = new designscript.Interpreter();
i.run( ast ); 

console.log( i.env.lookup("w") ); // prints "4"

Debugging

Pass a function to an Interpreter that will be invoked upon consuming every part of the AST. When invoked, the Interpreter passes along a callback that must be invoked in order to continue execution.

var interpreter = new designscript.Interpreter(
	function(node, env, stack, callback){
		// do stuff with node, env, stack
		callback();
	});
interpreter.run( ast ); 
 

See example/debugger.html for a more complete example.

Install

Install node.js

# npm install -g jison
# npm install -g browserify
# npm install -g typescript

Build

# make build

Build for the web

# make release

Produces designscript.js in the build directory

Test

# make test