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

@chia/chialisp

v0.1.43

Published

tools for working with chialisp language; compiler, repl, python and wasm bindings

Downloads

1,797

Readme

Build

Clone GitHub repository

git clone https://github.com/Chia-Network/clvm_tools_rs
cd clvm_tools_rs/wasm

Use wasm-pack to build the wasm pkg file used with npm. Install it with:

cargo install wasm-pack

Then build with

# Make sure you're at <clvm_tools_rs root>/wasm
wasm-pack build --release --target=nodejs

Test

Prerequisite:

  • NodeJS >= 16
  • Wasm files built by wasm-pack command exist at <clvm_tools_rs root>/wasm/pkg/
# Make sure you're at <clvm_tools_rs root>/wasm
node ./tests/index.js

Program

Program is exported by clvm_tools_rs and contains a to function among a few others. Its use is very like Program.to in the python code and similar to chiaminejp's clvm_tools library. It produces a value that can be used together with other such values, can be curried (and uncurried) converted to the hex representation and run.

Program.to(javascript_value)

Converts javascript values to SExp objects which can be used together and run as CLVM programs or used as program arguments. This conversion follows simple conventions that were established in clvm_tools.

  • There's a tuple object returned by the t function (2 arguments) which produces a cons.

  • javascript arrays are treated as linear proper lists. Each element appears as the first of a cons with the rest of the converted list as its tail. The list is terminated by a nil.

  • an object which has a serialize method treats the result of o.serialize() as an array-like object which specifies the byte values of the object's atom representation. This covers bls primitives such as G1Element and G2Element.

  • javascript numbers, bignums, strings and bools are treated as atoms.

  • javascript objects which contain an array-like pair member are treated the same as tuple objects above.

Program.from_hex(hex_str)

Converts a string of pairs of hex digits into the CLVM deserialized form of the object.

Program.null()

Returns a null object.

The returned objects have these methods:

SExp methods

SExp.toString()

Convert the object to its hex representation.

SExp.as_pair()

If it is a cons, return a tuple-compatible object containing a pair array with 2 elements, otherwise null.

SExp.listp()

Return true if the object is a cons.

SExp.nullp()

Return true if the object is falsey.

SExp.as_int()

Returns a javascript number that fits within the 32-bit integers representing the object's atom value, or throw.

SExp.as_bigint()

Returns a javascript big number representing the value of the given atom or throw.

SExp.first()

If the object is a cons, return its first or left component, or throw if not.

SExp.rest()

If the object is a cons, return its rest or right component, or throw if not.

SExp.cons(other)

Creates an SExp which is a cons of this sexp and other.

SExp.run(env)

Runs the indicated SExp as a program with the given environment.

SExp.as_bin()

Serialize the object into an array of byte values.

SExp.list_len()

Give the number of conses one needs to traverse until reaching a non-cons rest. For a proper list, this gives the list's length.

SExp.as_javascript()

Return a javascript value that allows the given SExp to be inspected via javascript.

SExp.curry(a, b, c ...)

Given a number of positional arguments, build a curried application that provides values for the left arguments of some runnable CLVM code, giving code that can be correctly called with fewer arguments. This is common for providing values to the upper case parameters of chialisp programs, such as coin puzzles.

SExp.uncurry(program) -> [inner_program, [args...]] SExp.uncurry_error(program)

Uncurry returns an array with the inner program and the retrievable arguments separated out, or the original program and null. uncurry_error throws instead of returning a value if the object wasn't a curried program.