commonMain.Each.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selection Show documentation
Show all versions of selection Show documentation
A collection of drawing/charting utilities
The newest version!
package com.juul.krayon.selection
import com.juul.krayon.element.Element
/**
* See analogous [d3 function](https://github.com/d3/d3-selection#selection_each).
*
* Note that this serves triple-duty for [d3 attr](https://github.com/d3/d3-selection#selection_attr)
* and [d3 style](https://github.com/d3/d3-selection#selection_style) due to strong typing and a lack
* of CSS, respectively.
*/
public inline fun > S.each(
crossinline action: E.(Arguments) -> Unit,
): S {
val arguments = Arguments.Buffer()
groups.forEach { group ->
group.nodes.forEachIndexed { index, node ->
node?.action(arguments(node.data as D, index, group.nodes))
}
}
return this
}