Skip to content

Reads a file list and returns it as an array of values.

License

Notifications You must be signed in to change notification settings

jmquigley/util.filelist

Repository files navigation

util.filelist

Reads a file list and returns it as an array of values.

build analysis code style: prettier testing NPM

Reads a given file list, stores each line in an array, and returns the array. It ignore blank lines and comments (# character). Each line is delimited by the newline characters.

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as a development dependency with cli:

$ yarn add --dev util.filelist

To build the app and run all tests:

$ yarn run all

Example Usage

const getFileList = require('util.filelist');
lines = getFileList("file.list");

lines.forEach(function(line) {
    console.log(line);
});

An example of the file.list above would be:

# This is a comment

    line 1

 line 2

This would result in an Array with only two lines (line 1 & line 2). The comment line and the blank line are removed and are not placed in the list. It also trims leading and trailing spaces.

About

Reads a file list and returns it as an array of values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published