You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe this is just due to my own peculiar habits for implementing route handlers, or maybe this would be useful to everyone. I'll let you be the judge of that!
Anyhow, it would be nice to have built-in way to iterate every path in the pathSet passed to a route handler. For example something like this:
Here's my implementation for example, which I've been using in all my route handlers.
exportfunction*all(pathSet,pointer=0,path=[]){if(pointer>=pathSet.length){yieldpath.slice();}else{constthing=pathSet[pointer];for(constxofiterateThing(thing)){path.push(x);yield*all(pathSet,pointer+1,path);path.pop();}}}function*iterateThing(thing){if(Array.isArray(thing)){for(constsubthingofthing){yield*iterateThing(subthing);}}elseif(isRange(thing)){const{ from, to }=thing;for(leti=from;i<=to;i++){yieldi;}}else{yieldthing;}}functionisRange(thing){returnthing&&typeofthing.from==='number';}
The text was updated successfully, but these errors were encountered:
Yes, that is essentially how the walkPath works as well. This could be useful. It would more than likely be put into the falcor-path-utils repo. Its useful.
Thanks for the response. I haven't looked much into falcor-path-utils, I'll have to check it out. Will it be attached as a method ala pathSet.all(), or is the idea for people to import falcor-path-utils and use it in their route handlers?
Maybe this is just due to my own peculiar habits for implementing route handlers, or maybe this would be useful to everyone. I'll let you be the judge of that!
Anyhow, it would be nice to have built-in way to iterate every path in the
pathSet
passed to a route handler. For example something like this:Here's my implementation for example, which I've been using in all my route handlers.
The text was updated successfully, but these errors were encountered: