flow-fp
v1.0.0
Published
Provide flow function for js/node. Handles async progress, exception throwing, conditional call, branching
Downloads
4
Maintainers
Readme
FLOW (Functional Programming)
flow(...funcs)
flow.and(...conditions)
flow.overEvery(...conditions)
flow.or(...conditions)
flow.overSome(...conditions)
flow.eq(value)
flow.equalTo(value)
flow.lt(value)
flow.lessThan(value)
flow.lessThanOrEqualTo(value)
flow.le(value)
flow.gt(value)
flow.greaterThan(value)
flow.ge(value)
flow.greaterThanOrEqualTo(value)
flow.ne(value)
flow.notEqualTo(value)
flow['?'] => parameter placeholder
flow.prop(propName1, propName2, propName3...)
flow.prop('methodName1()', 'methodName2()', ...)
flow.prop('toUpperCase()', 'substr(...)', [0, 2])
flow.invoke(methodName, ...args) => value[methodName](...args)
flow.invoke(func, ...args) => func(value, ...args)
flow.always(literal)
flow.push(...values)
flow.unshift(...values)
flow.first()
flow.last()
flow.sort(sorter)
flow.format(stringTemplateWithPlaceholder) => 'Hello {0} and {1}!!!'
flow.formatHello ${x => x.name}!!!
flow.spread()
flow.select([selector1, selector2, selector3, ...]) => [result1, result2, result3]
flow.select({ prop1: selector1, prop2: selector2, ... }) => { prop1: result1, prop2: result2 }
flow.select('prop.path.1', selector1, 'prop.path.2', selector2) => { prop: { path: {1: result1, 2: result2} } }
flow.when().case(value1, case1).case(value2, case2).else(elsePart)
flow.when(conditional).case(value1, case1).case(value2, case2).else(elsePart)
flow.when().case(true, thenPart)
flow.when(conditional).case(true, thenPart)
flow.when().case(false, elsePart)
flow.when(conditional).case(false, elsePart)
flow.when().then(thenPart)
flow.when(conditional).then(thenPart)
flow.unless(elsePart)
flow.catch(handleError)
flow.await(lazyMethod, handleFail)
flow.not(expression)
flow.path(...paths) => flow.path('name', 'displayName')({ name: null, displayName: 'has-value' }) => 'has-value'
Support some standard built-in object methods
flow.filter
flow.map
flow.reduce
flow.reduceRight
flow.slice
flow.some
flow.every
flow.substr
flow.substring
flow.indexOf
flow.includes
flow.match
flow.entries
flow.flat
flow.flatMap
flow.find
flow.findIndex
flow.join
flow.keys
flow.lastIndexOf
flow.values
flow.toLowerCase
flow.toUpperCase
flow.charAt
flow.charCodeAt
flow.concat
flow.endsWith
flow.startsWith
flow.padEnd
flow.padStart
flow.repeat
flow.replace
flow.search
flow.split
flow.trim
flow.trimEnd
flow.trimStart
Chaining method call
flow.prop('name.toUpperCase()').eq('HELLO WORLD')