@kastelll/util
TypeScript icon, indicating that this package has built-in type declarations

0.2.7 • Public • Published

@Kastelll/Util

Installation

yarn add @kastelll/util

or

npm install @kastelll/util

Usage

import { Snowflake, HTTPErrors } from '@kastelll/util';

const SnowflakeGen = new Snowflake({
	Epoch: 1_641_016_800_000,
	ProcessId: process.pid,
	ProcessIdBytes: 1,
	SequenceBytes: 6,
	WorkerId: 5,
	WorkerIdBytes: 12,
});

const GeneratedSnowflake = SnowflakeGen.Generate();

console.log(GeneratedSnowflake); // 21443134786896192

const HTTPError = new HTTPErrors(4000, {
	Code: {
		message: 'Invalid Code',
		status: 400,
	},
});

HTTPError.AddError({
	Waffles: {
		message: 'Invalid Waffles',
		status: 400,
	},
});

console.log(HTTPError.toJSON()); // { Code: 4000, Errors: { Code: { Message: 'Invalid Code', Status: 400 }, Waffles: { Message: 'Invalid Waffles', Status: 400 } }

Readme

Keywords

none

Package Sidebar

Install

npm i @kastelll/util

Weekly Downloads

2

Version

0.2.7

License

GPL-3.0-or-later

Unpacked Size

118 kB

Total Files

9

Last publish

Collaborators

  • darker_ink