node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



node-snowflake is a node.js clone for twitter snowflake.

how to use

>//only run simple http server
> require('node-snowflake').Server(3001);

>//request url example:GET http://localhost:3001/next_id?worker_id={optional}&data_center_id={optional}&sequence={optional}

>//response : {"id":"439658373735124992"}

>//only run snowflake nextId
>var snowflake = require('node-snowflake').Snowflake;
>var id = snowflake.nextId(); // use default set
>//snowflake.init({worker_id : 1, data_center_id : 1, sequence : 0});
>//var id = snowflake.nextId();

see examples/example.js