Notwithstanding Precautions, Misadventure

    @rentpath/hive-config

    1.1.4 • Public • Published

    hive-config

    Utilities for managing configuration objects in Node.js applications.

    API Reference

    merge(target, ...[sources])

    Recursively merges own and inherited string keyed properties of source configuration objects into a destination object. Special handling is given to any property whose value is a function, and whose key beings with $, which will be called as a resolver function with the previous value of the property as an argument. The return value is used as the merged property value.

    const obj1 = {
      foo: 'foo',
    }
     
    const obj2 = {
      $foo: prev => `${prev} bar`
    }
     
    merge({}, obj1, obj2)
    // -> { foo: 'foo bar' }

    combine(target, ...[sources])

    Recursively merges own and inherited string keyed properties of source configuration objects into a destination object, but with special handling for arrays. If both the source and the target are arrays, then the two arrays are combined.

    const obj1 = {
      items: [1],
    }
     
    const obj2 = {
      items: [2],
    }
     
    combine({}, obj1, obj2)
    // -> { items: [1, 2] }

    compile(context, ...[configs])

    A configuration resolver that iterates over a set of configs, and for each config that evaluates to a function, calls it with a provided context argument. The returned value(s) for each config are returned.

    const config1 = {
      foo: 'foo',
    }
     
    const config2 = ctx => ({
      foo: ctx.foo,
    })
     
    compile({ foo: 'bar' }, config1, config2)
    // -> [{ foo: 'foo' }, { foo: 'bar' }]

    Keywords

    none

    Install

    npm i @rentpath/hive-config

    DownloadsWeekly Downloads

    1

    Version

    1.1.4

    License

    MIT

    Unpacked Size

    6.89 kB

    Total Files

    8

    Last publish

    Collaborators

    • cubbyjs
    • vlucas
    • kaborso
    • helveticascenario
    • orionstein
    • rentpath-admin
    • lfender6445
    • tadjohnston
    • ninomichaels
    • plifshiz
    • kevinolson
    • mneumark83
    • patmfitz
    • verydanny