salvator
v0.2.0
Published
Safe write path checker
Downloads
4
Maintainers
Readme
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