Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

robert-util

Commandtechno25ISC1.0.0TypeScript support: included

Utilities for robert and robert-server packages

robert, utils, http, https, carrot, chomp

readme

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