Utility functions
Installation
npm i utilsac
Usage
utility.js
import {
createDebounced,
createThrottled,
throttledWithLast,
chainPromises,
chainRequestAnimationFrame,
doNTimes,
chainPromiseNTimes,
timeFunction,
timePromise,
memoizeAsStrings,
createTemplateTag,
bytesLengthFromString,
} from "utilsac";
deep.js
import {
deepCopy,
deepCopyAdded,
deepAssign,
deepAssignAdded,
deepEqual,
deepEqualAdded,
} from "utilsac/deep.js";
typeCast.js
import {
stringFromArrayBuffer,
arrayBufferFromBlob,
stringFromBlob,
} from "utilsac/typeCast.js";
evalGlobal.js
import { evalGlobal } from "utilsac/evalGlobal.js";
evalGlobal(`window.x = 2 ** 10`);
After the Promise is resolved the code has executed in global scope.
evalGlobal(`
import sin form "./x.js";
window.x = sin(Math.PI)
`, `module`);
Use optional second argument with module
to be able to use static imports
blobs.js
import { downloadBlob } from "utilsac/blobs.js";
deep.js
deepEqual example
const personA = { email: 'example@example@email.com', name: { firstname: 'James', lastname: 'William' }};
const personB = { email: 'example@example@email.com', name: { firstname: 'James', lastname: 'William' }};
deepEqual(personA, personB)
About
Changelog
Changelog
License
CC0
Related