Ranges

The Ranges modifier allows only values within the given ranges of characters. Each range is represented by a minimum character code and a maximum character code.

Types

  • String

Constructor

new Ranges (

ranges: { min: number, max: number }[] = Ranges.AlphaNumeric,

clamp = true,

allowKeyframeValues = true,

rangeStart: number | undefined = undefined,

rangeEnd: number | undefined = undefined,

)

ranges: The list of ranges within which characters are allowed.
clamp: Whether non-whitelisted characters should be clamped to the nearest allowed character or removed from the string.
allowKeyframeValues: Whether or not characters in the values of each keyframe should be whitelisted.
rangeStart: The time at which the modifier begins to modify the curve.
rangeEnd: The time at which the modifier no longer modifies the curve.\


import { Modifiers } from 'curves'; // Import Modifiers

const ranges = new Modifiers.String.Ranges(); // Create a new ranges modifier

The Ranges class contains a static method to facilitate the creation of a range from a minimum character and a maximum character. It also contains predefined ranges for ease of use.

Create Range

static createRange (min: number | string, max: number | string): { min: number, max: number }

min: The minimum character or character code of the range.
max: The maximum character or character code of the range.\


import { Modifiers } from 'curves'; // Import Modifiers

const lowercaseAlpha = Modifiers.String.Ranges.createRange('a', 'z'); // Create a range containing only lowercase letters

Predefined Ranges

AccessorCodeDefinition
Ranges.CapitalAlphaRanges.createRange('A', 'Z')A range that contains only capital letters.
Ranges.LowercaseAlphaRanges.createRange('a', 'z')A range that contains only lowercase letters.
Ranges.NumericRanges.createRange('0', '9')A range that contains numeric characters.
Ranges.AlphaAccentRanges.createRange('À', 'ÿ')A range that contains most of the accented letters.
Ranges.NonControlRanges.createRange(32, 255)A range that every common non-control character.
Ranges.Alpha[ Ranges.CapitalAlpha,
Ranges.LowercaseAlpha ]
A list of ranges containing all letters.
Ranges.AlphaNumeric[ Ranges.CapitalAlpha,
Ranges.LowercaseAlpha,
Ranges.Numeric ]
A list of ranges containing all letters and numbers.