Question: is there a handy method to take a function declaration and make it a function expression?

Asked By
Asked At
2018-02-02 21:37:23

Found 15 possible answers.

User Answered At Possible Answer
ljharb 2018-02-02 21:37:34 wrap it in parens?
loganfsmyth 2018-02-02 21:38:30 I think you can try path.toExpression() or something like that?
wagonofjustice 2018-02-02 21:39:44 shwing
bradleymeck 2018-02-02 21:40:00 @loganfsmyth sometime i need to figure out how to make actually properly handle source maps
loganfsmyth 2018-02-02 21:47:29 handle them how?
bradleymeck 2018-02-02 21:52:59 i generate new things for the AST but my source map didn't seem to be picked up properly by devtools (now turned off in webpack config)
loganfsmyth 2018-02-02 21:53:52 gotcha
wagonofjustice 2018-02-02 22:11:45 hmmm Error: You gave us a visitor for the node type pre but it's not a valid type are there alternatives to babel that do breadth first there's not an option to traverse breadth first rather than depth first is there? but, if I'm not depending on a nested visitor managing state for me, then maybe I don't need a nested visitor at all meaning, pre hooks for nested visitors would that be complicated to implement? I'll have to make some type of callstack for that... would eliminate a lot of the overhead of managing the state although this would be preferable if there was a way to utilize pre hooks in nested visitors and rebundle the state at the enter and exit functions at the appropriate nodes I suppose I could place that logic in, say, the program node
            this.currentScope = new currentScope(state.currentScope)
it has a pre hook in it like: 
pre(state) { in this situation I have one visitor that I tried to call recursively
bradleymeck 2018-02-02 22:59:53 @realisation that would use a lot of memory
wagonofjustice 2018-02-02 23:00:06 how so?
bradleymeck 2018-02-02 23:00:22 depth first lets you only operate on small subgraphs once you dive deep breadth first requires you to always track the entire graph above nodes
wagonofjustice 2018-02-02 23:00:49 yeah hmm. looks like it is what I need, though
bradleymeck 2018-02-02 23:00:54 post order depth first is also pretty much the only way to achieve real map reduce
wagonofjustice 2018-02-02 23:01:14 whats the importance of that
bradleymeck 2018-02-02 23:01:32 lets you do stuff in parallel since subgraphs don't affect eachother

Related Questions