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

yavascript

v0.0.11

Published

YavaScript is a cross-platform bash-like script runner and repl which is distributed as a single statically-linked binary. Scripts can be written in JavaScript, TypeScript, JSX/TSX, or CoffeeScript.

Downloads

32

Readme

yavascript

YavaScript is a cross-platform bash-like script runner and repl which is distributed as a single statically-linked binary. Scripts can be written in JavaScript, TypeScript, JSX/TSX, or CoffeeScript.

There are APIs available for all the things you'd normally want to do in a bash script, such as:

  • Running programs and getting their stdout/stderr/status
  • Reading/writing environment variables
  • Checking if files/folders exist
  • Removing/creating/copying files/folders
  • Reading and changing the current working directory
  • Reading and resolving symbolic links
  • Using globs to get large lists of files
  • Printing stylized text
  • Clearing the terminal
  • Fetching files from the internet

Additionally, you can do other things that are either not present in bash or are cumbersome to use in bash, namely:

  • Serialize and deserialize JSON, CSV, and YAML
  • Removing ANSI control characters from a string
  • Split path strings into a list of segments and rejoin them into a string
  • Check if a path is absolute and resolve relative paths
  • Parse command-line flags
  • Work with Arrays (lists)
  • Work with Objects (key/value dictionaries)
  • Work with Typed Arrays (byte buffers)
  • Reliably get the path to the currently-running file
  • Strongly-typed interfaces and functions (via TypeScript)
  • Cross-file import/export using ECMAScript Modules
  • Split strings on delimeters
  • Pretty-print complex structures
  • Call low-level POSIX C APIs like fputs, sprintf, isatty
  • Perform work in threads
  • Import packages from npm (via "npm:" imports) or local node_modules

You'll also find analogues to familiar CLI tools, like:

  • dirname
  • basename
  • cat
  • ls
  • realpath
  • readlink

...and more.

To view the APIs, consult the file yavascript.d.ts which was distributed with this program, or online at https://github.com/suchipi/yavascript/blob/main/yavascript.d.ts. This file contains TypeScript type definitions which can be given to your IDE to assist you when writing scripts, even if you aren't writing your scripts in TypeScript.

Here's an example of a script using YavaScript:

#!/usr/bin/env yavascript

// This comment is optional; it tells VS Code to load the specified TypeScript definitions.
/// <reference path="./yavascript.d.ts" />

let isWorkingTreeDirty;
try {
  exec(`git diff --quiet`);
  isWorkingTreeDirty = false;
} catch (error) {
  isWorkingTreeDirty = true;
}

const branchName = $(`git rev-parse --abbrev-ref HEAD`).stdout.trim();

const gitInfo = { branchName, isWorkingTreeDirty };
echo(gitInfo);

writeFile("git-info.yml", YAML.stringify(gitInfo));

YavaScript is powered by a fork of the QuickJS JavaScript Engine, originally written by Fabrice Bellard. QuickJS is a small, fast JavaScript engine supporting the ES2020 specification.

  • Original QuickJS engine: https://bellard.org/quickjs/
  • The fork we use: https://github.com/suchipi/quickjs/

Compiling

You'll need to install these prerequisites:

Then run meta/build.sh to build binaries for the current platform (will be output in dist), or meta/build-all.sh to build binaries for all platforms (will be output in bin).

Building the Docker image

You will need docker installed. After building binaries for all platforms, ensure yavascript is in your PATH, then run meta/docker/build-image.sh.


YavaScript is written with <3 by Lily Skye.