egg-cute-snowflake

cute snowflake for egg

Usage no npm install needed!

<script type="module">
  import eggCuteSnowflake from 'https://cdn.skypack.dev/egg-cute-snowflake';
</script>

README

egg-cute-snowflake

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-cute-snowflake --save

Usage

// {app_root}/config/plugin.js
exports.snowflake = {
  enable: true,
  package: 'egg-cute-snowflake',
};

Configuration

JAVA 64bit

config.snowflake = {
  app: true,
  agent: true,
  client: {
    twepoch: 1480166465631,
    dataCenterIdBits: 5,
    workerIdBits: 5,
    sequenceBits: 12,
  },
};

Return a 64bit string, for example '553211427826962432'
  
JS 53bit

config.snowflake = {
  app: true,
  agent: true,
  client: {
    twepoch: 1480166465631,
    dataCenterIdBits: 3,
    workerIdBits: 3,
    sequenceBits: 6,
  },
};

Return a 53bit number, for example '540245822818368'

see config/config.default.js for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT