Package Exports
- @tonaljs/array
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tonaljs/array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@tonaljs/array

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"]
// ]