Skip to content

Commit 0fb534d

Browse files
committed
chore: update project dependendices
1 parent 6287b7e commit 0fb534d

File tree

16 files changed

+4144
-14467
lines changed

16 files changed

+4144
-14467
lines changed

docs/js/docma-web.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
3+
import prettier from 'eslint-plugin-prettier';
4+
import globals from 'globals';
5+
import tsParser from '@typescript-eslint/parser';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
import js from '@eslint/js';
9+
import { FlatCompat } from '@eslint/eslintrc';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
17+
});
18+
19+
export default [
20+
...fixupConfigRules(
21+
compat.extends(
22+
'plugin:@typescript-eslint/eslint-recommended',
23+
'plugin:@typescript-eslint/recommended',
24+
'plugin:prettier/recommended',
25+
'plugin:import/recommended',
26+
'plugin:import/typescript'
27+
)
28+
),
29+
{
30+
plugins: {
31+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
32+
prettier: fixupPluginRules(prettier),
33+
},
34+
35+
languageOptions: {
36+
globals: {
37+
...globals.browser,
38+
...globals.jest,
39+
...globals.node,
40+
expect: true,
41+
},
42+
43+
parser: tsParser,
44+
ecmaVersion: 2018,
45+
sourceType: 'module',
46+
},
47+
48+
settings: {
49+
'import/resolver': {
50+
node: {
51+
extensions: ['.js', '.ts'],
52+
},
53+
},
54+
},
55+
56+
rules: {
57+
'no-console': 'off',
58+
'require-jsdoc': 0,
59+
indent: 'off',
60+
'@typescript-eslint/explicit-function-return-type': 0,
61+
'@typescript-eslint/no-explicit-any': 0,
62+
'import/no-unresolved': 'warn',
63+
'import/no-named-as-default': 'warn',
64+
'no-multi-assign': 0,
65+
'no-warning-comments': 0,
66+
'prettier/prettier': 1,
67+
'no-redeclare': 'off',
68+
'@typescript-eslint/no-redeclare': 'off',
69+
},
70+
},
71+
];

lib/analysis/matches.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,21 @@ export const findClosestMatches = (
315315
return [R.intersection(notes, n).length, R.intersection(intervals, i).length, c, n];
316316
});
317317

318-
const maxMatchingNotes = R.reduce(R.max, 0, R.map(R.nth(0), common));
318+
const maxMatchingNotes = R.reduce(
319+
R.max,
320+
0,
321+
R.map((ranking) => ranking[0], common)
322+
);
319323

320324
const matchesNotes = common.filter((m) => {
321325
return m[0] === maxMatchingNotes;
322326
});
323327

324-
const maxMatchingIntervals = R.reduce(R.max, 0, R.map(R.nth(1), matchesNotes));
328+
const maxMatchingIntervals = R.reduce(
329+
R.max,
330+
0,
331+
R.map((ranking) => ranking[1], matchesNotes)
332+
);
325333

326334
const closestMatch = matchesNotes.filter((m) => {
327335
return m[1] === maxMatchingIntervals;
@@ -340,5 +348,5 @@ export const findClosestMatches = (
340348
*/
341349
export const filterHighestMatches = (rankings: MatchRanking[]): MatchRanking[] => {
342350
const maxMatch = R.reduce(R.max, 0, R.map(R.prop('match'), rankings));
343-
return R.filter(R.propEq('match', maxMatch), rankings);
351+
return R.filter((ranking) => ranking.match === maxMatch, rankings);
344352
};

lib/composition/events/select.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class EventEditing<T extends Event> {
156156
const len = bracket.length;
157157
const start = i === 0 ? bracket[0] : bracket[0] - (len - events.length);
158158

159-
const eventsAdj = R.map(mapStartToEvent(this._events[start].time), events) as T[];
159+
const eventsAdj = events.map((event) => mapStartToEvent(this._events[start].time, event));
160160

161161
this._events.splice(start, len, ...eventsAdj);
162162
});
@@ -210,5 +210,5 @@ class EventEditing<T extends Event> {
210210
* @return {EventEditing}
211211
*/
212212
export function select<T extends Event>(events: T[]): EventEditing<T> {
213-
return new EventEditing(R.map(R.clone, events));
213+
return new EventEditing(R.map(R.clone, events) as T[]);
214214
}

lib/composition/events/split-at.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
12
import * as R from 'ramda';
23
import { Event } from '../../core/Event';
34
import { Time, TimeFormat } from '../../core/Time';
@@ -18,7 +19,8 @@ import { isUndefined } from '../../utils/types-guards';
1819
export const splitAt = <T extends Event>(pattern: T[], at: TimeFormat, adjustRestTime = false): T[][] => {
1920
const time = new Time(at);
2021

21-
const index = R.findIndex(R.lte(time.ticks), R.map(R.prop<number>('time'), pattern));
22+
// const index = R.findIndex(R.lte(time.ticks), R.map(R.prop('time'), pattern));
23+
const index = pattern.findIndex((p) => p.time >= time.ticks);
2224

2325
if (index === -1) {
2426
return [pattern];
@@ -39,7 +41,15 @@ export const splitAt = <T extends Event>(pattern: T[], at: TimeFormat, adjustRes
3941
}
4042

4143
if (adjustRestTime) {
42-
return R.adjust(1, R.map(mapStartToEvent(-firstEventLatter.time)), patterns);
44+
// @ts-expect-error
45+
// because the time is not defined in the type
46+
return R.adjust(
47+
1,
48+
// @ts-expect-error
49+
// because the time is not defined in the type
50+
R.map((patt) => mapStartToEvent(-firstEventLatter.time, patt)),
51+
patterns
52+
);
4353
}
4454

4555
return patterns;

lib/composition/rhythm/grid.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function createGrid(totalRhythmDuration: TimeFormat, subDivision: number)
5454

5555
for (let index = 0; index < Math.floor(maxRhythmNotes); index++) {
5656
const beat = index * normalTicks;
57-
const beatIndex = R.findIndex(R.propEq('time', beat), grid);
57+
const beatIndex = grid.findIndex((cell) => cell.time === beat);
5858

5959
if (beatIndex !== -1) {
6060
grid[beatIndex].res.push(normal);
@@ -66,5 +66,5 @@ export function createGrid(totalRhythmDuration: TimeFormat, subDivision: number)
6666
}
6767
}
6868

69-
return ring(R.uniq(R.sortBy(R.prop('time'), grid)));
69+
return ring(R.uniqBy(R.prop('time'), R.sortBy(R.prop('time'), grid)));
7070
}

lib/core/Chord.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ export class Chord extends HarmonyBase {
201201

202202
/**
203203
* Create a chord from a Scale's intervals
204-
* @function fromIntervals
204+
* @function fromNotes
205205
* @memberof Core#Chord
206206
* @static
207-
* @example Chord.fromIntervals('A', Scale.Intervals.Dorian, Chord.Sructures.Sixth);
207+
* @example Chord.fromNotes(['A', 'C', 'E', 'G'])
208208
*
209209
* @param {Array<NoteSymbol>} notes
210210
* @param {Octaves} [octaves = [ 3, 1]]
@@ -389,7 +389,8 @@ export class Chord extends HarmonyBase {
389389
);
390390

391391
chordType = `${chordType}add${last.replace(/\D/g, '')}`;
392-
} catch (error) {
392+
} catch {
393+
console.error("[findChordSymbol] Couldn't find a chord symbol for", chord);
393394
return;
394395
}
395396

@@ -410,8 +411,8 @@ export class Chord extends HarmonyBase {
410411
const rootNote = this.root;
411412

412413
// This is to figure out if flats is a better match than sharps when the root note is natural
413-
const sharpNotes = R.length(R.filter(R.prop<boolean>('isSharp'), notes));
414-
const flatNotes = R.length(R.filter(R.prop<boolean>('isFlat'), notes));
414+
const sharpNotes = R.length(R.filter((note) => note.isSharp, notes));
415+
const flatNotes = R.length(R.filter((note) => note.isFlat, notes));
415416

416417
if (rootNote.isFlat || flatNotes > 0) {
417418
this._notesType = NoteType.Flat;

lib/core/Key.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ export class Key extends Scale {
276276
if (R.includes(Key.Locrian, R.pluck('scale', modes))) {
277277
const modesLen = modes.length;
278278

279-
modes = R.sort(R.ascend(R.propEq('scale', Key.Locrian)), modes);
279+
modes = R.sort(
280+
R.ascend((mode) => mode.scale === Key.Locrian),
281+
modes
282+
);
280283

281284
const avgProb = ((1.0 - LOCRIAN_PROB) / (modesLen - 1.0)).toFixed(PRECISION);
282285

@@ -306,7 +309,7 @@ export class Key extends Scale {
306309
this._root = new Note(mode.root);
307310
this._intervals = mode.scale;
308311

309-
const rootPos = R.findIndex(R.propEq('note', mode.root), this._notes);
312+
const rootPos = this._notes.findIndex((note) => note.note === mode.root);
310313
const notesSplit = R.splitAt(rootPos, this._notes);
311314

312315
this._notes = R.concat(<Note[]>R.last(notesSplit), <Note[]>R.head(notesSplit));
@@ -337,7 +340,7 @@ export class Key extends Scale {
337340
* @return {Number}
338341
*/
339342
get modePosition(): number {
340-
return R.findIndex(R.propEq('root', this.root.note), this.modes);
343+
return this.modes.findIndex((mode) => mode.root === this.root.note);
341344
}
342345

343346
/**
@@ -441,7 +444,7 @@ export class Key extends Scale {
441444
this._root = new Note(mode.root);
442445
this._intervals = mode.scale;
443446

444-
const rootPos = R.findIndex(R.propEq('note', mode.root), this._notes);
447+
const rootPos = this._notes.findIndex((note) => note.note === mode.root);
445448
const notesSplit = R.splitAt(rootPos, this._notes);
446449

447450
this._notes = R.concat(<Note[]>R.last(notesSplit), <Note[]>R.head(notesSplit));

lib/tools/event.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ export const computeEventsNext = <T extends Event>(events: T[]): T[] => {
114114
* @param {TimeFormat} startTime
115115
* @return {Event}
116116
*/
117-
export const mapStartToEvent = R.curry(<T extends Event>(startTime: TimeFormat, event: T): T => {
117+
export const mapStartToEvent = <T extends Event>(startTime: TimeFormat, event: T): T => {
118118
const start = new Time(startTime);
119119
return {
120120
...event,
121121
time: start.ticks + event.time,
122122
next: start.ticks + event.next,
123123
};
124-
});
124+
};
125125

126126
/**
127127
* Converts Event[] to notevalues (ie. 4n), ignores rests
@@ -133,7 +133,7 @@ export const mapStartToEvent = R.curry(<T extends Event>(startTime: TimeFormat,
133133
* @return {string[]}
134134
*/
135135
export const convertEventsToNotevalues = (events: Event[]): string[] => {
136-
const filteredEvents = R.filter(R.propEq('isRest', false), events);
136+
const filteredEvents = R.filter((event) => !event.isRest, events);
137137

138138
return filteredEvents.map((evt, index) => {
139139
// TODO: Switch to Notevalue and fix undefined issue

lib/utils/functional.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export const valuesToArr = <T>(map: { [key: string]: T }): T[] => {
44
return Array.from(Object.values(map));
55
};
66

7-
export const convObj = <T>(list: T[]): ((list: T[]) => Record<string, T>[]) => R.map(R.flip(R.objOf)(list));
7+
export const convObj = <T extends string | number | symbol>(list: T[]): ((list: T[]) => Record<string, T>[]) =>
8+
R.map(R.flip(R.objOf)(list as string[])) as (list: T[]) => Record<string, T>[];
89

910
export const rotate = R.compose(
1011
R.flatten as (list: string[][]) => string[],

0 commit comments

Comments
 (0)