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

moon-tool

v0.2.29

Published

Command-lite tool for Moon-lang

Downloads

101

Readme

moon-tool

Command-line tool for Moon-lang. Allows you to:

  • Run expressions and files from the command-line;

  • Load/save expressions and files to IPFS;

  • Pack/unpack, compile to JS, etc...

Installing

npm i -g moon-tool

Usage

Inline execution:

moon run '(add 1 2)'        -- output: 3
moon run 'x=4 y=2 [x y]'    -- output: [4 2]
moon run '((x => [x x]) 3)' -- output: [3 3]

File execution:

echo '"Hello"' >> hi.moon
moon run hi -- output: "Hello"

Saving to IPFS:

moon save 'x => (add x 1)'
-- output: zb2rhoKHTgNBYJDnzaBn8uaCpKuX9iGpsc2hpLdE2k2YTD1jH

After you save an expression, you may use its hash inside other expressions: moon run recursively imports IPFS hashes.

Loading from IPFS:

moon load zb2rhoKHTgNBYJDnzaBn8uaCpKuX9iGpsc2hpLdE2k2YTD1jH
-- output: x => (add x 1)

Updating IPFS imports:

If you modify a file and save it to IPFS, all files that import it will keep using the old version, because Moon guarantees that a file's behavior doesn't change if its contents don't change. This can be very annoying when you just want to update a file which is imported in many places. To amend that, moon-tool provides the replace command, which allows you to change the contents of a file, save it to IPFS and recursivelly update all imports that refer to the old version. Example:

# creates a `helloworld.moon` file which imports a `hello.moon` file

$ echo "\"hello\"" > hello.moon

$ echo "[$(moon save hello) \"world\"]" > helloworld.moon

# Prints and runs both files

$ cat hello.moon
"hello"

$ moon run hello
"hello"

$ cat helloworld.moon
[zb2rhfsstEj5riwMdMpKep4h1MmCXTzKYrucQJ6TEqRCRRxAw "world"]

$ moon run helloworld
["hello" "world"]

# Rewrites `hello.moon`'s contents

$ moon replace hello.moon "\"hola\""
zb2rhfsstEj5riwMdMpKep4h1MmCXTzKYrucQJ6TEqRCRRxAw -> zb2rhf5uqM37QCXN8VMTXYPDA2XB2w1fwHzy91CjWovJmVGUW (hello.moon)
zb2rhiNoCanP5qCJeePx5zEyp8EBp9tBgGrEmQJ1K7ZKNSena -> zb2rhkikpZPfJGvJJ2wyUSTe9W4zeKBJHuaSrfpFBpbH18M3N (helloworld.moon)

# Prints and runs both files again

$ cat hello.moon
"hola"

$ moon run hello
"hola"

$ cat helloworld.moon
[zb2rhf5uqM37QCXN8VMTXYPDA2XB2w1fwHzy91CjWovJmVGUW "world"]

$ moon run helloworld
["hola" "world"]

# Notice `helloworld.moon` changed accourdingly.

You can also replace arbitrary expressions:

moon replace "some_regex" "new_value"

Note moon replace modifies your files, so use it carefully.

Running with side-effects:

moon runIO 'ask => end => (ask "prompt" "Hi!" then => (end 0))'

Moon is pure, but you can still peform side-effects by evaluating computations in a side-effective language. The runIO command does that with default side-effects.

Compiling to JavaScript:

moon compile 'x => (mul x 10)'