Needlessly Postulating Minds

    utilsac

    15.0.2 • Public • Published

    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

    Consider structuredClone if you need deepCopy

    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

    Install

    npm i utilsac

    DownloadsWeekly Downloads

    202

    Version

    15.0.2

    License

    CC0-1.0

    Unpacked Size

    39.1 kB

    Total Files

    8

    Last publish

    Collaborators

    • grossacasacs