# flocon **Repository Path**: painkiller/flocon ## Basic Information - **Project Name**: flocon - **Description**: 修改了在OSX 11.12 Node 6.6.0下无法编译的问题 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-04-21 - **Last Updated**: 2024-12-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # flocon [](https://travis-ci.org/Yosee/flocon) 64-bits unique ID generator for Node.js written in C++. Due to Javascript limitations to handle 53 bits Integer, this module returns a 64 bits integer using a String representation. **flocon** is meant to be used with [mongoose](https://github.com/learnboost/mongoose) and [mongoose-long](https://github.com/aheckmann/mongoose-long) but feel free to use it with any other database. ## Disclaimer 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! ## Requirements This module requires [C++11](http://en.wikipedia.org/wiki/C++11) because we use [chrono](http://www.cplusplus.com/reference/chrono/) to work with timestamps. ## Installation ``` npm install flocon --save ``` ## Usage ```javascript var flocon = require('flocon'); var id = flocon.snow(); console.log(typeof id); // string ``` ### flocon.snow() Returns a [Snowflake](https://github.com/twitter/snowflake/)-inspired 64-bit IDs String object constructed using:
| Input | Size | Comment |
|---|---|---|
| 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. |
| Counter | 13 bits |
Incremental value starting from 0 and re initialised every ms. Can generate 8192 per process per ms. |