# siteswap-generator

> siteswap generator

Latest version **0.2.0** (published 2015-04-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install siteswap-generator
pnpm add siteswap-generator
yarn add siteswap-generator
bun add siteswap-generator
```

Provides the command `siteswap`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-04-21 |
| First published | 2015-01-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Xavier Garcia Buils |
| Maintainers | xgbuils |
| Keywords | siteswap, juggler, juggling, balls, pattern, patterns |

## Links

- npm: https://www.npmjs.com/package/siteswap-generator
- Repository: https://github.com/xgbuils/siteswap-generator
- Issues: https://github.com/xgbuils/siteswap-generator/issues
- npm.io page: https://npm.io/package/siteswap-generator

## Dependencies (1)

- [lazyarray-lite](https://npm.io/package/lazyarray-lite.md) ^0.2.0

## Recent versions

- 0.2.0 (latest) — 2015-04-21
- 0.1.0 — 2015-01-29
- 0.0.2 — 2015-01-29
- 0.0.1 — 2015-01-29

## README

# siteswap-generator

## Siteswap introduction
Siteswap is a juggling notation used to describe or represent juggling patterns. It encodes the number of beats of each throw, which is related to their height, and the hand to which the throw is to be made. However, it does not describe body movements such as behind-the-back and under-the-leg.

A siteswap pattern can be expressed through number sequence that represent a cycle of throws with different heights. These heights must meet certain mathematical rules. For more information, see [siteswap entry](http://en.wikipedia.org/wiki/Siteswap) in wikipedia.

## Description
This module allow to compute the whole patterns with specific number of balls, length of cycle (also called period) and heights. Siteswap generator does not compute patterns that are the same except rotations or repetitions. For example, [5,3,1], [3,1,5] and [1,5,3] are the same except rotations and [3,3,3], [3,3] and [3] are the same except repetitions.


## Version
0.2.0

## Installation
``` bash
npm install siteswap-generator
```

## Example:
``` javascript
var siteswap = require('siteswap-generator')

var patterns = siteswap.Generator({
    balls : 3,
    period: {min: 2, max: 3},
    height: 5
})

console.log(patterns)
/*
[ [ 5, 3, 1 ],
  [ 5, 2, 2 ],
  [ 5, 0, 4 ],
  [ 4, 4, 1 ],
  [ 4, 2, 3 ],
  [ 5, 1 ],
  [ 4, 2 ] ]
  */
```

## API

- [siteswap](#siteswap--moduleexports)
  - [siteswap.Generator (options)](#siteswapgenerator-options)
    - [options.balls](#optionsballs)
    - [options.period](#optionsperiod)
    - [options.height](#optionsheight)
  - [siteswap.Buffer (options)](#siteswapbuffer-options)
    - [siteswap.Buffer#slice (begin, end)](#siteswapbufferslice-begin-end)
    - [siteswap.Buffer#length](#siteswapbufferlength)
    - [siteswap.Buffer#maxLength](#siteswapbuffermaxlength)
    - [siteswap.Buffer#minLength](#siteswapbufferminlength)

### siteswap === module.exports
Type: Object
#### siteswap.Generator (options)
Type: Function

Returns all of patterns required by `options` object parameter.

##### options.balls
Type: Object | Integer

If `options.balls` is an object, this mean the interval of balls of computed patterns.
- `options.balls.max` is maximum number of balls. 
- `options.balls.min` is minimum number of balls of patterns. If it is not defined the minimum number of balls is the same that `options.balls.max`.

If `options.balls` is an integer, it is the same that `options.balls` takes value `{min: options.balls, max: options.balls}`.

##### options.period
Type: Object | Integer

If `options.period` is an object, this mean the interval of periods which are computed.
- `options.period.max` is maximum period.
- `options.period.min` is minimum period. It takes value 1 by default.

If `options.period` is an integer, it is the same that `options.period` takes value `{min: 1, max: options.period}`.

##### options.height
Type: Object | integer | undefined

If `options.period` is an object:
- `options.height.max` mean that computed patterns have heights less than or equal to this. `options.height.max` is `options.balls.max` * `options.period.max` by default.
- `options.height.min` mean that computed patterns have at least one height greater than or equal to this. The default value is 0.

If `options.height` is an integer, this mean the same that `options.height` takes value `{min: 0, max: options.height}`.

If `options.height` is undefined, this mean the same that `options.height` takes value `{min: 0, max: options.balls.max * options.period.max}`

##### Example:
``` javascript
var patterns = siteswap.Generator({
    balls : {min: 1, max: 3},
    period: 3,
    height: {min: 5}
}) /* [ 
  [ 9, 0, 0 ],
  [ 8, 0, 1 ],
  [ 7, 2, 0 ],
  [ 7, 1, 1 ],
  [ 6, 3, 0 ],
  [ 6, 1, 2 ],
  [ 6, 0, 3 ],
  [ 5, 3, 1 ],
  [ 5, 2, 2 ],
  [ 5, 0, 4 ],
  [ 6, 0 ],
  [ 5, 1 ],
  [ 6, 0, 0 ],
  [ 5, 0, 1 ] 
] */
```

#### siteswap.Buffer (options)
Type: function

It is a constructor that creates a buffer object. This allow to get the same patterns than `siteswap.Generator` but these patterns can be get **lazily** with `.slice` method.

##### siteswap.Buffer#slice (begin, end)

It gets slice of patterns generated by `siteswap.Generator` function.

###### begin

Type: Integer

zero-based index at which to begin extraction

###### end

Type: Integer

zero-based index at which to end extraction.

###### Considerations:
`slice` method get patterns sequentially. If buffer object is created and after got from 11th to 20th pattenrs (`.slice(11,20)`), internally `.slice` compute from first to 20th patterns and returns slice from 11th to 20th requested. Then, if is requested 1st to 10th patterns, these are not computed and only are returned because was previously computed.

##### Example:

``` javascript
var buffer = siteswap.Buffer({
    balls : {min: 1, max: 3},
    period: 3,
    height: {min: 5}
})

buffer.slice(0, 5) /* [
  [ 9, 0, 0 ],
  [ 8, 0, 1 ],
  [ 7, 2, 0 ],
  [ 7, 1, 1 ],
  [ 6, 3, 0 ],
]*/
buffer.slice(5, 10) /* [
  [ 6, 1, 2 ],
  [ 6, 0, 3 ],
  [ 5, 3, 1 ],
  [ 5, 2, 2 ],
  [ 5, 0, 4 ],
]*/
```

##### siteswap.Buffer#length
Type: integer | undefined

length of patterns if all patterns was computed with `slice` method or undefined if not.

##### siteswap.Buffer#maxLength
maximum of length of patterns list.

##### siteswap.Buffer#minLength
minimum of length of patterns list.

## CLI (Comand Line Interface)

### Install
``` bash
$ npm install -g siteswap-generator
```

### Usage
``` bash
$ siteswap [balls.min:]balls.max [period.min:]period.max [[height.min:]height.max]
```

### Examples
``` bash
$ siteswap 3 3 5
[ [ 5, 3, 1 ],
  [ 5, 2, 2 ],
  [ 5, 0, 4 ],
  [ 4, 4, 1 ],
  [ 4, 2, 3 ],
  [ 5, 1 ],
  [ 4, 2 ],
  [ 3 ] ]
```

``` bash
$ siteswap 1:3 3:3 5:5
[ [ 5, 3, 1 ], [ 5, 2, 2 ], [ 5, 0, 4 ], [ 5, 0, 1 ] ]
```


## License
MIT

---
_Source: https://npm.io/package/siteswap-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
