handyjs 1.6.0
Install from the command line:
Learn more about npm packages
$ npm install @dgtlworkshop/handyjs@1.6.0
Install via package.json:
"@dgtlworkshop/handyjs": "1.6.0"
About this version
A collection of handy functions and reference types used across DGTL's Javascript projects. All functions are as close to pure as they can get and nearly all are designed to run in the browser or NodeJs. No modules have top-level await
.
"Because JavaScript doesn't really have a standard library"
echo "@dgtlworkshop:registry=https://npm.pkg.github.com" >> .npmrc
npm install @dgtlworkshop/handyjs
import { Chrono, Maths } from "@dgtlworkshop/handyjs";
await Chrono.timeout(500);
console.info("0.5 of 4 is equal to", Maths.mapRange(0.5, 0, 4, 0, 12), "of 12");
The Browser module can only be imported in the browser due to using document APIs.
import { Downloads } from "@dgtlworkshop/handyjs/browser";
let my_blob = new Blob();
Downloads.downloadFileFromBlob("myimage.jpg", "image/jpg", my_blob);
Similarly, the Server module can only be imported in Node (or other compatible environments).
import { Program } from "@dgtlworkshop/handyjs/server";
if (Program.isMain(import.meta.url)) {
console.info("Hello World");
} else {
// This file was imported, not the entrypoint
}