How to use just-range - 3 common examples

To help you get started, we’ve selected a few just-range examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kevinsqi / react-piano / src / MidiNumbers.js View on Github external
}

const midiNumberAttributesCache = buildMidiNumberAttributesCache();

// Returns an object containing various attributes for a given MIDI number.
// Throws error for invalid midiNumbers.
function getAttributes(midiNumber) {
  const attrs = midiNumberAttributesCache[midiNumber];
  if (!attrs) {
    throw Error('Invalid MIDI number');
  }
  return attrs;
}

// Returns all MIDI numbers corresponding to natural notes, e.g. C and not C# or Bb.
const NATURAL_MIDI_NUMBERS = range(MIN_MIDI_NUMBER, MAX_MIDI_NUMBER + 1).filter(
  (midiNumber) => !getAttributes(midiNumber).isAccidental,
);

export default {
  fromNote,
  getAttributes,
  MIN_MIDI_NUMBER,
  MAX_MIDI_NUMBER,
  NATURAL_MIDI_NUMBERS,
};
github kevinsqi / react-piano / src / Keyboard.js View on Github external
getMidiNumbers() {
    return range(this.props.noteRange.first, this.props.noteRange.last + 1);
  }
github kevinsqi / react-piano / src / MidiNumbers.js View on Github external
function buildMidiNumberAttributesCache() {
  return range(MIN_MIDI_NUMBER, MAX_MIDI_NUMBER + 1).reduce((cache, midiNumber) => {
    cache[midiNumber] = buildMidiNumberAttributes(midiNumber);
    return cache;
  }, {});
}

just-range

Generate a range array for numbers

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis

Popular just-range functions