Skip to content

Commit 05371a6

Browse files
committed
move deepEquals, arrayEquals to external
Let external dependencies do what they do best.
1 parent 2a5d5a2 commit 05371a6

File tree

8 files changed

+1385
-978
lines changed

8 files changed

+1385
-978
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ testHTML directory as `sfElsewhereCDN.html`.
124124

125125
## Version
126126

127-
0.21.2 (beta)
127+
0.21.3 (beta)
128128

129129
## License
130130

package-lock.json

Lines changed: 194 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "music21j",
3-
"version": "0.21.2",
3+
"version": "0.21.3",
44
"description": "A toolkit for computer-aided musicology, JavaScript version",
55

66
"_main_etc": "these are the legacy urls; exports:. is the modern standard",
@@ -24,6 +24,8 @@
2424
"/webResources"
2525
],
2626
"dependencies": {
27+
"array-equal": "^2.0.0",
28+
"deep-equal": "^2.2.3",
2729
"jsonpickle": "^1.2.0",
2830
"midicube": "^0.9.2",
2931
"vexflow": "^4.2.3"
@@ -36,6 +38,7 @@
3638
},
3739
"devDependencies": {
3840
"@playwright/test": "^1.57.0",
41+
"@types/deep-equal": "^1.0.4",
3942
"@types/jquery": "^3.5.32",
4043
"@types/node": "^25.0.3",
4144
"@types/qunit": "^2.19.13",

src/chordTables.ts

Lines changed: 1178 additions & 822 deletions
Large diffs are not rendered by default.

src/clef.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Clef related objects and properties
99
*
1010
*/
11+
import arrayEqual from 'array-equal';
12+
1113
import * as base from './base';
1214
import * as pitch from './pitch';
1315
import type { Stream } from './stream';
@@ -379,9 +381,6 @@ export function clefFromString(clefString: string, octaveShift: number = 0): Cle
379381
}
380382
}
381383

382-
// TODO: remove this -- we have other ways of deep equality
383-
const arrayEqual = (a: any[], b: any[]) => a.length === b.length && a.every((el, ix) => el === b[ix]);
384-
385384
const params = [thisType, lineNum, octaveShift];
386385
if (arrayEqual(params, ['G', 2, 0])) {
387386
return new TrebleClef();

src/common.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,6 @@ export function urlParam(name: string): string {
351351
: decodeURIComponent(results[1].replace(/\+/g, ' '));
352352
}
353353

354-
export function arrayEquals(a1: any[], a2: any[]): boolean {
355-
if (a1.length !== a2.length) {
356-
return false;
357-
}
358-
for (let i = 0; i < a1.length; i++) {
359-
if (a1[i] instanceof Array && a2[i] instanceof Array) {
360-
if (!arrayEquals(a1[i], a2[i])) {
361-
return false;
362-
}
363-
} else if (a1[i] !== a2[i]) {
364-
return false;
365-
}
366-
}
367-
return true;
368-
}
369-
370354
const _singletonCounter = {
371355
value: 0,
372356
};

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ import * as webmidi from './webmidi';
8484

8585
import { debug } from './debug';
8686

87-
export const VERSION = '0.21.2';
87+
export const VERSION = '0.21.3';
8888

8989
export {
9090
MIDI,

src/scale.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
* Copyright (c) 2013-24, Michael Scott Asato Cuthbert
88
* Based on music21 (=music21p), Copyright (c) 2006-24, Michael Scott Asato Cuthbert
99
*/
10+
import deepEqual from 'deep-equal';
11+
1012
import { Music21Exception } from './exceptions21';
1113
import { debug } from './debug';
1214

1315
import * as base from './base';
14-
import * as common from './common';
1516
import * as interval from './interval';
1617
import * as pitch from './pitch';
1718

@@ -85,11 +86,9 @@ export class AbstractScale extends Scale {
8586
* @returns {boolean}
8687
*/
8788
equals(other: AbstractScale): boolean {
88-
if (
89-
common.arrayEquals(this.classes, other.classes)
90-
&& this.tonicDegree === other.tonicDegree
91-
&& common.arrayEquals(this._net, other._net)
92-
) {
89+
if (deepEqual(this.classes, other.classes)
90+
&& this.tonicDegree === other.tonicDegree
91+
&& deepEqual(this._net, other._net)) {
9392
return true;
9493
} else {
9594
return false;

0 commit comments

Comments
 (0)