Comments (9)
Hi, yeah, my linter also has complained about this...
But as you see, I heavily rely on variables from surrounding closure - it would be a pain to extract this function.
How do you think, if I'll create it like
let forChildren = function(....
will everybody be happy with it?
from deepdash.
The only thing I could think of is to put the function at the root of the parent function as a generator to add additional closures on it.
function genForChildren(options, deps, callback, currentObj, currentParents, /* put other closures here */) {
return function forChildren(children, cp, scp) {
if (children && _.isObject(children)) {
_.forOwn(children, function(childValue, childKey) {
var childPath = (path || []).concat( (cp || []), [childKey]);
var strChildPath =
options.pathFormat == 'array'
? pathToString([childKey], strPath || '', scp || '')
: undefined;
iterate({
value: childValue,
callback: callback,
options: options,
key: childKey,
path: childPath,
strPath: strChildPath,
depth: depth + 1,
parent: currentObj,
parents: currentParents,
obj: obj,
childrenPath: cp,
strChildrenPath: scp,
});
});
}
}
}
and then generate the function when you need it.
const fn = genForChildren(...)
I am sure there are a lot of different ways to this, but I agree this is something of a pain in the "strict" rule for javascript.
from deepdash.
Ok, I will see in a few days what can I do
(hope it's not show stopper for you)
from deepdash.
Currently I had to remove it from my project because I couldn't figure out a way to make it work in my webpack setup :-(
from deepdash.
Do you use deepdash-es with a webpack?
from deepdash.
I have not, I could check. Basically what happened was that our build suddenly broke and I traced it down to this module. I figured it would be good to know on your side and I have looked for a quick fix on my side. Will definitely check the -es version, we were using just "npm install deepdash" but I did not specifically configure webpack to use the es files. Thanks for all your help.
from deepdash.
I don't know if it will help with uglifier, but probably it should:
this 'strict' mode is actually added to cjs build by Rollup, and there is no strict directive in es version.
So hope uglifier will take it easier this time.
Another good reason to use es version is theoretically supported tree shaking.
btw I am going to fix this issue, maybe just by instructing rollup to not make things harder or I'll find some time for refactoring
from deepdash.
Could you, please share your config for uglifyi?
I tried here:
https://skalman.github.io/UglifyJS-online/
and with default options, it works well
If I set strict: true,
it fails on trailing comma in a literal object, not on in scope function declaration.
from deepdash.
Hey, I tried to replace function declaration by assignment it to variable and eslint was satisfied.
I don't think it will help in your case but let's try)
Another solution for you is to adjust uglifier setting and turn 'strict' option off (does it really brings any benefit?)
Anyway, I need to do great refactoring, maybe replace recursion by loop, etc,
so I will not try fix this particular issue, but will keep it in mind)
from deepdash.
Related Issues (20)
- omitDeep changes input on empty array HOT 1
- omitDeep doesn't omit objects HOT 7
- ERR_PACKAGE_PATH_NOT_EXPORTED HOT 3
- how to remove values from json if they exist
- Feature Request Parent path
- filterDeep not working on deeply nested object HOT 2
- Working with promises HOT 2
- Frustrating that things like `pickDeep` and `filterDeep` can only return a nested structure HOT 3
- deepdash-es not working with jest-resolve HOT 9
- deepFilter keep parents
- ESM: IIterateeContext typescript interface not exposed
- findPathDeep doesn't return first Value path
- findDeep or findDeepValue - Return object that contains the key & value
- eachDeep with childrenPath == wrong parent, parent path etc
- Bug in documentation _.findDeep*
- findDeep return types problem HOT 3
- Add contributing docs HOT 1
- findDeep is not a function HOT 1
- explicit return values, why and how does this work HOT 1
- mapValuesDeep mutates the original object if `leavesOnly: false` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdash.