Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Divisions<T>

A base class that can be used to generate the divisions steps. The divisions is often used as a base class for other classes that expose the divisions as property accessor aliases. The Divisions class implements the IDivisions interface. This class exposes a set of [100, 900] properties that are calculated using a ratio and scale. For each division the value is calculated by passing the previous division, the scaling value and the normal 500 division to the callback. The divisions are calculated outwards from the 500 division and the scale is inverted when calculating the divisions less than `500. The following examples show how the divisions are calculated.

example
Creating delta divisions ```ts class Timing extends Divisions { constructor() { super({ base: 10, scale: (1 as Scale), ratio: (last, ratio) => last + ratio }); } } const timing = new Timing(); timing['100']; // -> 6 // 7 + (-1) timing['200']; // -> 7 // 8 + (-1) timing['300']; // -> 8 // 9 + (-1) timing['400']; // -> 9 // 10 + (-1) timing['500']; // -> 10 // takes the `base` value of `10` timing['600']; // -> 11 // 10 + 1 timing['700']; // -> 12 // 11 + 1 timing['800']; // -> 13 // 12 + 1 timing['900']; // -> 14 // 13 + 1 ```
example
Creating scaled divisions ```ts class Timing extends Divisions { constructor() { super({ base: 12, scale: (2 as Scale), ratio: (last, ratio) => last * (ratio < 0) : 1 / -ratio ? ratio }); } } const timing = new Timing(); timing['100']; // -> 0.75 // 1.5 * 0.5 timing['200']; // -> 1.5 // 3 * 0.5 timing['300']; // -> 3 // 6 * 0.5 timing['400']; // -> 6 // 12 * 0.5 timing['500']; // -> 12 // takes the `base` value of `12` timing['600']; // -> 24 // 12 * 2 timing['700']; // -> 48 // 24 * 2 timing['800']; // -> 96 // 48 * 2 timing['900']; // -> 192 // 96 * 2 ```
example
Overriding divisions ```ts class Timing extends Divisions { constructor() { super({ scale: (1 as Scale), ratio: (last, ratio) => last + ratio, base: { 500: 10, 700: 99 } }); } } const timing = new Timing(); timing['100']; // -> 6 // 7 + (-1) timing['200']; // -> 7 // 8 + (-1) timing['300']; // -> 8 // 9 + (-1) timing['400']; // -> 9 // 10 + (-1) timing['500']; // -> 10 // takes the `500` (base) value of `10` timing['600']; // -> 11 // 10 + 1 timing['700']; // -> 99 // 11 + 1 (overridden with 99, from division overrides) timing['800']; // -> 13 // 12 + 1 timing['900']; // -> 14 // 13 + 1 ```

Type parameters

  • T

Hierarchy

Implements

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new Divisions(__namedParameters: object): Divisions

Accessors

100

  • get 100(): T

200

  • get 200(): T

300

  • get 300(): T

400

  • get 400(): T

500

  • get 500(): T

600

  • get 600(): T

700

  • get 700(): T

800

  • get 800(): T

900

  • get 900(): T

Methods

__@toPrimitive

  • __@toPrimitive(hint: "string" | "number" | "default"): number | string
  • Parameters

    • hint: "string" | "number" | "default"

    Returns number | string