Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Fix currying in production #56

Merged
merged 1 commit into from
Nov 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions src/packages/recompose/createHelper.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import curry from 'lodash/function/curry'

/**
* In production, use lodash's curry and be done
*/
let createHelper = curry

/**
* In development, use custom implementation of curry that keeps track
* of whether enough parameters have been applied. Also adds a `displayName`
* to the base commponent.
*/
if (process.env.NODE_ENV !== 'production') {
const wrapDisplayName = require('./wrapDisplayName')

createHelper = (func, helperName, _helperLength, setDisplayName = true) => {
const helperLength = _helperLength || func.length

const createHelper = (func, helperName, _helperLength, setDisplayName = true) => {
const helperLength = _helperLength || func.length

if (process.env.NODE_ENV !== 'production') {
/**
* In development, use custom implementation of curry that keeps track
* of whether enough parameters have been applied. Also adds a `displayName`
* to the base commponent.
*/
const wrapDisplayName = require('./wrapDisplayName')
const apply = (previousArgs, nextArgs) => {
const args = previousArgs.concat(nextArgs)
const argsLength = args.length
Expand Down Expand Up @@ -46,6 +40,11 @@ if (process.env.NODE_ENV !== 'production') {

return (...args) => apply([], args)
}

/**
* In production, use lodash's curry
*/
return curry(func, helperLength)
}

export default createHelper