64-bits unique ID generator for Node.js written in C++.
This is an experimental module. We strongly discourage you to use it production for the moment since we don't have tested it enough.
Despite, if you want to use and contribute to this module, your help is welcome!
npm install flocon --save
var flocon = require('flocon'); var id = flocon.snow(); console.log(typeof id); // string
Returns a Snowflake-inspired 64-bit IDs String object constructed using:
|Time (milliseconds)||41 bits||Time elapsed since epoch, hardcoded to January 1st, 2012.|
|Process ID||10 bits||
Process ID that is generating the 64-bits ID.
Can handle up to 1024 different process ID.
Incremental value starting from 0 and re initialised every ms.
Can generate 8192 per process per ms.
.snow() can generate a total of
npm test or check inside bench for more tests.
The MIT License (MIT)
Copyright (c) 2013 Yosee <email@example.com>
Permission 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.