Novel Personal Mantras

    kwark

    0.0.3 • Public • Published

    kwark:dom:select

    bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies bitHound Code

    A minimalistic selector library. NO external dependencies.

    insertBefore( targetNode )

    Insert selected node before the element passed in as an argument.

    const div = select.inline('<div><p>contents</p></div>').nodeify();
     
    div
        .insertBefore(document.querySelector('#nodey'));

    insertAfter( targetNode )

    Insert selected node after the element passed in as an argument.

    div
        .clone()
        .insertAfter(document.querySelector('#nodey'));

    kwark:dom:effects

    Pre-build effects and animations that extend the standard select library.

    kwark:core:utils

    Utilities, and standalone functions that make the core of kwark.

    partial( fn, [ ...arguments ])

    Partial application. Function will fire as soon as it gets enough arguments.

    var addThree = function(a,b,c) {
        return a + b + c;
    }
     
    var partialAddThree = kwark.partial(addThree);
     
    partialAddThree(1)(2);
    // nothing happens, waiting for the third arg
     
    partialAddThree(1,2)(3);
    // 6
    partialAddThree(1)(2,3);
    // 6
    partialAddThree(1)(2)(3);
    // 6

    compose( ...functions )

    Functional composition utility (reversed pipeline).

    var filteredData = kwark
        .compose(filterById, parseJson);
     
    kwark.ajax('get' url)
        .then(filteredData);

    contains( item, array )

    Checks whether array contains the given item.

    kwark.contains(1,[1,2,3]);
    // true

    extend( destination, source )

    Extends javascript object(s). With ES2015 in mind, rather use native Object.assign() method, or spread operator { ...object}.

    nSiblings( targetNode )

    All siblings following the target node.

    kwark.nSiblings(document.querySelector('#nodey'));

    pSiblings( targetNode )

    All siblings preceding the target node.

    kwark.pSiblings(document.querySelector('#nodey'));

    kwark:dom:addons

    serialize( targetNode )

    Serializes form node which is then ready to be sent as a request.

    var formNode = select('#form').node,
        serialized = addons.serialize(formNode);

    xmlToJson( XML )

    Parses xml file and returns a valid JSON object out of it.

    // (...) some request with xmlresponse
     
    var JSON = addons.xmlToJson(xmlresponse);
     

    loadScript( urlSource, [ callback ] )

    Fetches and loads the script from external url. The script itself is cleaned up from DOM after being loaded.

    addons.loadScript('https://somefancyfancysite.co.uk/script.js');

    kwark:async:ajax

    A simple promise-based implementation of ajax module.

    ajax( method, url ).then( resolve, reject )

    Generalised ajax method, supports basic GET and POST requests. Where resolve and reject are functions that take one single argument response, and error, respectiely. Ajax module does not support chaining multiple .then sequences. There is some debate whether it is a better approach than the regular "callback hell". Use functional composition (kwark.compose) instead, it improves the design of your app.

    kwark.ajax('get', url)
        .then(resolve, reject);

    Keywords

    none

    Install

    npm i kwark

    DownloadsWeekly Downloads

    1

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • graforlock