Neurotic Pink Mongooses

    eoc

    0.1.0 • Public • Published

    eoc

    npm version Travis CI Badge (master branch)

    An utility to create shallow extended objects, made for use with setting default options in functions.

    How to include

    Node.js / Browserify

    In your shell:

    $ npm install --save eoc
    

    In your javascript:

    var eoc = require('eoc')

    Browser ("classic" way)

    Just add a script tag with either eoc.js or eoc.min.js from this repos root directory. This makes the eoc variable globally available.

    typeof window.eoc
    // --> 'function'

    API

    eoc(<defaults>[, <override>[, <key>]])

    Returns a shallow (depth 1) clone of defaults, extended with override. If override is of any other than than 'object', the returned object will have a property _compat (or key if given) set to override' value.

    var defaults = {
      method: 'GET',
      responseType: 'text'
    }
     
    console.log(eoc(defaults, {
      method: 'POST',
      url: 'http://some.domain.tld'
    }))
    // --> { method: 'POST', url: 'http://some.domain.tld', responseType: 'text' }
     
    console.log(eoc(defaults, 'http://some.domain.tld'))
    // --> { method: 'GET', responseType: 'text', _compat: 'http://some.domain.tld' }
     
    console.log(eoc(defaults, 'http://some.domain.tld', 'url'))
    // --> { method: 'GET', responseType: 'text', url: 'http://some.domain.tld' }

    Testing/Building

    Installing development dependencies

    $ npm install
    

    Running tests

    $ npm test
    

    Building for the browser

    $ npm run build
    $ # for building on file change
    $ npm run watch
    

    License

    MIT license, see LICENSE.

    Install

    npm i eoc

    DownloadsWeekly Downloads

    5

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • reg4in