API Reference

Shawn Allen edited this page Nov 17, 2013 · 2 revisions
Clone this wiki locally

# dtools.property(key[, name])

Create a function returns the named property of its first argument. TODO

# dtools.summarize()

Creates a new summary function that returns statistics about an array of values. Summaries can be configured with the following methods:

# summary.properties(properties)

Configure the summary to generate keys for the provided properties. Properties can be provided in any form compatible with dtools.property. So:

var summarize = dtools.summarize()
  .properties(["foo"])
  .stats(["min"]);
summarize([{foo: 1}, {foo: 2}]);
// {foo: {min: 1}}

# summarize(array)

Generate a summary from an array of values. TODO

# dtools.identity()

The identity function returns its first argument.

dtools.identity(5)
// 5

# dtools.index()

The index function returns its second argument, which is a convention used in d3 and most JavaScript Array iteration functions.

[5, 4, 3, 2, 1].map(dtools.index)
// [0, 1, 2, 3]