Nearly Post-Money

    swapdom

    1.1.1 • Public • Published

    swapdom test npm version

    Fast & tiny DOM swapper.

    import swap from './swap-inflate.js'
    
    swap(parentNode, oldNodes, newNodes, endNode)

    swap-deflate.js strategy is smaller (208b), but slower and doesn't support live collections.
    swap-inflate.js strategy is bigger (363b), but faster and supports live collections.

    Provide custom mutators as:

    swap.same = (a,b) => a?.isSameNode(b)
    swap.replace = (a,b, parent) => a.replaceWith(b)
    swap.insert = (a,b, parent) => a ? a.before(b) : parent.append(b)
    swap.remove = (a, parent) => a.remove()

    See benchmark.

    Install

    npm i swapdom

    DownloadsWeekly Downloads

    62

    Version

    1.1.1

    License

    ISC

    Unpacked Size

    45.3 kB

    Total Files

    14

    Last publish

    Collaborators

    • dy