@plurid/pipes.replacer
TypeScript icon, indicating that this package has built-in type declarations

0.0.0-3 • Public • Published



License: DEL

plurid' pipes

Utility Pipes for Scripts

Content Replacer Pipe


Contents

Install

It is preferred to install the pipe globally

npm install -g @plurid/pipes.replacer

and run the script with the global NODE_PATH

export NODE_PATH=$(npm root --quiet -g) && node path/to/script.js

Usage

Require in script file, generate a replace function, use it on files.

const replacer = require('../distribution/index').default;


const main = async () => {
    // obtain a replacer function
    const replace = replacer(
        'searchString',
        'replaceString',
    );

    // use the replacer by passing paths to files
    await replace('/path/to/file');
}


main();

The following options can be passed to the replacer and to replace

export interface ReplacerOptions {
    /**
     * Regular Expression replacement flags.
     *
     * Default: `'gm'`.
     */
    flags: string;
}


export interface ReplaceOptions {
    /**
     * Return the replaced result.
     *
     * Default: `false`.
     */
    extract: boolean;

    /**
     * Write result to another file.
     */
    redirect: string;
}

Packages

Version

@plurid/pipes.finder • files finder pipe

Version

@plurid/pipes.replacer • content replacer pipe

Codeophon

Readme

Keywords

Package Sidebar

Install

npm i @plurid/pipes.replacer

Weekly Downloads

1

Version

0.0.0-3

License

SEE LICENSE IN LICENSE

Unpacked Size

14.7 kB

Total Files

11

Last publish

Collaborators

  • ly3xqhl8g9