Turn function into arrow function#32
Turn function into arrow function#32loucyx wants to merge 1 commit intodevelopit:masterfrom vangware:master
Conversation
|
I also noticed that if we use export default (obj, path, def, undef) => {
path = path.split ? path.split(".") : path;
path.some(key => !(obj = obj ? obj[key] : undef));
return obj === undef ? def : obj;
};export default((a,b,c,d)=>(b=b.split?b.split("."):b,b.some(b=>!(a=a?a[b]:d)),a===d?c:a));Then again, maybe is a performance thing. |
Hmm, did you use |
|
@RReverser maybe making a PR to microbundle so the "module" build preserves the ES6 syntax instead of turning it into ES5? Also, even using microbundle, the other option I mentioned in #32 (comment) has a smaller size: export default function(t,n,e,r){return(n=n.split?n.split("."):n).some(function(n){return!(t=t?t[n]:r)}),t===r?e:t}And if you have and object like |
|
This library targets IE9+, so we can't rely on |
|
Sorry @developit, I never take IE into consideration. My bad! .... Closing then! |
Using an arrow function instead of a function the source is smaller, and also the minified code:
I'll understand if there is a reason related to performance or similar to not use an arrow function, but I'm making a PR if you consider this to be a good change 😄