seq-id-generator-react-native
v1.1.1
Published
int sequence generator, based on async storage
Downloads
5
Readme
seq-id-generator-react-native
generates an sequence id (1, 2, 3, 4...), based on asyncstorage
Usage
npm i seq-id-generator-react-native
const name = 'purchase'
const seqIdGenerator = require('seq-id-generator-react-native')
seqIdGenerator(name)
.then((generator) => generator.next())
.then((id) => console.log(id))
.catch((error) => console.error(error))
// with formating Function
seqIdGenerator(name, id => `A-${id}`)
.then((generator) => generator.next())
.then((id) => console.log(id))
.catch((error) => console.error(error))
// or callback style
seqIdGenerator(name, null, (error, generator) => {
if (error) return console.error(error)
generator.next((error, id) => {
if (error) return console.error(error)
console.log(id)
})
})