transform object to object array with ramdajs

I am writing a program, counting words in a file.

Suppose the object likes this:

  • limiting side effects when programming javascript in the browser
  • Writing Truly Private Functions in Javascript
  • Extract Javascript data using map(), filter() and concatAll() functions
  • Interpreting output after using callback in javascript
  • Is a nested pure function still a pure function?
  • JavaScript terminology: do I (call / invoke / execute) a function?
  • {
      I: 2,
      it: 4,
      that: 1

    And I wanna make it:

      { word: 'I', count: 2 }, 
      { word: 'it', count: 4 }, 
      { word: 'that', count: 1 }

    I can achieve the goal by using imperative programming: loop the object…

    And I check out the docs and google, but can’t find any method fit in 🙁


  • Removing numerous for loops from Javascript code
  • why this map reduce Promises array does not work, but just reducing it does?
  • Why does bind of the function instance supply the original value to the next computation?
  • whats the difference between function foo(){} and foo = function(){}?
  • Why this implementation of a pure function isn't considered to have external dependencies?
  • Underscore.js: how to chain custom functions
  • One Solution collect form web for “transform object to object array with ramdajs”

    This can be achieved using R.toPairs and R.zipObj:

    //    convert :: {a} -> [{ word :: String, count :: a }]
    const convert = R.compose(['word', 'count'])), R.toPairs);
    convert({I: 2, it: 4, that: 1});
    // => [{"count": 2, "word": "I"}, {"count": 4, "word": "it"}, {"count": 1, "word": "that"}]