4.8.4 • Published 6 months ago

@tonaljs/array v4.8.4

Weekly downloads
400
License
MIT
Repository
-
Last release
6 months ago

@tonaljs/array tonal npm version

A collection of functions to create and manipulate arrays of notes or intervals.

API

range(from: number, to: number) => number[]

Creates a numeric range:

range(-2, 2); // => [-2, -1, 0, 1, 2]
range(2, -2); // => [2, 1, 0, -1, -2]

rotate(times: number, array: any[]) => any[]

Rotate an array a number of times:

rotate(1, [1, 2, 3]); // => [2, 3, 1]

sortedNoteNames(array: any[]) => string[]

Sort an array of note names in ascending order. Pitch classes are listed before notes. Any string that is not a note is removed.

sortedNoteNames(["c2", "c5", "c1", "c0", "c6", "c"]);
// => ['C', 'C0', 'C1', 'C2', 'C5', 'C6']
sortedNoteNames(["c", "F", "G", "a", "b", "h", "J"]);
// => ['C', 'F', 'G', 'A', 'B']

sortedUniqNoteNames(array: any[]) => string[]

Return a list of sorted note names with duplications removed.

shuffle(array: any[]) => any[]

Randomizes the order of the specified array in-place, using the Fisher–Yates shuffle.

permutations(array: any[]) => any[][]

Get all permutations of an array

permutations(["a", "b", "c"])) // =>
// =>
// [
//   ["a", "b", "c"],
//   ["b", "a", "c"],
//   ["b", "c", "a"],
//   ["a", "c", "b"],
//   ["c", "a", "b"],
//   ["c", "b", "a"]
// ]
4.8.4

6 months ago

4.8.3

1 year ago

4.8.2

1 year ago

4.8.1

1 year ago

4.7.2

3 years ago

4.8.0

3 years ago

4.7.3

3 years ago

4.6.11

3 years ago

4.6.12

3 years ago

4.6.10

3 years ago

4.6.5

4 years ago

4.6.2

4 years ago

4.5.1

5 years ago

4.5.0

5 years ago

3.2.9

5 years ago

3.2.8

5 years ago

3.2.6

5 years ago

3.2.7

5 years ago

3.2.5

5 years ago

3.2.4

5 years ago

3.2.3

6 years ago

3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago