essed
is a simple program with purpose similar to sed
or awk
- Dealing with line-delimited JSON
- One-time time-consuming task
- Playing around
- Want to leverage knowledge of JavaScript
- Performance -
sed
is strongly optimized C code. JavaScript is much slower. It's totally possible foressed
to be 200 times slower than C-based tools. - Non-UTF8 encodings (at least yet)
- Dealing with binary files
- Portability - you can use
essed
in yournpm
scripts. Though, it won't be installed globally on your CI.
Remove whitespace from each line:
cat ~/.bashrc | essed --map "line.trim()"
Reverse lines:
cat ~/.bashrc | essed --map "$0.reverse()"
Remove comments (nulls and undefineds are filtered out from output):
cat ~/.zshrc | essed --map "value.trim().startsWith('#') ? null : line"
Color even lines (terminal):
cat ~/.zshrc | essed -m "i % 2 ? line.yellow : line"
Remove comments:
essed --filter "line.trim().startsWith('#')" ~/.zshrc
string
Promise<string>
highland<string>
ReadableStream<string>
For your convenience we expose following "globals":
shared
- empty object shared by many invocationsP
,Bluebird
- Bluebird instancelodash
,_
- lodash instancehl
,highland
- highland instancedeburr
,pad
,trim
,truncate
,upperFirst
,replace
- exported fromlodash
execFile
,execFileSync
- exported from nativechild_process
colors
-colors
instancelog
- function that logs it's input onstderr
and returns first argument.fs
- native Node.js module **log(line) === line
colors module is avalaible by default.
Line is available as line
, l
, value
, $0
.
Number of line is avalaiable as i
and index
.