nodupes
Prevent duplicate names by appending an incremented suffix.
Examples
example/nodupes.js
var nodupes = ;var names = 'name' 'name' 'othername' 'name' 'othername';names;
Output:
$ node example/nodupes.jsnamename-2othernamename-3othername-2
Usage
var nodupes = ;
var nd = nodupes(options)
Call nodupes()
to get a new nodupes function, with its own index and options.
Options:
var options = names: {} // Load a pre-existing names index (see `nd.getNames()`). suffixFirst: false // Add a suffix on the first appearance of a name. separator: '-' // Change the suffix separator.;
nd('name')
Returns the name with an appended suffix if needed.
nd.getNames()
Returns the names index that you can pass to nodupes()
with options.names
.
Installation
$ npm install nodupes