6.3.0 • Published 9 months ago
@drk4/utilities v6.3.0
Utilities Library
Random collection of utilities functions/classes.
Installation
npm install @drk4/utilities
Usage
import { Timeout } from '@drk4/utilities';
const timeout = new Timeout();
timeout.start(() => {
console.log('Done!');
}, 1000);import { Preload } from '@drk4/utilities';
const preload = new Preload();
const manifest = [
{ id: 'something', path: 'path/image.png' },
];
preload.addEventListener('complete', (loaded) => {
const image = preload.get('something');
// do something with it
});
preload.loadManifest(manifest);import { timeToString } from '@drk4/utilities';
const second = 1000;
const minute = 60 * second;
const hour = 60 * minute;
const time = 2 * hour + 30 * minute;
const text = timeToString({ time }); // "2 hours 30 minutes"
const daytime = timeToString({ time, format: "daytime" }); // "02:30:00"import { Dialog } from '@drk4/utilities';
import "@drk4/utilities/build/dialog.css"; // optional styling
const body = document.createElement('div');
body.innerHTML = "Some HTML elements here";
const dialog = new Dialog({
title: 'The Title', // title/body can be either a string or an HTMLElement
body,
});
dialog.open();In node you can require it (some things only work on the browser though).
const Utilities = require('@drk4/utilities');
const values = [1, 2, 3];
Utilities.shuffle(values);You can also just load directly with a script tag.
<script src="path/to/library/utilities.iife.js"></script>Documentation
You can read the documentation here.
Development
corepack enable(install pnpm)pnpm install(install the dependencies)pnpm run dev(run a dev build and a local server where you can try out some test pages that are used while developing the library components)pnpm run test(run the tests)pnpm run build(builds into the/builddirectory)pnpm run documentation(build the documentation into the/docsdirectory)
Check package.json scripts section for more information.
6.3.0
9 months ago
6.2.1
1 year ago
6.2.0
1 year ago
6.1.0
2 years ago
6.1.2
2 years ago
6.1.1
2 years ago
6.1.3
2 years ago
6.0.0
3 years ago
5.1.0
4 years ago
5.0.0
5 years ago
4.0.0
6 years ago
3.4.1
6 years ago
3.4.0
6 years ago
3.3.0
6 years ago
3.2.0
6 years ago
3.1.0
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
3.0.0
6 years ago