{"id":16567734,"url":"https://github.com/varkor/siteswap","last_synced_at":"2025-04-04T22:13:00.749Z","repository":{"id":57362046,"uuid":"84665747","full_name":"varkor/siteswap","owner":"varkor","description":"A siteswap library for JavaScript.","archived":false,"fork":false,"pushed_at":"2019-01-04T11:18:46.000Z","size":28,"stargazers_count":1,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T11:38:54.234Z","etag":null,"topics":["juggling","parser","siteswap","validator"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varkor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-11T16:57:31.000Z","updated_at":"2024-10-18T22:05:13.000Z","dependencies_parsed_at":"2022-09-26T16:41:03.292Z","dependency_job_id":null,"html_url":"https://github.com/varkor/siteswap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varkor%2Fsiteswap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varkor%2Fsiteswap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varkor%2Fsiteswap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varkor%2Fsiteswap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varkor","download_url":"https://codeload.github.com/varkor/siteswap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256116,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["juggling","parser","siteswap","validator"],"created_at":"2024-10-11T21:07:21.581Z","updated_at":"2025-04-04T22:13:00.723Z","avatar_url":"https://github.com/varkor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# siteswap\n*siteswap* is a JavaScript library for parsing, validating, analysing and manipulating siteswaps, a succinct notation for juggling patterns.\n\n## Example\n```javascript\nconst readline = require(\"readline\");\nconst { Siteswap } = require(\"siteswap\");\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.question(\"Enter a siteswap: \", (input) =\u003e {\n\ttry {\n\t\tconst siteswap = new Siteswap(input);\n\t\tif (siteswap.valid) {\n\t\t\tconsole.log(`${siteswap.pattern} is a period-${siteswap.period} pattern, juggled with ${siteswap.cardinality} prop${siteswap.cardinality !== 1 ? \"s\" : \"\"}.`);\n\t\t} else {\n\t\t\tconsole.log(`${input} is an invalid siteswap!`);\n\t\t}\n\t} catch (error) {\n\t\t// Catch any syntax errors and handle them differently to simply invalid siteswaps.\n\t\tconsole.log(`\"${input}\" is not a siteswap!`);\n\t}\n\trl.close();\n});\n```\n\n## Motivation\nThe aim for this project was to create an open-source library for siteswap validation that handled the entire range of siteswaps. Many siteswap validators stumble when it comes to the more esoteric notation like `!`, which is really only useful for asynchronous-to-synchronous transitions. Additionally, after having formulated a method for validating theoretical siteswaps – with both throws, and quantities, of negative values – an easy way to allow anyone to experiment with them seemed a nice opportunity. So many people write their own siteswap parsers because there aren't any that meet their needs already that it seemed that someone should sit down and write a complete one for once.\n\n## Installation\nInstallation is easy. First, install via npm, and check everything is working:\n```bash\nnpm install siteswap\nnpm test\n```\nYou can try it out using `examples/prompt.js`:\n```bash\nnode examples/prompt.js\n```\nTo use it as a library, simply include it in your project:\n```javascript\nconst { Siteswap } = require(\"siteswap\");\n```\n\n## Usage\n```javascript\nnew Siteswap(pattern, [options])\n```\n### Options\nProperty | Possible values | Default | Description\n--- | --- | --- | ---\n`allowTheoreticalPatterns` | `true` or `false` | `false` | Validates theoretical siteswaps, including those with negative throw values, and negative action quantities (allowing for negative-period patterns).\n`maximumLength` | Integer | `100` | Limits the state-range of the siteswap (the maximum range of the minimum occupied beat to the maximum occupied beat at any state). Validation time is proportional to the state-range, so it can be useful to cap this when performance matters.\n\n## `Siteswap` Reference\nEach `Siteswap` instance contains a collection of the following properties.\n\nProperty | Possible values | Present | Description\n--- | --- | --- | ---\n`valid` | `true` or `false` | Always | Whether the siteswap is a valid siteswap. Theoretical siteswaps are valid only if `allowTheoreticalPatterns: true` has been passed as an option.\n`pattern` | String | Always | The pattern passed to the constructor, modulo some reformatting (such as removing whitespace, and converting to lowercase). `\"ε\"` is used to represent the empty input.\n`normalised` | String | If valid | A normalised pattern (see **Terminology**).\n`period` | Integer | If valid, or period-0 | The period of the siteswap. Note that all period-0 siteswaps are invalid.\n`cardinality` | Integer | If valid | The number of props used in the siteswap.\n`ground` | `true` or `false` | If valid | `true` if the siteswap is a ground-state siteswap.\n`excited` | `true` or `false` | If valid | `true` if the siteswap is an excited-state siteswap (equivalently: if the siteswap is not a ground-state siteswap).\n\n## Terminology\nFor the most part, the terminology used in `siteswap` is consistent with standard nomenclature. However, there are some terms it is useful to define, which have not seen widespread use before this point. To clarify some of the terminology used in the source code, it is useful to provide a brief reference:\n\nTerm | Meaning\n--- | ---\nEvent | An event is an operation on a single prop (what might be loosely classified as a \"throw\"). For example, a `7` is an event, and `[64]` contains two events.\nAction | An action is a set of events performed on the same beat. For example, `[64]` is an action containing two events.\nChain | A chain of events of actions is that same event or action, repeated a certain number of times. For example, in `7 4^2`, there is a chain of one `7`s followed by a chain of two `4`s.\nNormalised | A siteswap is normalised if it satisfies the following four properties: \u003cli\u003e `0` may only occur as a singleton action (i.e. `0` may not occur within a multiplex: `0` is a placeholder symbol) \u003cli\u003e events are ordered from least to greatest within each action (e.g. `[346]`, not `[634]`); \u003cli\u003e any identical adjacent chains of actions or events are combined, summing their quantities (e.g. `b 4^3 4 4^2` is reduced to `b 4^6`); \u003cli\u003e all quantities are non-zero (e.g. `7^0` is disallowed); \u003cli\u003e the siteswap has minimal period (e.g. `744`, not `744744`).\nCanonicalised | A siteswap is canonicalised is if it normalised and all quantities are positive (e.g. `7^-1` is disallowed).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarkor%2Fsiteswap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarkor%2Fsiteswap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarkor%2Fsiteswap/lists"}