datastore-id-codec
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

datastore-id-codec

A tool to encode shorter, user-friendly representations of Google Cloud Datastore (GCDS) IDs.

Mechanism

IDs assigned by GCDS are always highly divisible by 2. This property can be used to greatly shorten their encoded length, by factoring out the largest power of 2 it is divisible by.

Yes; this is somewhat of an implementation-dependent kludge :)

This tool's default implementation uses Crockford-alphabet base32 as its output format.

Usage

const base32DsIdCodec = require('datastore-id-codec').base32
 
// Outputs: "2D84Y0GV"
const encoded = base32DsIdCodec.encode('5201242305331200') 
 
// Outputs: "5201242305331200"
const decoded = base32DsIdCodec.decode('2D84Y0GV')

Readme

Keywords

none

Package Sidebar

Install

npm i datastore-id-codec

Weekly Downloads

1

Version

0.1.1

License

ISC

Unpacked Size

8.96 kB

Total Files

18

Last publish

Collaborators

  • beaulac