This is Charming1. For Charming2, go to charmingjs.org. This is v1. For v2, go to charmingjs.org.

Array

Array generation and manipulation.

cm.range(count[, start[, end]])

Returns an array of exactly count uniformly-spaced values between start and end. If start is not specified, it defaults to 0. If end is not specified, it defaults to 1.

cm.range(10); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
cm.range(10, 5); // [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5]
cm.range(10, 5, 55); // [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]

cm.cross(…arrays)

Returns the [Cartesian product](Cartesian product) of the specified arrays.

cm.cross([1, 2, 3], [1, 2]); // [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2]]

cm.extent(array[, accessor])

Returns the minium and maximum value in given array using natural order.

cm.extent([4, 3, 2, 2, 7, 3, 5]); // [2, 7]

If an optional accessor function is specified, the extent is computed after calling array.map function.

cm.extent(people, (d) => d.age); // [10, 30]