describe

Module to describe objects or sets of data

Describe an array of objects

Most commonly, object.describeObjects(collection, options) is used - as it describes with the appropriate type for each property.

Note, if there are multiple child objects within the collection, object.flatten() will bring those values down through dot notation (similar to arrow format) - so they can be better described.

Classes

BooleanDescription
DateDescription
NumberDescription
SeriesDescription
StringDescription

Methods

(static) describeBoolean(collection, options) → {BooleanDescription}

See:
  • module:format.parseBooleanValue

Describes a series of boolean values.

Note, that the following are considered TRUE:

  • Boolean true
  • Number 1
  • String TRUE
  • String True
  • String true
Parameters:
Name Type Description
collection Array.<Boolean> | Array.<String> | Array.<Number>

Array of Boolean Values

options Object

options for describing boolean values

Returns:
Type
BooleanDescription

(static) describeDates(collection, options) → {DateDescription}

Describes a series of Date / Epoch Numbers

Parameters:
Name Type Description
collection Array.<Date> | Array.<Number>

Array of Dates / Epoch Numbers

options Object

options for describing dates

Returns:
Type
DateDescription

(static) describeNumbers(collection, options) → {NumberDescription}

Describes a series of numbers

Parameters:
Name Type Description
collection Array.<Number>

Array of numbers

options Object

options for describing numbers

Returns:
Type
NumberDescription

(static) describeObjects(collection, options, maxRows) → {Array.<SeriesDescription>}

See:
  • object.flatten() - if the collection of objects have a large number of child objects.

Describes a collection of objects.

For example, given the following collection:

 collection = [{
     first: 'john',
     last: 'doe',
     age: 23,
     enrolled: new Date('2022-01-01')
   }, {
     first: 'john',
     last: 'doe',
     age: 24,
     enrolled: new Date('2022-01-03')
   }, {
     first: 'jan',
     last: 'doe',
     age: 25,
     enrolled: new Date('2022-01-05')
   }];

Running utils.describe.describeObjects(collection); gives:

[{
    "count": 3,
    "max": "john",
    "min": "jan",
    "top": "john",
    "topFrequency": 2,
    "type": "string",
    "unique": 2,
    "what": "first"
  }, {
    "count": 3,
    "max": "doe",
    "min": "doe",
    "top": "doe",
    "topFrequency": 3,
    "type": "string",
    "unique": 1,
    "what": "last"
  }, {
    "count": 3,
    "max": 25,
    "min": 23,
    "mean": 24,
    "stdDeviation": 0.816496580927726,
    "type": "number",
    "what": "age"
  }, {
    "count": 3,
    "max": "2022-01-05T00:00:00.000Z",
    "min": "2022-01-01T00:00:00.000Z",
    "mean": "2022-01-03T00:00:00.000Z",
    "type": "Date",
    "what": "enrolled"
}]

Or Rendered to a table: utils.table(results).render():

what type count max min mean top topFrequency unique
first string 3 john jan john 2 2
last string 3 doe doe doe 3 1
age number 3 25 23 24
enrolled Date 3 2022-01-05T00:00:00.000Z 2022-01-01T00:00:00.000Z 2022-01-03T00:00:00.000Z

Note, if there are multiple child objects within the collection, object.flatten() will bring those values down through dot notation (similar to arrow format) - so they can be better described.

Parameters:
Name Type Description
collection Array.<Object>

Collection of objects to be described

options Object

options to be used

Properties
Name Type Description
include Array.<String>

string list of fields to include in the description

exclude Array.<String>

string list of fields to exclude in the description

overridePropertyType Object

object with property:type values (string|number|date|boolean) - that will override how that property is parsed.

maxRows Number

max rows to consider before halting

Returns:
  • collection of descriptions - one for each property
Type
Array.<SeriesDescription>

(static) describeStrings(collection, options) → {StringDescription}

Describes a series of numbers

Parameters:
Name Type Description
collection Array.<String>

collection of string values to describe

options Object

options for describing strings

Returns:
  • Description of the list of strings
Type
StringDescription

Type Definitions

DescribeOptions

Properties:
Name Type Description
uniqueStrings Boolean

whether unique strings / frequency should be captured

Type:
  • Object