0.1.0 • Published 3 years ago

doge-utils v0.1.0

Weekly downloads
-
License
GPL-2.0-or-later
Repository
github
Last release
3 years ago

doge-utils

What is this?

This was supposed to be a collection of utilities to ease the usage of the DogeHouse API.

It currently only includes a token formatting utility.

Creating chat tokens

import { format } from 'doge-utils'

const unformatted = <anything except recursive object, Symbol, or BigInt>

const formatted_message = format(unformatted);

// formatted message is now an array of valid DogeHouse ChatTokens.
// Array<{ t: string; v: string }>

Interpreting chat tokens

import { messageToString } from 'doge-utils'

const tokens = <properly formatted tokens>

const str = messageToString(tokens);

// str is now a String

Real example

import { format, messageToString } from 'doge-utils'

const message = [ ['Hello,'], { mention: 'world' } ]; // weirdly formatted message

const tokens = format(message); // [ { t: 'text', v: 'Hello' }, { t: 'mention', v: 'world' } ]

const str = messageToString(tokens); // 'Hello, @world'

messageToString(format(str)) === str // true

format(messageToString(tokens)) === tokens

// false, because it's a different object.
// The shape and values of the object are the same, however.
0.1.0

3 years ago

0.1.0-1

3 years ago

0.1.0-2

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago