kssfilo/olnode


One Liner's NODE.js, Helps to write one line node.js stdin filter program like perl.(CLI toos/module)

License: MIT

Language: CoffeeScript


olnode

One Liner's NODE.js, Helps to write one line node.js stdin filter program like perl.(CLI tool/module)

Install

sudo npm install -g olnode

Example

	echo '{"s":"Hello World"}' | olnode -e 'console.log(JSON.parse($_).s)'
	# Hello World

	echo -e "Hello World\nGoodnight World"|olnode -pe 'm=$_.match(/^Hello/);return(m?$_:"---")'
	# Hello World
	# ---

	echo -e "Hello World\nGoodnight World"|olnode -ne 'console.log($_.length)'
	# 11
	# 15

	echo -e "Hello,World\nGoodnight,World"|olnode -aF ','  -ne 'console.log($F[0])'
	# Hello
	# Goodnight

	echo -e "Hello World\nGoodnight World"|olnode -ne '$G.count+=$_.length' -B '$G.count=0' -E 'console.log("chars:"+$G.count)'
	# chars:26

Usage

@PARTPIPE@|dist/cli.js -h
See npmjs.com or olnode -h
@PARTPIPE@

Module

npm install olnode

echo '{"s":"Hello World"}'| node -e 'require("olnode").e(($_,$G)=>{console.log(JSON.parse($_).s);})'
# Hello World

echo -e "Hello\nWorld"| node -e 'require("olnode").pe(($_,$G)=>{return $_.replace(/Hello/,"Hi!")})'
# Hi!
# World

echo -e "Hello\nWorld"| node -e 'require("olnode").ne(($_,$G)=>{$G.count+=$_.length},($G)=>{$G.count=0},($G)=>{console.log(`Chars:${$G.count}`)})'
# Chars:10

# require.("olnode").e(<function(-e)>)
# require.("olnode").e(<RegExp|String>,<function(-e)>)

# require.("olnode").ne(<function(-e)>,<function(-B)>,<Function(-E)>)
# require.("olnode").ne(<RegExp|String>,[<function(-e)>,<function(-B)>,<Function(-E)>])

# require.("olnode").pe(<function(-e)>,<function(-B)>,<Function(-E)>)
# require.("olnode").pe(<RegExp|String>,<function(-e)>,[<function(-B)>,<Function(-E)>])

# each functions returns return(x) value of <Function(-E)>(ne()/pe()) or <function(-e)>(e())
# <RegExp|String> is seperator for .split() if you need to specify

Change Log

  • 0.0.1:first release

Project Statistics

Sourcerank 2
Repository Size 5.86 KB
Stars 0
Forks 0
Watchers 0
Open issues 0
Dependencies 4
Contributors 1
Tags 2
Created
Last updated
Last pushed

Top Contributors See all

kssfilo

Packages Referencing this Repo

olnode
One Liner NODE.js, Helps to write one line node.js stdin filter program like perl.(CLI tool/module)
Latest release 1.0.0 - Published

Recent Tags See all

1.0.1 July 04, 2019
1.0.0 July 04, 2019

Something wrong with this page? Make a suggestion

Last synced: 2019-07-05 00:17:23 UTC

Login to resync this repository