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

janus-script

v1.9.4

Published

scripting interpreter for project Janus

Downloads

655

Readme

janus-script

Scripting interpreter to support adaptive pages

Documentation

You can assign values using let statements:

let a = 1;

Identifiers can have spaces or any characters in them, however when using spaces and other special characters you must wrap them in curly brackets:

let a_b = 3;
let a.b = 4;
let {a=b} = 5;
let {shoe size} = 11.5;
let {something.value 1} = "foo";

Identifiers can be "bound" to the value of other identifiers using &= the identifier that you want to bind to does not need to exist before it can be bound:

let c &= a;
let a = 3;
let b &= a;

//...
Janus> b
3
Janus> c
3

Identifiers can be "anchored" to the value of other identifiers using #= the identifier that you want to anchor to does not need to exist before it can be anchored. Anchors differ from bindings in that they do not trigger change events, nor do they reflect in the environment dump (toObj).

let c #= a;
let a = 3;
let b #= a;

//...
Janus> b
3
Janus> c
3

To remove a binding, anchor, or any other value you can use the delete command.

let a = 3;
let b &= a;
let b = 7;
delete b;
let b = 7; // OK

Built In Functions and Values

You can determine the type of any identifier using typeof:

let c = 8; typeof(c); // NUMBER

It may be necessary to convert types, this can be done with string and number :

let a = 3;
let b = "I have " + string(a) + " shoes.";
let input = "33";
let result = 19 + number(input);

Arrays can be created from string using array.

let arr = [1, 2, 3];
let j = json(arr); // string
let arr1 = array(j); // back to janus array

You can also get the length of an array or string using len.

Hash objects can be created from string using hash.

let o = {"a": 1, "b": 2};
let s = json(o); // json string
let i = hash(s); // back to a janus hash

For random numbers there is a random function it returns a float between 0 and 1.

You can create a deterministic random number generator using rng. The seed provided determines the outcome.

let seed = 1234;
let rand = rng(seed);
let otherRand = rng(seed);
otherRand() == rand(); // true

Math Library

Constants

  • Math.E - 2.718281828459045
  • Math.PI - 3.141592653589793
  • Math.LN10 - 2.302585092994046
  • Math.LN2 - 0.6931471805599453
  • Math.LOG2E - 1.4426950408889634
  • Math.SQRT2 - 1.4142135623730951
  • Math.SQRT1_2 - 0.7071067811865476

Functions

Math.log(value) - Calculates the logarithm of a value.

Math.max(value1, value2, ...valueN) - Evaluates value1 and value2 (or more values) and returns the largest value.

Math.min(value1, value2, ...valueN) - Evaluates value1 and value2 (or more values) and returns the smallest value.

Math.round(value) - rounds to the nearest integer

TODO