salvator

0.2.0 • Public • Published

NPM version Build Status Dependency Status

Checks given filepath to exist, and if yes, returns safe version of filepath

Install

$ npm install --save salvator

Usage

var salvator = require('salvator');

salvator.safe('/path/to/my/file.js')
    .then(function(result) {
        // result is a safe to write filepath like a
        // /path/to/my/file(1).js
    });

API

salvator.safe(filepath: string[, options: Object]) : Promise
options.format

Type: string Default: "${dirname}/${filename}(${fix}).${extname}"

Template for a new path iterator.

options.counter

Type: Function(fix: Any) Default: [incremental function]

Where fix is a result from previous call, or undefined.

options.limit

Type: number Default: 999

Limit of iterations.

options.exclude

Type: Array
Default: []

Contains a list of "excluded" filepaths that will not be returned by the module in any case.

License

MIT © Sergey Kamrdin

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i salvator

    Weekly Downloads

    2

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • gobwas