Siteswap.analyze()

The analyze() method parses an input string and returns siteswap data.

Syntax

analyze(text)

Parameters

text
A string representing the siteswap pattern.

Return value

An object with the following properties:

count
The number of props for the specified siteswap. For example, if the pattern string is "51", it will be 3.
message
A message string if the pattern is not a valid siteswap.
period
The length of period for the specified siteswap. For example, 4 if the pattern string is "7131", 2 if "(4x,2x)", and so on.
state
A numeric array representing the state of the siteswap. For example, [1, 1, 0, 1] if the pattern string is "51", [2, 1] if "[34]20", and so on.
sync
True if the siteswap is synchronous, false otherwise.
text
The pattern string. Double-byte characters in the argument string are converted to single-byte characters, and uppercase letters are converted to lowercase letters.
throws
An array of numeric arrays converted from the pattern string. For example, [[3]] for pattern string "3" and [[3, 4], [2], [0]] for "[34]20". For synchronous, numbers with "x" are converted to odd numbers, where +1 is added to the left number and -1 to the right number. For example, "(4x,2x)" becomes [[5], [1]].
valid
This property always exists. True if the input string is a valid siteswap, false otherwise.

Examples

const result = jmotion.Siteswap.analyze("531");

// result = {
//     "count": 3,
//     "period": 3,
//     "state": [1, 1, 1],
//     "sync": false,
//     "text": "531",
//     "throws": [
//         [5],
//         [3],
//         [1],
//     ],
//     "valid": true,
// }