seq-id-generator
v1.3.1
Published
int sequence generator, based on file
Downloads
9
Readme
seq-id-generator
generates an sequence id (1, 2, 3, 4...), based on a file
Usage
npm i seq-id-generator
const path = '/tmp/file.txt'
const seqIdGenerator = require('seq-id-generator')
seqIdGenerator(path)
.then((generator) => generator.next())
.then((id) => console.log(id))
.catch((error) => console.error(error))
// with formating Function
seqIdGenerator(path, (id) => `A-${id}`)
.then((generator) => generator.next())
.then((id) => console.log(id))
.catch((error) => console.error(error))
// or callback style
seqIdGenerator(path, null, (error, generator) => {
if (error) return console.error(error)
generator.next((error, id) => {
if (error) return console.error(error)
console.log(id)
})
})