thebrain-uuid-slug
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

thebrain-uuid-slug

npm

Encode TheBrain uuids to 22 characters slugs and decode slugs to uuids

This is useful to decode slugs from local thought url and create same url from BrainId and ThoughtId.

Install

npm install thebrain-uuid-slug

Usage

Create TheBrain local url

const { uuidToSlug } = require('thebrain-uuid-slug')
 
const brainId = 'fd7bebf7-0ea0-40c9-b8c7-969e54c86136'
const thoughtId = 'd527957d-d57b-4af5-bb68-d527fd7d7b3b'
 
const localUrl = `brain://api.thebrain.com/${uuidToSlug(brainId)}/${uuidToSlug(thoughtId)}`
 
assert.equal(
  localUrl,
  'brain://api.thebrain.com/9-t7_aMOyUC4x5aeVMhhNg/fZUn1XvV9Uq3aNUn_X17Ow'
)

Decode TheBrain local url slug to uuid

const { slugToUuid } = require('thebrain-uuid-slug')
 
const slug = '9-t7_aMOyUC4x5aeVMhhNg'
 
assert.equal(slugToUuid(slug), 'fd7bebf7-0ea3-40c9-b8c7-969e54c86136')

Package Sidebar

Install

npm i thebrain-uuid-slug

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

6.83 kB

Total Files

6

Last publish

Collaborators

  • wmakeev