JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 38
  • Score
    100M100P100Q48669F
  • License MIT

Enables chained lodash functions with ES bind (::) syntax

Package Exports

  • lodash-fn-bind

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lodash-fn-bind) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lodash-fn-bind

transform all lodash function to bindable function, with ec39 proposal new function bind syntax (::), you can do this:

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)))