Skip to content

Instantly share code, notes, and snippets.

View joelvim's full-sized avatar
🏠
Working from home

Joël Vimenet joelvim

🏠
Working from home
View GitHub Profile
@joelvim
joelvim / index.js
Created May 25, 2023 15:04
UUID to ULID encoding
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const base32Chars = '0123456789abcdefghjkmnpqrstvwxyz'
const ENCODING_LEN = base32Chars.length
function hexToBytes(hex) {
let bytes = new Array(hex.length * 4);
let index = 0;
for (let c = 0; c < hex.length; c += 2) {
var value = parseInt(hex.substr(c, 2), 16);
for (let d = 0; d < 8; d++) {
@joelvim
joelvim / index.js
Created May 25, 2023 11:11
id128 umd
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const { Ulid } = require('./src/id/ulid');
const { UlidMonotonic } = require('./src/id/ulid-monotonic');
const { Uuid } = require('./src/id/uuid');
const { Uuid1 } = require('./src/id/uuid-1');
const { Uuid4 } = require('./src/id/uuid-4');
const { Uuid6 } = require('./src/id/uuid-6');
const { UuidNil } = require('./src/id/uuid-nil');
const Crockford32Coder = require('./src/coder/crockford32');
@joelvim
joelvim / index.js
Created May 25, 2023 10:58
base32 umd
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.base32 = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 568:
/***/ ((module) => {
// eslint-disable-next-line no-extra-semi
;(funct

Keybase proof

I hereby claim:

  • I am joelvim on github.
  • I am joelvim (https://keybase.io/joelvim) on keybase.
  • I have a public key ASBTn622zhjXnixaWAPMJcECEnkZZ1cOXzVWCz5KYyE7Ywo

To claim this, I am signing this object: