Created
April 13, 2016 22:56
-
-
Save tjphilli/33875f9b9c4e5265c847ca0b74bc827d to your computer and use it in GitHub Desktop.
Methods to select sublayers of a given layer using substrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This method will return the first resulting child layer containing a specified substring | |
Layer.prototype.childContaining = (str) -> | |
for layer in @children | |
return layer if layer.name.indexOf(str) != -1 | |
return -1 | |
# This method will return an array of child layers containing a specified substring | |
Layer.prototype.childrenContaining = (str) -> | |
layers = [] | |
for layer in @children | |
layers.push(layer) if layer.name.indexOf(str) != -1 | |
return layers | |
# This method will return the first resulting child layer whose name begins with a specified string | |
Layer.prototype.childStartingWith = (str) -> | |
for layer in @children | |
return layer if layer.name.indexOf(str) == 0 | |
return -1 | |
# This method will return an array of child layers whose names begin with a specified string | |
Layer.prototype.childrenStartingWith = (str) -> | |
layers = [] | |
for layer in @children | |
layers.push(layer) if layer.name.indexOf(str) == 0 | |
return layers | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment