chordsheetjs 4.10.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -139
- package/d7b54993c4ea66c07a35bd36690482ab620f836e.patch +105 -0
- package/lib/chord.js +341 -35
- package/lib/chord_sheet/chord_lyrics_pair.js +1 -1
- package/lib/chord_sheet/chord_pro/composite.js +1 -1
- package/lib/chord_sheet/chord_pro/evaluation_error.js +7 -3
- package/lib/chord_sheet/chord_pro/literal.js +1 -1
- package/lib/chord_sheet/chord_pro/ternary.js +1 -1
- package/lib/chord_sheet/comment.js +1 -1
- package/lib/chord_sheet/line.js +1 -1
- package/lib/chord_sheet/metadata.js +4 -4
- package/lib/chord_sheet/paragraph.js +1 -1
- package/lib/chord_sheet/song.js +9 -5
- package/lib/chord_sheet/tag.js +10 -3
- package/lib/chord_sheet_serializer.js +1 -1
- package/lib/constants.js +6 -2
- package/lib/formatter/chord_pro_formatter.js +1 -1
- package/lib/formatter/html_div_formatter.js +4 -4
- package/lib/formatter/html_formatter.js +3 -2
- package/lib/formatter/html_table_formatter.js +4 -4
- package/lib/formatter/templates/html_div_formatter.js +31 -32
- package/lib/formatter/templates/html_table_formatter.js +7 -6
- package/lib/formatter/text_formatter.js +25 -17
- package/lib/helpers.js +32 -0
- package/lib/index.js +26 -10
- package/lib/key.js +311 -0
- package/lib/note.js +132 -0
- package/lib/parser/chord_pro_parser.js +1 -1
- package/lib/parser/chord_pro_peg_parser.js +22 -13
- package/lib/parser/chord_sheet_parser.js +1 -1
- package/lib/parser/parser_warning.js +1 -1
- package/lib/parser/ultimate_guitar_parser.js +4 -4
- package/lib/{handlebars_helpers.js → template_helpers.js} +21 -2
- package/lib/utilities.js +22 -23
- package/package.json +6 -5
- package/lib/chord_helpers.js +0 -222
- package/lib/chord_symbol.js +0 -139
- package/lib/numeric_chord.js +0 -138
- package/lib/parse_chord.js +0 -74
- package/lib/to_chord_symbol.js +0 -93
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasTextContents = void 0;
|
|
7
|
+
|
|
3
8
|
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
4
9
|
|
|
5
10
|
var _chord_lyrics_pair = _interopRequireDefault(require("./chord_sheet/chord_lyrics_pair"));
|
|
@@ -8,6 +13,8 @@ var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
|
|
|
8
13
|
|
|
9
14
|
var _constants = require("./constants");
|
|
10
15
|
|
|
16
|
+
var _helpers = require("./helpers");
|
|
17
|
+
|
|
11
18
|
var _utilities = require("./utilities");
|
|
12
19
|
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -17,6 +24,16 @@ var lineHasContents = function lineHasContents(line) {
|
|
|
17
24
|
return item.isRenderable();
|
|
18
25
|
});
|
|
19
26
|
};
|
|
27
|
+
/* eslint import/prefer-default-export: 0 */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var hasTextContents = function hasTextContents(line) {
|
|
31
|
+
return line.items.some(function (item) {
|
|
32
|
+
return item instanceof _chord_lyrics_pair["default"] && item.lyrics || item instanceof _tag["default"] && item.isRenderable() || (0, _utilities.isEvaluatable)(item);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.hasTextContents = hasTextContents;
|
|
20
37
|
|
|
21
38
|
_handlebars["default"].registerHelper('isChordLyricsPair', function (item) {
|
|
22
39
|
return item instanceof _chord_lyrics_pair["default"];
|
|
@@ -40,7 +57,7 @@ _handlebars["default"].registerHelper('shouldRenderLine', function (line, option
|
|
|
40
57
|
|
|
41
58
|
_handlebars["default"].registerHelper('hasChordContents', _utilities.hasChordContents);
|
|
42
59
|
|
|
43
|
-
_handlebars["default"].registerHelper('hasTextContents',
|
|
60
|
+
_handlebars["default"].registerHelper('hasTextContents', hasTextContents);
|
|
44
61
|
|
|
45
62
|
_handlebars["default"].registerHelper('lineHasContents', lineHasContents);
|
|
46
63
|
|
|
@@ -76,4 +93,6 @@ _handlebars["default"].registerHelper('evaluate', function (item, metadata) {
|
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
return item.evaluate(metadata);
|
|
79
|
-
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
_handlebars["default"].registerHelper('renderChord', _helpers.renderChord);
|
package/lib/utilities.js
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.deprecate = deprecate;
|
|
7
|
+
exports.hasChordContents = void 0;
|
|
8
|
+
exports.isEmptyString = isEmptyString;
|
|
9
|
+
exports.pushNew = exports.presence = exports.padLeft = exports.isPresent = exports.isEvaluatable = void 0;
|
|
7
10
|
exports.scopeCss = scopeCss;
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
14
13
|
|
|
15
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
15
|
|
|
@@ -34,7 +33,7 @@ exports.pushNew = pushNew;
|
|
|
34
33
|
|
|
35
34
|
var hasChordContents = function hasChordContents(line) {
|
|
36
35
|
return line.items.some(function (item) {
|
|
37
|
-
return item
|
|
36
|
+
return !!item.chords;
|
|
38
37
|
});
|
|
39
38
|
};
|
|
40
39
|
|
|
@@ -46,14 +45,6 @@ var isEvaluatable = function isEvaluatable(item) {
|
|
|
46
45
|
|
|
47
46
|
exports.isEvaluatable = isEvaluatable;
|
|
48
47
|
|
|
49
|
-
var hasTextContents = function hasTextContents(line) {
|
|
50
|
-
return line.items.some(function (item) {
|
|
51
|
-
return item instanceof _chord_lyrics_pair["default"] && item.lyrics || item instanceof _tag["default"] && item.isRenderable() || isEvaluatable(item);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports.hasTextContents = hasTextContents;
|
|
56
|
-
|
|
57
48
|
var padLeft = function padLeft(str, length) {
|
|
58
49
|
var paddedString = str;
|
|
59
50
|
|
|
@@ -66,14 +57,6 @@ var padLeft = function padLeft(str, length) {
|
|
|
66
57
|
|
|
67
58
|
exports.padLeft = padLeft;
|
|
68
59
|
|
|
69
|
-
var deprecate = function deprecate(message) {
|
|
70
|
-
if (process && process.emitWarning) {
|
|
71
|
-
process.emitWarning(message);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.deprecate = deprecate;
|
|
76
|
-
|
|
77
60
|
var isPresent = function isPresent(object) {
|
|
78
61
|
return object && object.length > 0;
|
|
79
62
|
};
|
|
@@ -108,4 +91,20 @@ function scopeCss(css, scope) {
|
|
|
108
91
|
var scopedSelector = "".concat(scope, " ").concat(selector).trim();
|
|
109
92
|
return "\n".concat(scopedSelector, " {\n ").concat(rules, "\n}").substring(1);
|
|
110
93
|
}).join('\n\n');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function deprecate(message) {
|
|
97
|
+
try {
|
|
98
|
+
throw new Error("DEPRECATION: ".concat(message));
|
|
99
|
+
} catch (e) {
|
|
100
|
+
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.emitWarning === 'function') {
|
|
101
|
+
process.emitWarning("".concat(message, "\n").concat(e.stack));
|
|
102
|
+
} else {
|
|
103
|
+
console.warn("".concat(message, "\n").concat(e.stack));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isEmptyString(string) {
|
|
109
|
+
return string === null || string === undefined || string === '';
|
|
111
110
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chordsheetjs",
|
|
3
3
|
"author": "Martijn Versluis",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"description": "A JavaScript library for parsing and formatting chord sheets",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -15,16 +15,17 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/cli": "^7.10.1",
|
|
17
17
|
"@babel/core": "^7.10.2",
|
|
18
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
18
19
|
"@babel/plugin-transform-runtime": "^7.10.1",
|
|
19
20
|
"@babel/preset-env": "^7.10.2",
|
|
20
|
-
"babel-eslint": "^10.1.0",
|
|
21
21
|
"babel-plugin-handlebars-inline-precompile": "^2.1.1",
|
|
22
|
-
"eslint": "^
|
|
23
|
-
"eslint-config-airbnb-base": "^
|
|
22
|
+
"eslint": "^8.3.0",
|
|
23
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
24
24
|
"eslint-plugin-import": "^2.21.2",
|
|
25
25
|
"jest": "^27.0.1",
|
|
26
26
|
"jsdoc-to-markdown": "^7.1.0",
|
|
27
|
-
"pegjs": "^0.10.0"
|
|
27
|
+
"pegjs": "^0.10.0",
|
|
28
|
+
"print": "^1.2.0"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"jest": "jest",
|
package/lib/chord_helpers.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deprecate = deprecate;
|
|
7
|
-
exports.internalSwitchModifier = internalSwitchModifier;
|
|
8
|
-
exports.isEmptyString = isEmptyString;
|
|
9
|
-
exports.keyDown = keyDown;
|
|
10
|
-
exports.keyUp = keyUp;
|
|
11
|
-
exports.normalize = normalize;
|
|
12
|
-
exports.processChord = processChord;
|
|
13
|
-
exports.switchModifier = switchModifier;
|
|
14
|
-
exports.transpose = transpose;
|
|
15
|
-
exports.transposeDown = transposeDown;
|
|
16
|
-
exports.transposeUp = transposeUp;
|
|
17
|
-
exports.useModifier = useModifier;
|
|
18
|
-
|
|
19
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
20
|
-
|
|
21
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
-
|
|
23
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
-
|
|
25
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
-
|
|
27
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
28
|
-
|
|
29
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
30
|
-
|
|
31
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
-
|
|
33
|
-
var A = 'A'.charCodeAt(0);
|
|
34
|
-
var G = 'G'.charCodeAt(0);
|
|
35
|
-
|
|
36
|
-
function keyChange(key, delta) {
|
|
37
|
-
var charCode;
|
|
38
|
-
charCode = key.toUpperCase().charCodeAt(0);
|
|
39
|
-
charCode += delta;
|
|
40
|
-
|
|
41
|
-
if (charCode > G) {
|
|
42
|
-
charCode = A;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (charCode < A) {
|
|
46
|
-
charCode = G;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return String.fromCharCode(charCode);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function keyUp(key) {
|
|
53
|
-
return keyChange(key, 1);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function keyDown(key) {
|
|
57
|
-
return keyChange(key, -1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function normalize(base, modifier) {
|
|
61
|
-
if (modifier === '#' && /^(B|E)$/.test(base)) {
|
|
62
|
-
return [keyUp(base), null];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (modifier === 'b' && /^(C|F)$/.test(base)) {
|
|
66
|
-
return [keyDown(base), null];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return [base, modifier];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function internalSwitchModifier(base, modifier) {
|
|
73
|
-
if (modifier === '#') {
|
|
74
|
-
return [keyUp(base), 'b'];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (modifier === 'b') {
|
|
78
|
-
return [keyDown(base), '#'];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
throw new Error("Unexpected modifier ".concat(modifier));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function switchModifier(base, modifier) {
|
|
85
|
-
var _normalize = normalize(base, modifier),
|
|
86
|
-
_normalize2 = _slicedToArray(_normalize, 2),
|
|
87
|
-
normalizedBase = _normalize2[0],
|
|
88
|
-
normalizedModifier = _normalize2[1];
|
|
89
|
-
|
|
90
|
-
if (modifier) {
|
|
91
|
-
return internalSwitchModifier(normalizedBase, normalizedModifier);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return [normalizedBase, normalizedModifier];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function useModifier(base, modifier, newModifier) {
|
|
98
|
-
if (modifier && modifier !== newModifier) {
|
|
99
|
-
return internalSwitchModifier(base, modifier);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return [base, modifier];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function repeatProcessor(base, modifier, processor, amount) {
|
|
106
|
-
var processedBase = base,
|
|
107
|
-
processedModifier = modifier;
|
|
108
|
-
|
|
109
|
-
for (var i = 0; i < amount; i += 1) {
|
|
110
|
-
var _processor = processor(processedBase, processedModifier);
|
|
111
|
-
|
|
112
|
-
var _processor2 = _slicedToArray(_processor, 2);
|
|
113
|
-
|
|
114
|
-
processedBase = _processor2[0];
|
|
115
|
-
processedModifier = _processor2[1];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return [processedBase, processedModifier];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function transposeUp(base, modifier) {
|
|
122
|
-
var _normalize3 = normalize(base, modifier),
|
|
123
|
-
_normalize4 = _slicedToArray(_normalize3, 2),
|
|
124
|
-
normalizedBase = _normalize4[0],
|
|
125
|
-
normalizedModifier = _normalize4[1];
|
|
126
|
-
|
|
127
|
-
if (normalizedModifier === 'b') {
|
|
128
|
-
return [normalizedBase, null];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (normalizedModifier === '#') {
|
|
132
|
-
return [keyUp(normalizedBase), null];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (/^(B|E)$/.test(normalizedBase)) {
|
|
136
|
-
return [keyUp(normalizedBase), null];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return [normalizedBase, '#'];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function transposeDown(base, modifier) {
|
|
143
|
-
var _normalize5 = normalize(base, modifier),
|
|
144
|
-
_normalize6 = _slicedToArray(_normalize5, 2),
|
|
145
|
-
normalizedBase = _normalize6[0],
|
|
146
|
-
normalizedModifier = _normalize6[1];
|
|
147
|
-
|
|
148
|
-
if (normalizedModifier === 'b') {
|
|
149
|
-
return [keyDown(normalizedBase), null];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (normalizedModifier === '#') {
|
|
153
|
-
return [normalizedBase, null];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (/^(C|F)$/.test(normalizedBase)) {
|
|
157
|
-
return [keyDown(normalizedBase), null];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return [normalizedBase, 'b'];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function transpose(base, modifier, delta) {
|
|
164
|
-
var newBase = base,
|
|
165
|
-
newModifier = modifier;
|
|
166
|
-
|
|
167
|
-
if (delta < 0) {
|
|
168
|
-
var _repeatProcessor = repeatProcessor(base, modifier, transposeDown, Math.abs(delta));
|
|
169
|
-
|
|
170
|
-
var _repeatProcessor2 = _slicedToArray(_repeatProcessor, 2);
|
|
171
|
-
|
|
172
|
-
newBase = _repeatProcessor2[0];
|
|
173
|
-
newModifier = _repeatProcessor2[1];
|
|
174
|
-
} else if (delta > 0) {
|
|
175
|
-
var _repeatProcessor3 = repeatProcessor(base, modifier, transposeUp, delta);
|
|
176
|
-
|
|
177
|
-
var _repeatProcessor4 = _slicedToArray(_repeatProcessor3, 2);
|
|
178
|
-
|
|
179
|
-
newBase = _repeatProcessor4[0];
|
|
180
|
-
newModifier = _repeatProcessor4[1];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return useModifier(newBase, newModifier, modifier);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function processChord(sourceChord, processor, processorArg) {
|
|
187
|
-
var chord = sourceChord.clone();
|
|
188
|
-
|
|
189
|
-
var _processor3 = processor(sourceChord.base, sourceChord.modifier, processorArg);
|
|
190
|
-
|
|
191
|
-
var _processor4 = _slicedToArray(_processor3, 2);
|
|
192
|
-
|
|
193
|
-
chord.base = _processor4[0];
|
|
194
|
-
chord.modifier = _processor4[1];
|
|
195
|
-
|
|
196
|
-
if (sourceChord.bassBase) {
|
|
197
|
-
var _processor5 = processor(sourceChord.bassBase, sourceChord.bassModifier, processorArg);
|
|
198
|
-
|
|
199
|
-
var _processor6 = _slicedToArray(_processor5, 2);
|
|
200
|
-
|
|
201
|
-
chord.bassBase = _processor6[0];
|
|
202
|
-
chord.bassModifier = _processor6[1];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return chord;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function deprecate(message) {
|
|
209
|
-
try {
|
|
210
|
-
throw new Error("DEPRECATION: ".concat(message));
|
|
211
|
-
} catch (e) {
|
|
212
|
-
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.emitWarning === 'function') {
|
|
213
|
-
process.emitWarning("".concat(message, "\n").concat(e.stack));
|
|
214
|
-
} else {
|
|
215
|
-
console.warn("".concat(message, "\n").concat(e.stack));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function isEmptyString(string) {
|
|
221
|
-
return string === null || string === undefined || string === '';
|
|
222
|
-
}
|
package/lib/chord_symbol.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _chord_helpers = require("./chord_helpers");
|
|
11
|
-
|
|
12
|
-
var _chord = _interopRequireDefault(require("./chord"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
-
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
|
|
26
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
27
|
-
|
|
28
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
29
|
-
|
|
30
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
-
|
|
32
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
-
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Represents a chord symbol, such as Esus4
|
|
38
|
-
*/
|
|
39
|
-
var ChordSymbol = /*#__PURE__*/function (_Chord) {
|
|
40
|
-
_inherits(ChordSymbol, _Chord);
|
|
41
|
-
|
|
42
|
-
var _super = _createSuper(ChordSymbol);
|
|
43
|
-
|
|
44
|
-
function ChordSymbol() {
|
|
45
|
-
_classCallCheck(this, ChordSymbol);
|
|
46
|
-
|
|
47
|
-
return _super.apply(this, arguments);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_createClass(ChordSymbol, [{
|
|
51
|
-
key: "normalize",
|
|
52
|
-
value:
|
|
53
|
-
/**
|
|
54
|
-
* Normalizes the chord:
|
|
55
|
-
* - Fb becomes E
|
|
56
|
-
* - Cb becomes B
|
|
57
|
-
* - B# becomes C
|
|
58
|
-
* - E# becomes F
|
|
59
|
-
* If the chord is already normalized, this will return a copy.
|
|
60
|
-
* @returns {ChordSymbol} the normalized chord
|
|
61
|
-
*/
|
|
62
|
-
function normalize() {
|
|
63
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.normalize);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Switches between '#' and 'b' as modifiers. If
|
|
67
|
-
* @returns {ChordSymbol} the changed chord
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
}, {
|
|
71
|
-
key: "switchModifier",
|
|
72
|
-
value: function switchModifier() {
|
|
73
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.switchModifier);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Switches to the specified modifier
|
|
77
|
-
* @param newModifier the modifier to use: `'#'` or `'b'`
|
|
78
|
-
* @returns {ChordSymbol} the changed chord
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
}, {
|
|
82
|
-
key: "useModifier",
|
|
83
|
-
value: function useModifier(newModifier) {
|
|
84
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.useModifier, newModifier);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Transposes the chord up by 1 semitone. Eg. A becomes A#, Eb becomes E
|
|
88
|
-
* @returns {ChordSymbol} the transposed chord
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
}, {
|
|
92
|
-
key: "transposeUp",
|
|
93
|
-
value: function transposeUp() {
|
|
94
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.transposeUp);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Transposes the chord down by 1 semitone. Eg. A# becomes A, E becomes Eb
|
|
98
|
-
* @returns {ChordSymbol} the transposed chord
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
}, {
|
|
102
|
-
key: "transposeDown",
|
|
103
|
-
value: function transposeDown() {
|
|
104
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.transposeDown);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Transposes the chord by the specified number of semitones
|
|
108
|
-
* @param delta de number of semitones
|
|
109
|
-
* @returns {ChordSymbol} the transposed chord
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
}, {
|
|
113
|
-
key: "transpose",
|
|
114
|
-
value: function transpose(delta) {
|
|
115
|
-
return (0, _chord_helpers.processChord)(this, _chord_helpers.transpose, delta);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Convert the chord to a string, eg. `'Esus4/G#'`
|
|
119
|
-
* @returns {string|*}
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
}, {
|
|
123
|
-
key: "toString",
|
|
124
|
-
value: function toString() {
|
|
125
|
-
var chordString = this.base + (this.modifier || '') + (this.suffix || '');
|
|
126
|
-
|
|
127
|
-
if (this.bassBase) {
|
|
128
|
-
return "".concat(chordString, "/").concat(this.bassBase).concat(this.bassModifier || '');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return chordString;
|
|
132
|
-
}
|
|
133
|
-
}]);
|
|
134
|
-
|
|
135
|
-
return ChordSymbol;
|
|
136
|
-
}(_chord["default"]);
|
|
137
|
-
|
|
138
|
-
var _default = ChordSymbol;
|
|
139
|
-
exports["default"] = _default;
|
package/lib/numeric_chord.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _chord = _interopRequireDefault(require("./chord"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
|
-
|
|
20
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
-
|
|
22
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
-
|
|
24
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
-
|
|
26
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
-
|
|
28
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
29
|
-
|
|
30
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
|
|
32
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Represents a numeric chord, such as b3sus4
|
|
36
|
-
*/
|
|
37
|
-
var NumericChord = /*#__PURE__*/function (_Chord) {
|
|
38
|
-
_inherits(NumericChord, _Chord);
|
|
39
|
-
|
|
40
|
-
var _super = _createSuper(NumericChord);
|
|
41
|
-
|
|
42
|
-
function NumericChord(_ref) {
|
|
43
|
-
var base = _ref.base,
|
|
44
|
-
modifier = _ref.modifier,
|
|
45
|
-
suffix = _ref.suffix,
|
|
46
|
-
bassBase = _ref.bassBase,
|
|
47
|
-
bassModifier = _ref.bassModifier;
|
|
48
|
-
|
|
49
|
-
_classCallCheck(this, NumericChord);
|
|
50
|
-
|
|
51
|
-
return _super.call(this, {
|
|
52
|
-
base: parseInt(base, 10),
|
|
53
|
-
modifier: modifier,
|
|
54
|
-
suffix: suffix,
|
|
55
|
-
bassBase: parseInt(bassBase, 10),
|
|
56
|
-
bassModifier: bassModifier
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_createClass(NumericChord, [{
|
|
61
|
-
key: "toString",
|
|
62
|
-
value: function toString() {
|
|
63
|
-
var chordString = (this.modifier || '') + this.base + (this.suffix || '');
|
|
64
|
-
|
|
65
|
-
if (this.bassBase) {
|
|
66
|
-
return "".concat(chordString, "/").concat(this.bassModifier || '').concat(this.bassBase);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return chordString;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Normalizes the chord - this is a noop for numeric chords.
|
|
73
|
-
* @returns {NumericChord} a copy of the chord object
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
}, {
|
|
77
|
-
key: "normalize",
|
|
78
|
-
value: function normalize() {
|
|
79
|
-
return this.clone();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Switches between '#' and 'b' as modifiers - this is a noop for numeric chords.
|
|
83
|
-
* @returns {NumericChord} a copy of the chord object
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
}, {
|
|
87
|
-
key: "switchModifier",
|
|
88
|
-
value: function switchModifier() {
|
|
89
|
-
return this.clone();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Switches to the specified modifier - this is a noop for numeric chords.
|
|
93
|
-
* @returns {NumericChord} a copy of the chord object
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
}, {
|
|
97
|
-
key: "useModifier",
|
|
98
|
-
value: function useModifier() {
|
|
99
|
-
return this.clone();
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Transposes the chord up by 1 semitone - this is a noop for numeric chords.
|
|
103
|
-
* @returns {NumericChord} a copy of the chord object
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
}, {
|
|
107
|
-
key: "transposeUp",
|
|
108
|
-
value: function transposeUp() {
|
|
109
|
-
return this.clone();
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Transposes the chord down by 1 semitone - this is a noop for numeric chords.
|
|
113
|
-
* @returns {NumericChord} a copy of the chord object
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
}, {
|
|
117
|
-
key: "transposeDown",
|
|
118
|
-
value: function transposeDown() {
|
|
119
|
-
return this.clone();
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Transposes the chord by the specified number of semitones - this is a noop for numeric chords.
|
|
123
|
-
* @param delta de number of semitones
|
|
124
|
-
* @returns {NumericChord} a copy of the chord object
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
}, {
|
|
128
|
-
key: "transpose",
|
|
129
|
-
value: function transpose() {
|
|
130
|
-
return this.clone();
|
|
131
|
-
}
|
|
132
|
-
}]);
|
|
133
|
-
|
|
134
|
-
return NumericChord;
|
|
135
|
-
}(_chord["default"]);
|
|
136
|
-
|
|
137
|
-
var _default = NumericChord;
|
|
138
|
-
exports["default"] = _default;
|