There are situations when you want to find a single node by name or id. I don't see any convenient way to do this in KineticJS since Container.find() always returns array. findOne convenience method can be found from DOM API to ORM libraries, so I believe KineticJS should have one too :)
I have added a Container.findOne() convenience method and a simple test. it returns a node or undefined.
Optimized implementation should of course break the find() loop after first match found.
There are situations when you want to find a single node by name or id. I don't see any convenient way to do this in KineticJS since
Container.find()
always returns array.findOne
convenience method can be found from DOM API to ORM libraries, so I believe KineticJS should have one too :)I have added a
Container.findOne()
convenience method and a simple test. it returns a node or undefined.Optimized implementation should of course break the find() loop after first match found.