articulate/funky

assocWith not quite currying correctly

rpearce opened this issue · 1 comments

Expected

assocWith('foo', always('bar'), {}) //=> { foo: 'bar' }

Received

assocWith('foo', always('bar'), {}) //=> Function

Current workaround

assocWith('foo', always('bar'))({}) //=> { foo: 'bar' }

Suggested fix

const converge = require('ramda/src/converge')
const curry    = require('ramda/src/curry')
const assoc    = require('ramda/src/assoc')
const identity = require('ramda/src/identity')

// assocWith :: String -> ({ k: v } -> a) -> { k: v } -> { k: v }
const assocWith = (key, fn, obj) =>
  converge(assoc(key), [fn, identity])(obj)

module.exports = curry(assocWith)

got this on my to-do list to submit a PR for