Coder Social home page Coder Social logo

pitabwire / xid Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 4.0 48 KB

Xid is a globally unique id generator. Xids are small, fast to generate, sortable, compact URL-safe string with no configuration or central generator server.

Home Page: https://pub.dev/packages/xid

License: MIT License

Dart 100.00%
id-generator uuid-generator xid dart flutter

xid's People

Contributors

pitabwire avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xid's Issues

Random RangeError on _getMachineId

It seems that, at random times when we try to generate a new Xid() it fails with a RangeError. The call stack shows:

RangeError (index): Index out of range: index should be less than 2: 2
  dart:typed_data                                        Uint8List.[]
  package:xid/src/xid_base.dart 113:30                   Xid._generateXid
  package:xid/src/xid_base.dart 29:5                     new Xid

When debugging it appears that the machineID array only has 2 elements instead of three:

String _generateXid() {
    var now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
    var counter = _counter();
    var machineID = _getMachineId();

    _xidBytes = List.filled(20, 0, growable: false);

    _xidBytes![0] = (now >> 24) & 0xff;
    _xidBytes![1] = (now >> 16) & 0xff;
    _xidBytes![2] = (now >> 8) & 0xff;
    _xidBytes![3] = (now) & 0xff;

    _xidBytes![4] = machineID[0];
    _xidBytes![5] = machineID[1];
    _xidBytes![6] = machineID[2]; //<--- it fails here.

When printing the machineID list the output is: [24, 128] instead of something like [10, 72, 66, 16]

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/changelog.yml
  • actions/checkout v4
  • saadmk11/changelog-ci v1.1.2
.github/workflows/draft_release.yml
.github/workflows/post_summaries.yaml
.github/workflows/publish.yaml
.github/workflows/run_tests.yaml
  • actions/checkout v4
pub
pubspec.yaml
  • lints ^1.0.0
  • test ^1.16.0
  • dart ^2.14.4

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.