foreachline

1.1.0 • Public • Published

Online version - http://scriptnull.github.io/foreachline

Install

npm install -g foreachline

Usage

If you are a javascript fan who loves to do all your tasks with javascript , then foreachline is for you.

To use foreachline , you have to install it from npm and use the following command line.

foreachline src.txt logic.js 

or

fel src.txt logic.js res.txt

Use foreachline or just fel .

Arguments

  • src.txt - Source file for data.
  • logic.js - contains logic for mapping the data.
  • res.txt [Optional] - Results will be written to res.txt if specified , else will be written back to src.txt.

What can you do ?

Transform data . Be it a silly to-do list or 50 lines of code , map them the way you want.

Lets say you have the following source file src.txt

Apple
Orange
Banana

All you need to do is writing a JS file to map data on each line to new data.

while creating a JS file , you just need to know one thing . foreachline provides you 2 variables to operate on your data.They are line and lineNumber

Lets say you want to add lines numbers on each line of src.txt Then logic.js would look like

line = lineNumber + "." + line ;

and you will have

1.Apple
2.Orange
3.Banana

If you want to convert them to html list elements

line = "<li>" + line + "</li>" ; 

and you will have

<li>Apple</li>
<li>Orange</li>
<li>Banana</li>

If you want to create JavaScript objects

line = { id : lineNumber , name : line };

and you will have

{"id":1,"name":"Apple"}
{"id":2,"name":"Orange"}
{"id":3,"name":"Banana"}

and I can continue giving examples all night.

Plans

Yeah ! We made it to the web browser , as per the plan. Right now , there is no major plans for foreachline.

Contributing

Please visit the project page to have idea about contibuting towards foreachline.

Whatever you have in your mind , lets discuss. Gitter

License

This tool is licensed under the MIT License.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i foreachline

      Weekly Downloads

      3

      Version

      1.1.0

      License

      MIT

      Last publish

      Collaborators

      • scriptnull