https://github.com/stringmanolo/js
Run javascript in Linux/Termux terminal using node as engine
https://github.com/stringmanolo/js
Last synced: 10 months ago
JSON representation
Run javascript in Linux/Termux terminal using node as engine
- Host: GitHub
- URL: https://github.com/stringmanolo/js
- Owner: StringManolo
- Created: 2021-12-12T00:41:31.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-12T01:27:14.000Z (about 4 years ago)
- Last Synced: 2025-03-11T16:42:09.412Z (11 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js
Js is a command utility to run javascript as a command in a simple way.
### Use cases
- Run javascript in the fastest way posible preserving your code in the history.
- Empower your shell scripting and trasladate your javascript knowledge to the shell.
- Parse strings, use regexp, split, replace... using the same code everywhere.
### Features
- A pipedStdin global that holds piped input if provided from command line.
- A run global function that allows you to run commands also inside your javascript code.
- A loadFile function to load files in memory.
- Small and portable. 80 lines of code and should work anywhere.
- Only native node modules used, so you don't depend on versions and installs.
### Examples
Run javascript: ```js 'console.log("Hello world")'```
Work with piped streams: ```date | js 'console.log(pipedStdin.split(" ")[3])'```
Fetch a remote resource and return the number of words ```js 'console.log(run("curl --silent http://example.com"))' | wc -w```
### Install
npm install --global command-javascript
### Alternative Install
curl https://github.com/StringManolo/js/blob/c01e68feaaef521304fc7b5d073aec209243a311/bin/js -L > /usr/bin/js