paldepind / flyd

The minimalistic but powerful, modular, functional reactive programming library in JavaScript.
MIT License
1.56k stars 85 forks source link

curryN code duplication #27

Closed queckezz closed 9 years ago

queckezz commented 9 years ago

I peaked into the source of flyd today. One thing I noticed that there is a curryN implementation which seems to be exactly the same as the one from ramda. If one uses ramda already, there is quite some code duplication.

Why did you choose to copy it into source instead of requiring the function? If it's an altered version maybe there's potential to merge it back into ramda?

var curryN = require('ramda/src/curryN')

Also I think the boilerplate in the source belongs to a build step:


(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory); // AMD. Register as an anonymous module.
  } else if (typeof exports === 'object') {
    module.exports = factory(); // NodeJS
  } else { // Browser globals (root is window)
    root.flyd = factory();
  }
}(this, function () {

We could use something like browserify to make a final bundle for those who aren't using require() on the client and distribute that:

browserify lib/index.js --standalone > flyd.js

Just my 2¢! All in all a seriously awesome library :) I'm also looking forward to play around with snappdom ;)

StreetStrider commented 9 years ago

@queckezz, for such kind of situations the main reason is trying to keep this state of package.json:

  "dependencies": {
  },

:)

paldepind commented 9 years ago

I guess you missed this comment:

// Own curry implementation snatched from Ramda
// Figure out something nicer later on

;)

I did that to keep the dependencies at zero like @StreetStrider suggested. Depending directly on Ramda's curryN like I've done here and doing a nice browser build is on my todo list!

In other words I agree with you! I'll take a look at the --standalone option for browserify. It sounds like exactly what we'd need!