utilsac

Utility functions

Usage no npm install needed!

<script type="module">
  import utilsac from 'https://cdn.skypack.dev/utilsac';
</script>

README

utilsac

Utility functions

Installation

npm i utilsac

Usage

The source code is the documentation.

utility.js

import {
    createDebounced,
    createThrottled,
    throttledWithLast,
    chainPromises,
    somePromisesParallel,
    chainRequestAnimationFrame,
    doNTimes,
    chainPromiseNTimes,
    timeFunction,
    timePromise,
    memoizeAsStrings,
    createTemplateTag,
    bytesLengthFromString,
} from "utilsac";

// deno
import {
    createDebounced,
    createThrottled,
    throttledWithLast,
    chainPromises,
    somePromisesParallel,
    chainRequestAnimationFrame,
    doNTimes,
    chainPromiseNTimes,
    timeFunction,
    timePromise,
    memoizeAsStrings,
    createTemplateTag,
    bytesLengthFromString,
} from "https://unpkg.com/utilsac/utility.js";

deep.js

import {
    deepCopy,
    deepCopyAdded,
    deepAssign,
    deepAssignAdded,
    deepEqual,
    deepEqualAdded,
    deepDifference,
} from "utilsac/deep.js";

// deno
import {
    deepCopy,
    deepCopyAdded,
    deepAssign,
    deepAssignAdded,
    deepEqual,
    deepEqualAdded,
    deepDifference,
} from "https://unpkg.com/utilsac/deep.js";

deepEqual example

const personA = { email: 'example@email.com', name: { firstname: 'James', lastname: 'William' }};

const personB = { email: 'example@email.com', name: { firstname: 'James', lastname: 'William' }};

deepEqual(personA, personB); //  true

typeCast.js

import {
    stringFromArrayBuffer,
    arrayBufferFromBlob,
    stringFromBlob,
    stringFromArray,
    setFromArray,
    mapFromObject,
} from "utilsac/typeCast.js";

// deno
import {
    deepCopy,
    deepCopyAdded,
    deepAssign,
    deepAssignAdded,
    deepEqual,
    deepEqualAdded,
    deepDifference,
} from "https://unpkg.com/utilsac/typeCast.js";

browserUtility.js

import { 
    evalGlobal,
    downloadBlob,
} from "utilsac/browserUtility.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

About

Changelog

Changelog

License

CC0

Related