1.1.1 • Published 3 years ago

zwsp v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ZWSP

Store data using zero width spaces! Might be useful for discord bots.


Installation

npm i zwsp

Usage

Import the library:

import { encode, decode} from 'zwsp'; // typescript

const { encode, decode } = require('zwsp'); // node.js

Encoding:

encode("Hello World!");
encode(3.14159265359);
encode(12345678987654321n);
encode([ 123, "Hello", 321, "World" ]);
encode({ a: 123, b: 321, c: "example", d: [ "Hello", "world" ] });

Decoding:

decode(...);

// will also keep the type:
decode(encode("123")); // "123" (string)
decode(encode(123)); // 123 (number)
decode(encode([1, 2, 3])); // [1, 2, 3] (object)

Why?

tbh, I don't really know. This might be useful for discord bots that don't use any database but still need to store certain information (for example, bots hosted on heroku).

That was just a random idea that came to my mind at 3 am lol.

npm.io

It works because the characters this library uses are actually a zero-width spaces and are invisible. Users still can access the info you stored, but a regular user won't notice anything.


Other examples

Visit examples directory for other examples (with discord.js)

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago