config-brick 3.0
use standard brick function to build complex config easier
install
yarn add config-brick# or npm install config-brick
use with sync functions
const fn0 = { console}const fn1 = { confa = 1}const fn2 = { confb = 2 return conf}const fn3 = { confc = 3 return d: 4 }const fn4 = 3
pipe
lay function, like a const lay = const conf1 = // {} // use initial value,default is {}const conf2 = initial: 'this is a initial seed' // {initial:'this is a initial seed'}// with no returned function,it will use pre resultconst conf3 = // {a:1}const conf4 = // {a:1,b:2}const conf5 = // {d:4} because fn3 return {d:4}const conf6 = // {} fn4 not a function,return pre result
use with Async Function
// notice should resolved a function,not the conf valueconst fn5 = { // give a name,for debug const fn5Brick = { confe = 5 } // this is function } const fn6 = { const fn6Brick = { conff = 6 return conf } }
use lay with async function
const lay = // detect it has async function ,so p will be a Promise instanceconst p = p
you can mix sync function and async function,that's ok
const p = p
with control flow
const when lay = const conf = // {a:1,b:2} const p1 = p1
pipe
const pipe = // pipe function is like `lay`,but this only support sync function, // {a:1,b:2} // Error
pipeAsync
const pipeAsync = // pipeAsync function is like `lay`,but it will always return a Promiseconst p = // it will be a Promisep
merge
const merge = // notice here is,merge(right value)(left value),data always last a: 2 b: 2 // -> {a:1,b:[1,2]}