-
Notifications
You must be signed in to change notification settings - Fork 5
Core API #4
Comments
totally agree |
Are they really? Enlighten us. Got some examples of places you use |
Yep, I those set methods are pretty common (I use them in my own code regularly). |
My thoughts on the current state Strongly in favour of +indexOf
+lastIndexOf
+now
+omit
+max
+min
+drop
+take
+first
+last
+restParam
+negate If we're sharing core features and keeping both project identities for now (#6) -chain
-iteratee Borderline. I'm not sure if these belong +union
+intersection
+difference
-memoize
-compose |
Memoize is much better handled in idiomatic JS (the Underscore API isn't great for it). |
They're convenient for cases where |
How often do you use them outside of chaining though? I'd wager you almost always want to do |
I actually use Agree with removing |
Lodash split Since the goal is a small core we should err on the side of less, it can always expand later (if needed).
To my earlier comment while |
Update: Update: Updates (July 15):
Next up I'm creating the smaller core. As for the smaller core I'm currently keeping things as-is for the npm package. This means kitchen sink and modules as usual for node folks. The smaller core build will come in to play for the bower/component packages and site downloads. |
Will those still be available in some form? The reason I went from underscore to lodash in the first place was deep clone. 😆 Maybe not the main reason I migrated ( Either way, I'm really excited about where you're taking this, keep up the awesome work! |
|
Ah, nice! Never was a fan of boolean params anyway. Perfect solution. Thanks for the swift response! No idea how I didn't notice it before... |
i noticed |
Correct, recursive assignment is what _.merge is for. |
@jdalton ah, thanks for clearing it up |
Ok so here's the 58 methods I've gotten to include in the 4kb build which should still support Backbone: ["before", "bind", "chain", "clone", "compact", "defaults", "defer", "delay", "escape",
"every", "extend", "filter", "find", "first", "flatten", "flattenDeep", "forEach",
"functions", "has", "identity", "indexOf", "invoke", "isArguments", "isArray", "isDate",
"isEmpty", "isEqual", "isFinite", "isFunction", "isObject", "isRegExp", "isString",
"iteratee", "keys", "keysIn", "last", "map", "max", "min", "mixin", "negate",
"noConflict", "noop", "now", "once", "pick", "reduce", "result", "size", "slice",
"some", "sortBy", "tap", "thru", "toArray", "uniqueId", "value", "values"] |
@jdalton Out of curiosity: what's the rationale for this? |
To keep the API clean and focused. |
"Penny wise and dollar foolish", as my dad would say... |
Sometimes aliases are great but having close to 20 of them is a bit much. Reducing the aliases also helps devs grok the API so they don't have to map for example that |
But some of those aliases read better in real code than their canonical names ( There's real fat trimming to be done in Lo-Dash and Underscore. Killing 20 aliases isn't really the problem. |
I dig favoring those with JS lang precedents over Ruby since this is a JS lib and devs are more likely to be familiar with the JS names.
Fat trimming is a different issue which is tackled by other line items. Reducing aliases is more about ensuring a more focused, uniform, & grokkable API. In addition, a subtle issue I've seen with aliases is that devs reach for them not knowing which is the primary/preferred API and end up with dependencies which just point to others adding extraneous scaffolding for browserfiy/webpack bundles. |
I'm for getting rid of aliases. Each function should have a single canonical name. If you want to use an alias, use underscore like this: import _, {some, some as any} from "underscore"; |
That's not the point at all. But fine. Killing aliases is the definition of bikeshedding. Don't we have some actual culling to do? |
On my end I've created a 4kb lodash core build. |
The WIP core build is up. The core build is composed of methods required by Backbone and others I could fit into 4kb gzipped. I got the file size down by removing deep path look ups, removing placeholder support, removing array and method composition optimizations, and removing features from |
💯 Very nice! |
I think some of those 'aliases' were well established long before Lodash (e.g. head, tail, etc.), no? It would be a shame for someone coming from FP land would have to learn new terms here? |
They are rooted in other langs and I'm OK with dropping them. This is JS (this is Spartaaaa) I'm fine with folks learning alternative APIs. |
Two thoughts.
_.alias({reduce: 'foldl', some: 'any'}); (This itself can be written as a mixin, if need be.)
|
You mean this... :) |
Exactly! Any comments on whether an |
I think use of _.mixin({foldl: _.reduce, any: _.some}); |
_.mixin({ alias: _.mixin }); 😅 |
The suggested API for
|
Continuing to reduce overloaded methods I've split out |
I've gotten the 4kb core build tested via our CI now. Since June there's been ~700 commits which is pretty active development. It's like squeezing ~3yrs of Underscore development into ~6 months. |
@jdalton I realize it's not yet officially published/released, right? But would it be ok, if I would have latest code in file, and I would try to replace underdash in Backbone app to replace underscore, and another project to replace lodash, so that to test if my app work :) Kinda code testing for free :) |
Lodash v4 release notes! |
Closed by #14. |
Just briefly glancing through the “Core” and “More” functions, I think
difference
andintersection
should be in the core, as they are used very commonly.The text was updated successfully, but these errors were encountered: