1.1.2 • Published 3 years ago

splitfilt v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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
  });
1.1.2

3 years ago

1.1.1

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago