splitfilt

1.1.2 • Public • Published

SplitFilt

Utility for split the content of a textfile given a filepath, with the posibility of filter splitted items given a string (or an array of strings) and keeping separator/delimeter in results if desired.

Methods

  • splitText(filepath [, options]) Separator by default is carriage return.

  • splitPhrases(filepath [, options]) Separator is always a dot, trim every 'phrase' and preserve dot.

  • splitTextAsync(filepath [, options]) Same than splitText, but returns a promise.

  • splitPhrasesAsync(filepath [, options]) Same than splitPhrases, but returns a promise.

All of them will return an array.

Options

An object with properties (all of them optionals):

  • separator: String or regular expression to split the text. By default, a carriage return in splitText and a dot in splitPhrases.
  • containing: Single string or an array of strings to filter the splitted items.
  • insensitive: Boolean value to determine if filter must be case insensitive or not (true by default).
  • keepsSeparator: Boolean value to determine if splitted results maintain the separator (false by default).

Examples:

const splitfilt = require('splitfilt');

const filePath = '/texts/someFile.txt';
const options = {
  containing: ['something', 'other'],
  separator: ' - ',
  insensitive: false,
  keepsSeparator: true
};

splitfilt.splitTextAsync(filePath, options)
.then(console.log);

const phrasesWithHello = splitfilt.splitPhrases('/texts/someFile.txt', {
  containing: 'Hello',
  insensitive: false
  });

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.20latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.20
1.1.10
1.0.70
1.0.60
1.0.50
1.0.41
1.0.30
1.0.20
1.0.10
1.0.01

Package Sidebar

Install

npm i splitfilt

Weekly Downloads

2

Version

1.1.2

License

ISC

Unpacked Size

5.23 kB

Total Files

3

Last publish

Collaborators

  • usuario616