lost22git / xid.cr

xid for crystal lang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xid for crystal lang

API DOC

Resources:

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  xid:
    github: lost22git/xid.cr
  1. Run shards install

Usage

require "xid"

# generate a Xid
xid = Xid.generate

# xid to string
str = xid.to_s

# parse string to Xid
xid2 = Xid.from_s str

# xid as read only bytes view
bytes = xid2.as_bytes

# generate Xid by bytes
xid3 = Xid.from_bytes bytes

# resolve time from xid
p! xid3.time

# print xid debug info
xid3.debug

Development

Run tests

crystal spec --progress

Run bench

crystal run --release --progress bench/xid_bench.cr

Contributing

  1. Fork it (https://github.com/lost22git/xid.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • lost - creator and maintainer

About

xid for crystal lang

License:MIT License


Languages

Language:Crystal 93.8%Language:Just 6.2%