1.0.0 • Published 2 years ago

robert-util v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Logo

utilities for robert and robert-server

Usage

// CommonJS
const utils = require("robert-utils");

// Typescript / ES2019
import * as utils from "robert-utils";

Time and size

// parse time to milliseconds
utils.parseTime("1m"); // 60000

// parse size to bytes
utils.parseSize("1kb"); // 1024

Parsing

all functions take an http incoming message, and a maxSize (number) parameter

utils.toBuffers(); // Array of buffers
utils.toBuffer(); // Buffer
utils.toArrayBuffer(); // ArrayBuffer instance
utils.toBlob(); // Blob with the content-type already set
utils.toString(); // String
utils.toJSON(); // Object