New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-distance

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-distance - npm Package Compare versions

Comparing version 1.0.0-pre2 to 1.0.0-pre3

111

build/transpiled.js

@@ -30,14 +30,19 @@ 'use strict';

// { C: 0, D: 2, E: 4, F: -1, G: 1, A: 3, B: 5 }
const FIFTHS = [0, 2, 4, -1, 1, 3, 5];
var FIFTHS = [0, 2, 4, -1, 1, 3, 5];
// Given a number of fifths, return the octaves they span
const fOcts = f => Math.floor(f * 7 / 12);
var fOcts = function (f) { return Math.floor(f * 7 / 12); };
// Get the number of octaves it span each step
const FIFTH_OCTS = FIFTHS.map(fOcts);
var FIFTH_OCTS = FIFTHS.map(fOcts);
const encode = ({ step, alt, oct, dir = 1 }) => {
const f = FIFTHS[step] + 7 * alt;
if (oct === null) return [dir * f];
const o = oct - FIFTH_OCTS[step] - 4 * alt;
var encode = function (ref) {
var step = ref.step;
var alt = ref.alt;
var oct = ref.oct;
var dir = ref.dir; if ( dir === void 0 ) dir = 1;
var f = FIFTHS[step] + 7 * alt;
if (oct === null) { return [dir * f]; }
var o = oct - FIFTH_OCTS[step] - 4 * alt;
return [dir * f, dir * o];

@@ -50,28 +55,31 @@ };

// for ['F', 'C', 'G', 'D', 'A', 'E', 'B'] we have:
const STEPS = [3, 0, 4, 1, 5, 2, 6];
var STEPS = [3, 0, 4, 1, 5, 2, 6];
// Return the number of fifths as if it were unaltered
function unaltered(f) {
const i = (f + 1) % 7;
var i = (f + 1) % 7;
return i < 0 ? 7 + i : i;
}
const decode = (f, o, dir) => {
const step = STEPS[unaltered(f)];
const alt = Math.floor((f + 1) / 7);
if (o === undefined) return { step, alt, dir };
const oct = o + 4 * alt + FIFTH_OCTS[step];
return { step, alt, oct, dir };
var decode = function (f, o, dir) {
var step = STEPS[unaltered(f)];
var alt = Math.floor((f + 1) / 7);
if (o === undefined) { return { step: step, alt: alt, dir: dir }; }
var oct = o + 4 * alt + FIFTH_OCTS[step];
return { step: step, alt: alt, oct: oct, dir: dir };
};
const memo = (fn, cache = {}) => str => cache[str] || (cache[str] = fn(str));
var memo = function (fn, cache) {
if ( cache === void 0 ) cache = {};
const encoder = props$$1 =>
memo(str => {
const p = props$$1(str);
return function (str) { return cache[str] || (cache[str] = fn(str)); };
};
var encoder = function (props$$1) { return memo(function (str) {
var p = props$$1(str);
return p.name === null ? null : encode(p);
});
}); };
const encodeNote = encoder(tonalNote.props);
const encodeIvl = encoder(tonalInterval.props);
var encodeNote = encoder(tonalNote.props);
var encodeIvl = encoder(tonalInterval.props);

@@ -95,7 +103,7 @@ /**

function transpose(note, interval) {
if (arguments.length === 1) return i => transpose(note, i);
const n = encodeNote(note);
const i = encodeIvl(interval);
if (n === null || i === null) return null;
const tr = n.length === 1 ? [n[0] + i[0]] : [n[0] + i[0], n[1] + i[1]];
if (arguments.length === 1) { return function (i) { return transpose(note, i); }; }
var n = encodeNote(note);
var i = encodeIvl(interval);
if (n === null || i === null) { return null; }
var tr = n.length === 1 ? [n[0] + i[0]] : [n[0] + i[0], n[1] + i[1]];
return tonalNote.build(decode(tr[0], tr[1]));

@@ -122,5 +130,5 @@ }

function trFifths(note, fifths) {
if (arguments.length === 1) return f => trFifths(note, f);
const n = encodeNote(note);
if (n === null) return null;
if (arguments.length === 1) { return function (f) { return trFifths(note, f); }; }
var n = encodeNote(note);
if (n === null) { return null; }
return tonalNote.build(decode(n[0] + fifths));

@@ -138,6 +146,6 @@ }

function fifths(from, to) {
if (arguments.length === 1) return to => fifths(from, to);
const f = encodeNote(from);
const t = encodeNote(to);
if (t === null || f === null) return null;
if (arguments.length === 1) { return function (to) { return fifths(from, to); }; }
var f = encodeNote(from);
var t = encodeNote(to);
if (t === null || f === null) { return null; }
return t[0] - f[0];

@@ -159,15 +167,14 @@ }

function transposeBy(interval, note) {
if (arguments.length === 1) return n => transpose(n, interval);
if (arguments.length === 1) { return function (n) { return transpose(n, interval); }; }
return transpose(note, interval);
}
const isDescending = e => e[0] * 7 + e[1] * 12 < 0;
const decodeIvl = i =>
isDescending(i) ? decode(-i[0], -i[1], -1) : decode(i[0], i[1], 1);
var isDescending = function (e) { return e[0] * 7 + e[1] * 12 < 0; };
var decodeIvl = function (i) { return isDescending(i) ? decode(-i[0], -i[1], -1) : decode(i[0], i[1], 1); };
function addIntervals(ivl1, ivl2, dir) {
const i1 = encodeIvl(ivl1);
const i2 = encodeIvl(ivl2);
if (i1 === null || i2 === null) return null;
const i = [i1[0] + dir * i2[0], i1[1] + dir * i2[1]];
var i1 = encodeIvl(ivl1);
var i2 = encodeIvl(ivl2);
if (i1 === null || i2 === null) { return null; }
var i = [i1[0] + dir * i2[0], i1[1] + dir * i2[1]];
return tonalInterval.build(decodeIvl(i));

@@ -189,3 +196,3 @@ }

function add(ivl1, ivl2) {
if (arguments.length === 1) return i2 => add(ivl1, i2);
if (arguments.length === 1) { return function (i2) { return add(ivl1, i2); }; }
return addIntervals(ivl1, ivl2, 1);

@@ -204,3 +211,3 @@ }

function subtract(ivl1, ivl2) {
if (arguments.length === 1) return i2 => add(ivl1, i2);
if (arguments.length === 1) { return function (i2) { return add(ivl1, i2); }; }
return addIntervals(ivl1, ivl2, -1);

@@ -229,7 +236,7 @@ }

function interval(from, to) {
if (arguments.length === 1) return t => interval(from, t);
const f = encodeNote(from);
const t = encodeNote(to);
if (f === null || t === null || f.length !== t.length) return null;
const d =
if (arguments.length === 1) { return function (t) { return interval(from, t); }; }
var f = encodeNote(from);
var t = encodeNote(to);
if (f === null || t === null || f.length !== t.length) { return null; }
var d =
f.length === 1

@@ -254,5 +261,5 @@ ? [t[0] - f[0], -Math.floor((t[0] - f[0]) * 7 / 12)]

function semitones(from, to) {
if (arguments.length === 1) return t => semitones(from, t);
const f = tonalNote.props(from);
const t = tonalNote.props(to);
if (arguments.length === 1) { return function (t) { return semitones(from, t); }; }
var f = tonalNote.props(from);
var t = tonalNote.props(to);
return f.midi !== null && t.midi !== null

@@ -259,0 +266,0 @@ ? t.midi - f.midi

{
"name": "tonal-distance",
"version": "1.0.0-pre2",
"version": "1.0.0-pre3",
"description": "Transpose notes and find intervals between them",

@@ -23,4 +23,4 @@ "keywords": [

"dependencies": {
"tonal-interval": "^1.0.0-pre2",
"tonal-note": "^1.0.0-pre2"
"tonal-interval": "^1.0.0-pre3",
"tonal-note": "^1.0.0-pre3"
},

@@ -27,0 +27,0 @@ "babel": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc