TooTallNate / jsfunc

Write JavaScript functions - use as bash functions

Home Page:https://import.pw/tootallnate/jsfunc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsfunc

Write JavaScript functions - use as shell functions!

Note: jsfunc requires a shell that supports Here Documents. bash is recommended.

Example

#!/bin/bash
. "$(which import)"

import tootallnate/jsfunc@2.0.0

# Define a shell function named `str_func`, written in JavaScript
jsfunc str_func <<EOF
  const stdin = String(await process.stdin);
  return (stdin + ' ' + process.argv[2]).toUpperCase();
EOF

# Invoke it the same as any other shell function
printf hello | str_func world
# HELLO WORLD

About

Write JavaScript functions - use as bash functions

https://import.pw/tootallnate/jsfunc


Languages

Language:Shell 100.0%