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 
@tonaljs/array is a collection of functions to work with arrays: create ranges, permutations, rotations, sort.
Examples:
import { range, sort } from '@tonaljs/array'
range(-2, 2) // => [-2, -1, 0, 1, 2]
sort(['c', 'F', 'G', 'a', 'b', 'h', 'J']) // => ['C', 'F', 'G', 'A', 'B']Usage
Install
npm: npm i --save @tonaljs/array
yarn: yarn add @tonaljs/array
Import
ES6 module:
import * as midi from '@tonaljs/array'ES5 module:
const midi = require('@tonaljs/array')ES6 individual functions:
import { rotate } from '@tonaljs/array'Documentation
API
range(from: number, to: number): number[]- Creates a numeric rangerotate(times: number, array: any[]): any[]- Rotates a list a number of times. It"s completly agnostic about the contents of the listcompact(array: any[]): any[]- Return a copy of the array with the null values removedsortNotes(notes: string[]): string[]- Sort an array of notes in ascending order. Pitch classes are listed before notes. Any string that is not a note is removedsortedUniqNotes(array: string[]): string[]- Get sorted notes with duplicates removed. Pitch classes are listed before notesshuffle(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
Read the full API documentation here
License
MIT License