1.4.0 • Published 7 years ago

essed v1.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

essed

essed is a simple program with purpose similar to sed or awk

Pros and cons

When to use essed

  • Dealing with line-delimited JSON
  • One-time time-consuming task
  • Playing around
  • Want to leverage knowledge of JavaScript

When not to use essed

  • Performance - sed is strongly optimized C code. JavaScript is much slower. It's totally possible for essed to be 200 times slower than C-based tools.
  • Non-UTF8 encodings (at least yet)
  • Dealing with binary files

Consider

  • Portability - you can use essed in your npm scripts. Though, it won't be installed globally on your CI.

TODO

  • Loading code from file
  • assert - assert input match some criteria. If it doesn't, break pipeline, otherwise return untouched
  • find - find first line matching some criteria
  • limit parameter on filter - if number of matched items exceed limit, drop them down
  • limit parameter on map
  • takeWhile
  • takeUntil
  • findLast
  • reduce
  • Native support for line-delimited JSON
  • Provide Webpack compiled build to improve startup time
  • Provide way to load external modules

map

Examples

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"

filter

Examples

Remove comments:

essed --filter "line.trim().startsWith('#')" ~/.zshrc

Comming

Allowed return values

  • string
  • Promise<string>
  • highland<string>
  • ReadableStream<string>

Enviroment

For your convenience we expose following "globals":

  • shared - empty object shared by many invocations
  • P, Bluebird - Bluebird instance
  • lodash, _ - lodash instance
  • hl, highland - highland instance
  • deburr, pad, trim, truncate, upperFirst, replace - exported from lodash
  • execFile, execFileSync - exported from native child_process
  • colors - colors instance
  • log - function that logs it's input on stderr 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.

Resources to read:

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago