ramda-fn-bind
v1.0.6
Published
Enables chained lodash functions with ES bind (::) syntax
Downloads
5
Maintainers
Readme
lodash-fn-bind
transform all lodash function to bindable function, with ec39 proposal new function bind syntax (::), you can do code fly.
npm:
https://www.npmjs.com/package/lodash-fn-bind
install:
yarn add lodash-fn-bind
just a look:
import { cat } from 'shelljs'
import date from 'date.js'
import { format } from 'date-fns/fp'
import logger from '../util/logger'
import { IS_PROD } from '../constant'
import { renameKeys } from 'ramda-adjunct'
import { _map, _filter, _uniqBy, _tap, } from 'lodash-bound'
import { take, tryCatch, pluck, always, has, omit, allPass } from 'ramda'
const YESTERDAY = format('yMMdd', date('yesterday'))
const requestLogs = (IS_PROD ? '/usr/local/nginx/logs' : __dirname)
|> cat(`${#}/access.log-${YESTERDAY}`).split('\n')
::_map(tryCatch(JSON.parse, always({})))
::_filter({ status: '200' }) // = R.filter(R.propEq('status', '200'))
::_map('body') // = R.pluck('body')
::_map(tryCatch(JSON.parse, always({})))
::_filter(allPass([has('service'), has('__openid')]))
::_map(omit(['channel', 'format', 'oper', 'random', 'spid', 'sign', 'userId', '__patientId']))
::_map(renameKeys({ service: 'apiname' }))
::__uniqBy('__openid') // = R.uniqBy(R.prop('apiname'))
::_tap(xn => logger.log('get log count %d,the first is %j:', xn.length, take(1, xn)))
all available functions:
// if you want, you can do this (crazy!):
foo
::_add()
::_after()
::_ary()
::_assign()
::_assignIn()
::_assignInWith()
::_assignWith()
::_at()
::_attempt()
::_before()
::_bind()
::_bindAll()
::_bindKey()
::_camelCase()
::_capitalize()
::_castArray()
::_ceil()
::_chain()
::_chunk()
::_clamp()
::_clone()
::_cloneDeep()
::_cloneDeepWith()
::_cloneWith()
::_compact()
::_concat()
::_cond()
::_conforms()
::_conformsTo()
::_constant()
::_countBy()
::_create()
::_curry()
::_curryRight()
::_debounce()
::_deburr()
::_defaults()
::_defaultsDeep()
::_defaultTo()
::_defer()
::_delay()
::_difference()
::_differenceBy()
::_differenceWith()
::_divide()
::_drop()
::_dropRight()
::_dropRightWhile()
::_dropWhile()
::_each()
::_eachRight()
::_endsWith()
::_entries()
::_entriesIn()
::_eq()
::_escape()
::_escapeRegExp()
::_every()
::_extend()
::_extendWith()
::_fill()
::_filter()
::_find()
::_findIndex()
::_findKey()
::_findLast()
::_findLastIndex()
::_findLastKey()
::_first()
::_flatMap()
::_flatMapDeep()
::_flatMapDepth()
::_flatten()
::_flattenDeep()
::_flattenDepth()
::_flip()
::_floor()
::_flow()
::_flowRight()
::_forEach()
::_forEachRight()
::_forIn()
::_forInRight()
::_forOwn()
::_forOwnRight()
::_fromPairs()
::_functions()
::_functionsIn()
::_get()
::_groupBy()
::_gt()
::_gte()
::_has()
::_hasIn()
::_head()
::_identity()
::_includes()
::_indexOf()
::_initial()
::_inRange()
::_intersection()
::_intersectionBy()
::_intersectionWith()
::_invert()
::_invertBy()
::_invoke()
::_invokeMap()
::_isArguments()
::_isArray()
::_isArrayBuffer()
::_isArrayLike()
::_isArrayLikeObject()
::_isBoolean()
::_isBuffer()
::_isDate()
::_isElement()
::_isEmpty()
::_isEqual()
::_isEqualWith()
::_isError()
::_isFinite()
::_isFunction()
::_isInteger()
::_isLength()
::_isMap()
::_isMatch()
::_isMatchWith()
::_isNaN()
::_isNative()
::_isNil()
::_isNull()
::_isNumber()
::_isObject()
::_isObjectLike()
::_isPlainObject()
::_isRegExp()
::_isSafeInteger()
::_isSet()
::_isString()
::_isSymbol()
::_isTypedArray()
::_isUndefined()
::_isWeakMap()
::_isWeakSet()
::_iteratee()
::_join()
::_kebabCase()
::_keyBy()
::_keys()
::_keysIn()
::_last()
::_lastIndexOf()
::_lowerCase()
::_lowerFirst()
::_lt()
::_lte()
::_map()
::_mapKeys()
::_mapValues()
::_matches()
::_matchesProperty()
::_max()
::_maxBy()
::_mean()
::_meanBy()
::_memoize()
::_merge()
::_mergeWith()
::_method()
::_methodOf()
::_min()
::_minBy()
::_mixin()
::_multiply()
::_negate()
::_noop()
::_now()
::_nth()
::_nthArg()
::_omit()
::_omitBy()
::_once()
::_orderBy()
::_over()
::_overArgs()
::_overEvery()
::_overSome()
::_pad()
::_padEnd()
::_padStart()
::_parseInt()
::_partial()
::_partialRight()
::_partition()
::_pick()
::_pickBy()
::_property()
::_propertyOf()
::_pull()
::_pullAll()
::_pullAllBy()
::_pullAllWith()
::_pullAt()
::_random()
::_range()
::_rangeRight()
::_rearg()
::_reduce()
::_reduceRight()
::_reject()
::_remove()
::_repeat()
::_replace()
::_rest()
::_result()
::_reverse()
::_round()
::_sample()
::_sampleSize()
::_set()
::_setWith()
::_shuffle()
::_size()
::_slice()
::_snakeCase()
::_some()
::_sortBy()
::_sortedIndex()
::_sortedIndexBy()
::_sortedIndexOf()
::_sortedLastIndex()
::_sortedLastIndexBy()
::_sortedLastIndexOf()
::_sortedUniq()
::_sortedUniqBy()
::_split()
::_spread()
::_startCase()
::_startsWith()
::_stubArray()
::_stubFalse()
::_stubObject()
::_stubString()
::_stubTrue()
::_subtract()
::_sum()
::_sumBy()
::_tail()
::_take()
::_takeRight()
::_takeRightWhile()
::_takeWhile()
::_tap()
::_template()
::_throttle()
::_thru()
::_times()
::_toArray()
::_toFinite()
::_toInteger()
::_toLength()
::_toLower()
::_toNumber()
::_toPairs()
::_toPairsIn()
::_toPath()
::_toPlainObject()
::_toSafeInteger()
::_toString()
::_toUpper()
::_transform()
::_trim()
::_trimEnd()
::_trimStart()
::_truncate()
::_unary()
::_unescape()
::_union()
::_unionBy()
::_unionWith()
::_uniq()
::_uniqBy()
::_uniqueId()
::_uniqWith()
::_unset()
::_unzip()
::_unzipWith()
::_update()
::_updateWith()
::_upperCase()
::_upperFirst()
::_values()
::_valuesIn()
::_without()
::_words()
::_wrap()
::_xor()
::_xorBy()
::_xorWith()
::_zip()
::_zipObject()
::_zipObjectDeep()
::_zipWith()
|> console.log