Hey peeps. Wrote this function the other day, and found it super useful, so thought I'd shared.
Sketch import, layer referencing
What it's good for:
Accessing imported layer children via dot notation, while maintaining layer hierarchy.
How to use:
1) Copy and paste code into your project
2) Call 'createChildrenRefs()' on any imported layer. I prefer calling it on a root level layer. E.g. myImportedLayer.createChildrenRefs()
Wanted a way to access imported children layers hierarchically, without having to constantly use the childrenWithName method. I was also tired of having to lookup layers by their uniquely assigned name (e.g. btn1, btn2, btn3). This keeps it a lot cleaner and truer to my Sketch layer naming and hierarchy conventions. Note: This doesn't currently check for object property conflicts. As an example, not sure what will happen if you name one of your sketch layers "width", lol. Use with caution. :D