@rbxts/squash
v1.1.6-ts.2
Published
Typings for Squash
Downloads
7
Readme
Squash
Typings for squash, a Roblox Ser/Des library.
Installation
Simply execute the command below to install it to your roblox-ts project.
npm i @rbxts/squash
Usage
Squash can be either imported as a namespace or destructured. Below are some examples with roblox-ts.
import Squash from "@rbxts/squash";
import { string, number, uint, int, boolean, ... } from "@rbxts/squash";
Unsigned Integers
const y = uint.ser(243, 1);
print(y); // ≤
print(uint.des(y, 1)); // 243
const y = uint.ser(7365, 2);
print(y); // ┼∟
print(uint.des(y, 2)); // 7365
Signed Integers
const y = int.ser(127, 1);
print(int.des(y, 1)); // 127
const y = int.ser(-127, 1);
print(int.des(y, 1)); // -127
const y = int.ser(128, 1);
print(int.des(y, 1)); // 128
const y = int.ser(-128, 1);
print(int.des(y, 1)); // -128
Floating Point
const y = number.ser(174302.923957475339573, 4);
print(y); // ╗7*H
print(number.des(y, 4)); // 174302.921875
const y = number.ser(-17534840302.923957475339573, 8);
print(y); // "▓╗╖íT►┬
print(number.des(y, 8)); // -17534840302.923958
Strings
const x = 'Hello, world!';
const alphabet = string.alphabet(x);
print(alphabet); // ' !,Hdelorw'
const y = string.ser(x, alphabet);
print(y); /** <-- There is a newline character here
'��C�**/
print(string.des(y, alphabet)); // 'Hello, world!'
const y = string.ser('great sword', Squash.lower .. ' ');
print(y); // ��L�,
print(string.des(y, Squash.lower .. ' ')); // 'great sword'
const y = string.convert('lowercase', Squash.lower, Squash.upper);
print(y); // 'LOWERCASE'
print(string.convert(y, Squash.upper, Squash.lower)); // 'lowercase'
const y = string.convert('1936', Squash.decimal, Squash.binary);
print(y); // '11110010000'
print(string.convert(y, Squash.binary, Squash.decimal)); // '1936'
Check out the original article for more information.