remove-duplicate-lines

0.1.1 • Public • Published

remove-duplicate-lines

GitHub | NPM | @jelmerdemaat

Removes duplicate lines from a given input text.

Usage

Install:

npm install remove-duplicate-lines

Use:

const removeDuplicateLines = require('remove-duplicate-lines');
 
const example = `
    jelmer
    jelmer
    de
    maat
    testing123
    testing
    testing
    testing123
`;
 
removeDuplicateLines(example)
    .then(output => console.log(output))
    // Logs:
    // jelmer
    // de
    // maat
    // testing123
    // testing
    // testing123
    .catch(error => console.log(error))
    // Logs potential errors

Arguments

source | String | The input text (required)

options | Boolean | An object containing options.

Options

unique | Boolean | Default: false | Allow every line only once in the entire text.

Pass options in an object as the seconds argument. Example:

const example = `
    jelmer
    jelmer
    de
    maat
    testing123
    testing
    testing
    testing123
`;
 
removeDuplicateLines(example, { unique: true })
    .then(output => console.log(output))
    // Logs:
    // jelmer
    // de
    // maat
    // testing
    // testing123
    .catch(error => console.log(error))
    // Logs potential errors

Package Sidebar

Install

npm i remove-duplicate-lines

Weekly Downloads

4

Version

0.1.1

License

SEE LICENSE IN LICENSE

Unpacked Size

2.95 kB

Total Files

6

Last publish

Collaborators

  • jelmer