Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    fd-insert-beforepublic

    fd-insert-before

    Build Status npm version

    insert-before DOM element in a functional way.

    Installation

    npm install fd-insert-before --save

    Usage

    Let the DOM be like:

    <div id="parentElement">
      <span id="childElement">foo bar</span>
    </div>```
     
     
    ```js
    let insertBefore = require('fd-insert-before');
     
    let sp1 = elem("span","meow")
    ,sp2 = document.getElementById("childElement")
    ,parentDiv = sp2.parentNode
     
    insertBefore(parentDiv, sp1, sp2);
     
    selectOne('#parentElement').children[0].innerText; // => 'meow'

    API

    insert-before :: parent -> newChild -> refChild
    

    A curried function that takes in:

    • parent The parent of the newly inserted node.

    • newChild The node to insert.

    • refChild The node before which newChild is inserted.

    Keywords

    install

    npm i fd-insert-before

    Downloadsweekly downloads

    6

    version

    1.0.1

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar
    • avatar