Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qard/id-pool
Temporary unique id pooling
https://github.com/qard/id-pool
Last synced: about 1 month ago
JSON representation
Temporary unique id pooling
- Host: GitHub
- URL: https://github.com/qard/id-pool
- Owner: Qard
- Created: 2014-07-21T21:24:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-20T03:57:41.000Z (over 4 years ago)
- Last Synced: 2024-10-12T03:10:03.797Z (about 1 month ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IdPool
With IdPool, you can reserve ids that remain unique until released.## Installation
```sh
npm install id-pool
```## Usage
```js
const pool = new IdPool()
pool.on('release', id => {
console.log('release', id)
})const first = pool.reserve()
const second = pool.reserve()setImmediate(function () {
pool.release(first)
pool.release(second)
})
```
---### Copyright (c) 2019 Stephen Belanger
#### Licensed under MIT LicensePermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.