millermedeiros / amd-utils

modular JavaScript utilities written in the AMD format
http://millermedeiros.github.com/amd-utils
142 stars 11 forks source link

move `lang/bind` to "function" package? #56

Closed millermedeiros closed 12 years ago

millermedeiros commented 12 years ago

before we didn't have the "function" package.. now it fells weird to require the bind method from the lang package even tho the bind is used to solve scope issues related to the "language".

maybe create an alias like:

// function/bind.js
define(['../lang/bind'], function(bind){
  return bind;
});

this can also be "solved" with the RequireJS map config, so no need for an extra file or changes in the lib:

require.config({
  map : {
     '*' : {
       'amd-utils/function/bind' : 'amd-utils/lang/bind'
     }
  }
});

not a big deal and I'm not even sure if the correct place would be inside the function package, both or just keep it inside lang...

PS: I had the same question about lang/clone since the original need was to deep clone objects, than I realized it was also useful/needed for Array/Date/RegExp, so I decided to just keep it inside lang.

conradz commented 12 years ago

I would prefer the bind function to be in the function package. If anyone needs backwards compatibility, they can use the RequireJS map config. Although if they import the complete lang package and then use lang.bind, it still won't exist. It really shouldn't be hard to do a search and replace to update all the usages.

millermedeiros commented 12 years ago

@conradz thanks for the feedback, I also think we should move it to the function package.