npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

siteswap-generator

v0.2.0

Published

siteswap generator

Downloads

17

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 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

npm install siteswap-generator

Example:

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 === 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:
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:
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

$ npm install -g siteswap-generator

Usage

$ siteswap [balls.min:]balls.max [period.min:]period.max [[height.min:]height.max]

Examples

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

License

MIT