chordsheetjs 4.8.0 → 5.0.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 +164 -138
- package/lib/chord.js +338 -32
- package/lib/chord_sheet/metadata.js +3 -3
- package/lib/chord_sheet/song.js +8 -0
- package/lib/chord_sheet/tag.js +20 -4
- package/lib/constants.js +14 -2
- package/lib/index.js +33 -10
- package/lib/key.js +292 -0
- package/lib/note.js +132 -0
- package/lib/parser/ultimate_guitar_parser.js +1 -1
- package/lib/utilities.js +22 -9
- package/package.json +4 -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
package/lib/key.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
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 _note = _interopRequireDefault(require("./note"));
|
|
11
|
+
|
|
12
|
+
var _constants = require("./constants");
|
|
13
|
+
|
|
14
|
+
var _MODIFIER_TRANSPOSITI;
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
+
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
+
|
|
24
|
+
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); } }
|
|
25
|
+
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
27
|
+
|
|
28
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
29
|
+
|
|
30
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
31
|
+
|
|
32
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
33
|
+
|
|
34
|
+
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); _groups.set(_this, groups || _groups.get(re)); return _setPrototypeOf(_this, BabelRegExp.prototype); } _inherits(BabelRegExp, RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; if (_typeof(args[args.length - 1]) !== "object") { args = [].slice.call(args); args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
|
|
35
|
+
|
|
36
|
+
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); }
|
|
37
|
+
|
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
+
|
|
40
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
41
|
+
|
|
42
|
+
var FLAT = 'b';
|
|
43
|
+
var SHARP = '#';
|
|
44
|
+
var MODIFIER_TRANSPOSITION = (_MODIFIER_TRANSPOSITI = {}, _defineProperty(_MODIFIER_TRANSPOSITI, SHARP, 1), _defineProperty(_MODIFIER_TRANSPOSITI, FLAT, -1), _MODIFIER_TRANSPOSITI);
|
|
45
|
+
|
|
46
|
+
var symbolKeyRegex = /*#__PURE__*/_wrapRegExp(/^([A-G])(#|b)?$/i, {
|
|
47
|
+
note: 1,
|
|
48
|
+
modifier: 2
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var numericKeyRegex = /*#__PURE__*/_wrapRegExp(/^(#|b)?([1-7])$/, {
|
|
52
|
+
modifier: 1,
|
|
53
|
+
note: 2
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var regexes = [symbolKeyRegex, numericKeyRegex];
|
|
57
|
+
|
|
58
|
+
var _set = /*#__PURE__*/new WeakSet();
|
|
59
|
+
|
|
60
|
+
var Key = /*#__PURE__*/function () {
|
|
61
|
+
function Key(_ref) {
|
|
62
|
+
var note = _ref.note,
|
|
63
|
+
_ref$modifier = _ref.modifier,
|
|
64
|
+
modifier = _ref$modifier === void 0 ? null : _ref$modifier;
|
|
65
|
+
|
|
66
|
+
_classCallCheck(this, Key);
|
|
67
|
+
|
|
68
|
+
_classPrivateMethodInitSpec(this, _set);
|
|
69
|
+
|
|
70
|
+
this.note = note instanceof _note["default"] ? note : new _note["default"](note);
|
|
71
|
+
this.modifier = modifier || null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_createClass(Key, [{
|
|
75
|
+
key: "clone",
|
|
76
|
+
value: function clone() {
|
|
77
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {});
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "toChordSymbol",
|
|
81
|
+
value: function toChordSymbol(key) {
|
|
82
|
+
if (this.is(_constants.SYMBOL)) {
|
|
83
|
+
return this.clone();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var transposeDistance = this.note.getTransposeDistance() + (MODIFIER_TRANSPOSITION[this.modifier] || 0);
|
|
87
|
+
return key.transpose(transposeDistance).normalize().useModifier(key.modifier);
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "toChordSymbolString",
|
|
91
|
+
value: function toChordSymbolString(key) {
|
|
92
|
+
return this.toChordSymbol(key).toString();
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "is",
|
|
96
|
+
value: function is(type) {
|
|
97
|
+
return this.note.is(type);
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "isNumeric",
|
|
101
|
+
value: function isNumeric() {
|
|
102
|
+
return this.is(_constants.NUMERIC);
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "isChordSymbol",
|
|
106
|
+
value: function isChordSymbol() {
|
|
107
|
+
return this.is(_constants.SYMBOL);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "toNumeric",
|
|
111
|
+
value: function toNumeric(key) {
|
|
112
|
+
if (this.isNumeric()) {
|
|
113
|
+
return this.clone();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var numericKey = new Key({
|
|
117
|
+
note: 1
|
|
118
|
+
});
|
|
119
|
+
var symbolKey = key.clone();
|
|
120
|
+
var reference = this.clone().normalize().useModifier(key.modifier);
|
|
121
|
+
|
|
122
|
+
while (!symbolKey.equals(reference)) {
|
|
123
|
+
numericKey = numericKey.transposeUp().useModifier(key.modifier);
|
|
124
|
+
symbolKey = symbolKey.transposeUp().normalize().useModifier(key.modifier);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return numericKey;
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "equals",
|
|
131
|
+
value: function equals(_ref2) {
|
|
132
|
+
var note = _ref2.note,
|
|
133
|
+
modifier = _ref2.modifier;
|
|
134
|
+
return this.note.equals(note) && this.modifier === modifier;
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "toNumericString",
|
|
138
|
+
value: function toNumericString(key) {
|
|
139
|
+
return this.toNumeric(key).toString();
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "toString",
|
|
143
|
+
value: function toString() {
|
|
144
|
+
if (this.is(_constants.NUMERIC)) {
|
|
145
|
+
return "".concat(this.modifier || '').concat(this.note);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return "".concat(this.note).concat(this.modifier || '');
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "transpose",
|
|
152
|
+
value: function transpose(delta) {
|
|
153
|
+
if (delta === 0) {
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var originalModifier = this.modifier;
|
|
158
|
+
var transposedKey = this.clone();
|
|
159
|
+
var func = delta < 0 ? 'transposeDown' : 'transposeUp';
|
|
160
|
+
|
|
161
|
+
for (var i = 0, count = Math.abs(delta); i < count; i += 1) {
|
|
162
|
+
transposedKey = transposedKey[func]();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return transposedKey.useModifier(originalModifier);
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "transposeUp",
|
|
169
|
+
value: function transposeUp() {
|
|
170
|
+
if (this.modifier === FLAT) {
|
|
171
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
172
|
+
modifier: null
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (this.note.isOneOf(3, 7, 'E', 'B')) {
|
|
177
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
178
|
+
note: this.note.up()
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (this.modifier === SHARP) {
|
|
183
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
184
|
+
note: this.note.up(),
|
|
185
|
+
modifier: null
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
190
|
+
modifier: SHARP
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "transposeDown",
|
|
195
|
+
value: function transposeDown() {
|
|
196
|
+
if (this.modifier === SHARP) {
|
|
197
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
198
|
+
modifier: null
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (this.note.isOneOf(1, 4, 'C', 'F')) {
|
|
203
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
204
|
+
note: this.note.down()
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (this.modifier === FLAT) {
|
|
209
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
210
|
+
note: this.note.down(),
|
|
211
|
+
modifier: null
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
216
|
+
modifier: FLAT
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "useModifier",
|
|
221
|
+
value: function useModifier(newModifier) {
|
|
222
|
+
if (this.modifier === FLAT && newModifier === SHARP) {
|
|
223
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
224
|
+
note: this.note.down(),
|
|
225
|
+
modifier: SHARP
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (this.modifier === SHARP && newModifier === FLAT) {
|
|
230
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
231
|
+
note: this.note.up(),
|
|
232
|
+
modifier: FLAT
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return this.clone();
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "normalize",
|
|
240
|
+
value: function normalize() {
|
|
241
|
+
if (this.modifier === SHARP && this.note.isOneOf(3, 7, 'E', 'B')) {
|
|
242
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
243
|
+
note: this.note.up(),
|
|
244
|
+
modifier: null
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (this.modifier === FLAT && this.note.isOneOf(1, 4, 'C', 'F')) {
|
|
249
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
250
|
+
note: this.note.down(),
|
|
251
|
+
modifier: null
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return this.clone();
|
|
256
|
+
}
|
|
257
|
+
}], [{
|
|
258
|
+
key: "parse",
|
|
259
|
+
value: function parse(keyString) {
|
|
260
|
+
for (var i = 0, count = regexes.length; i < count; i += 1) {
|
|
261
|
+
var match = keyString.match(regexes[i]);
|
|
262
|
+
|
|
263
|
+
if (match) {
|
|
264
|
+
return new Key(match.groups);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "wrap",
|
|
272
|
+
value: function wrap(keyStringOrObject) {
|
|
273
|
+
if (keyStringOrObject instanceof Key) {
|
|
274
|
+
return keyStringOrObject;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return this.parse(keyStringOrObject);
|
|
278
|
+
}
|
|
279
|
+
}]);
|
|
280
|
+
|
|
281
|
+
return Key;
|
|
282
|
+
}();
|
|
283
|
+
|
|
284
|
+
function _set2(attributes) {
|
|
285
|
+
return new this.constructor(_objectSpread({
|
|
286
|
+
note: this.note.clone(),
|
|
287
|
+
modifier: this.modifier
|
|
288
|
+
}, attributes));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
var _default = Key;
|
|
292
|
+
exports["default"] = _default;
|
package/lib/note.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
|
|
12
|
+
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); } }
|
|
13
|
+
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
|
+
|
|
16
|
+
var A = 'A'.charCodeAt(0);
|
|
17
|
+
var G = 'G'.charCodeAt(0);
|
|
18
|
+
var TRANSPOSE_DISTANCE = [null, 0, 2, 4, 5, 7, 9, 11];
|
|
19
|
+
|
|
20
|
+
function keyToCharCode(key) {
|
|
21
|
+
return key.toUpperCase().charCodeAt(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function clamp(note, min, max) {
|
|
25
|
+
var newNote = note;
|
|
26
|
+
|
|
27
|
+
if (newNote < min) {
|
|
28
|
+
newNote += 7;
|
|
29
|
+
} else if (newNote > max) {
|
|
30
|
+
newNote -= 7;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return newNote;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var Note = /*#__PURE__*/function () {
|
|
37
|
+
function Note(note) {
|
|
38
|
+
_classCallCheck(this, Note);
|
|
39
|
+
|
|
40
|
+
if (/^[A-Ga-g]$/.test(note)) {
|
|
41
|
+
this.note = note.toUpperCase();
|
|
42
|
+
this.type = _constants.SYMBOL;
|
|
43
|
+
} else if (/^[1-7]$/.test(note)) {
|
|
44
|
+
this.note = parseInt(note, 10);
|
|
45
|
+
this.type = _constants.NUMERIC;
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error("Invalid note ".concat(note));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_createClass(Note, [{
|
|
52
|
+
key: "equals",
|
|
53
|
+
value: function equals(otherNote) {
|
|
54
|
+
return this.note === otherNote.note && this.type === otherNote.type;
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "clone",
|
|
58
|
+
value: function clone() {
|
|
59
|
+
return new this.constructor(this.note);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "up",
|
|
63
|
+
value: function up() {
|
|
64
|
+
return this.change(1);
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "down",
|
|
68
|
+
value: function down() {
|
|
69
|
+
return this.change(-1);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "isOneOf",
|
|
73
|
+
value: function isOneOf() {
|
|
74
|
+
for (var _len = arguments.length, options = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
|
+
options[_key] = arguments[_key];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return options.includes(this.note);
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "isNumeric",
|
|
82
|
+
value: function isNumeric() {
|
|
83
|
+
return this.is(_constants.NUMERIC);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "isChordSymbol",
|
|
87
|
+
value: function isChordSymbol() {
|
|
88
|
+
return this.is(_constants.SYMBOL);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "is",
|
|
92
|
+
value: function is(noteType) {
|
|
93
|
+
return this.type === noteType;
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "getTransposeDistance",
|
|
97
|
+
value: function getTransposeDistance() {
|
|
98
|
+
return TRANSPOSE_DISTANCE[this.note];
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "change",
|
|
102
|
+
value: function change(delta) {
|
|
103
|
+
if (this.isNumeric()) {
|
|
104
|
+
var newNote = clamp(this.note + delta, 1, 7);
|
|
105
|
+
|
|
106
|
+
if (newNote < 1) {
|
|
107
|
+
newNote += 7;
|
|
108
|
+
} else if (newNote > 7) {
|
|
109
|
+
newNote -= 7;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return new Note(newNote);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var charCode;
|
|
116
|
+
charCode = keyToCharCode(this.note);
|
|
117
|
+
charCode += delta;
|
|
118
|
+
charCode = clamp(charCode, A, G);
|
|
119
|
+
return new Note(String.fromCharCode(charCode));
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "toString",
|
|
123
|
+
value: function toString() {
|
|
124
|
+
return "".concat(this.note);
|
|
125
|
+
}
|
|
126
|
+
}]);
|
|
127
|
+
|
|
128
|
+
return Note;
|
|
129
|
+
}();
|
|
130
|
+
|
|
131
|
+
var _default = Note;
|
|
132
|
+
exports["default"] = _default;
|
|
@@ -27,7 +27,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
27
27
|
|
|
28
28
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
29
29
|
|
|
30
|
-
function _get(
|
|
30
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
31
31
|
|
|
32
32
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
33
33
|
|
package/lib/utilities.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.deprecate = deprecate;
|
|
7
|
+
exports.hasTextContents = 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
12
|
var _chord_lyrics_pair = _interopRequireDefault(require("./chord_sheet/chord_lyrics_pair"));
|
|
@@ -12,6 +15,8 @@ var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
|
|
|
12
15
|
|
|
13
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
17
|
|
|
18
|
+
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); }
|
|
19
|
+
|
|
15
20
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
21
|
|
|
17
22
|
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."); }
|
|
@@ -66,14 +71,6 @@ var padLeft = function padLeft(str, length) {
|
|
|
66
71
|
|
|
67
72
|
exports.padLeft = padLeft;
|
|
68
73
|
|
|
69
|
-
var deprecate = function deprecate(message) {
|
|
70
|
-
if (process && process.emitWarning) {
|
|
71
|
-
process.emitWarning(message);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.deprecate = deprecate;
|
|
76
|
-
|
|
77
74
|
var isPresent = function isPresent(object) {
|
|
78
75
|
return object && object.length > 0;
|
|
79
76
|
};
|
|
@@ -108,4 +105,20 @@ function scopeCss(css, scope) {
|
|
|
108
105
|
var scopedSelector = "".concat(scope, " ").concat(selector).trim();
|
|
109
106
|
return "\n".concat(scopedSelector, " {\n ").concat(rules, "\n}").substring(1);
|
|
110
107
|
}).join('\n\n');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function deprecate(message) {
|
|
111
|
+
try {
|
|
112
|
+
throw new Error("DEPRECATION: ".concat(message));
|
|
113
|
+
} catch (e) {
|
|
114
|
+
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.emitWarning === 'function') {
|
|
115
|
+
process.emitWarning("".concat(message, "\n").concat(e.stack));
|
|
116
|
+
} else {
|
|
117
|
+
console.warn("".concat(message, "\n").concat(e.stack));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function isEmptyString(string) {
|
|
123
|
+
return string === null || string === undefined || string === '';
|
|
111
124
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chordsheetjs",
|
|
3
3
|
"author": "Martijn Versluis",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"description": "A JavaScript library for parsing and formatting chord sheets",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"babel-eslint": "^10.1.0",
|
|
21
21
|
"babel-plugin-handlebars-inline-precompile": "^2.1.1",
|
|
22
22
|
"eslint": "^7.2.0",
|
|
23
|
-
"eslint-config-airbnb-base": "^
|
|
23
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
24
24
|
"eslint-plugin-import": "^2.21.2",
|
|
25
25
|
"jest": "^27.0.1",
|
|
26
|
-
"jsdoc-to-markdown": "^7.0
|
|
26
|
+
"jsdoc-to-markdown": "^7.1.0",
|
|
27
27
|
"pegjs": "^0.10.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"jest": "jest",
|
|
31
31
|
"test": "yarn lint && yarn jest",
|
|
32
|
-
"lint": "yarn build:pegjs && node_modules/.bin/eslint --ext .js .",
|
|
32
|
+
"lint": "yarn build:templates && yarn build:pegjs && node_modules/.bin/eslint --ext .js .",
|
|
33
33
|
"lint:fix": "node_modules/.bin/eslint --fix --ext .js .",
|
|
34
34
|
"build:template": "handlebars \"src/formatter/templates/$TEMPLATE.handlebars\" -f \"src/formatter/templates/$TEMPLATE.js\" --known each --known if --known with --known paragraphClasses --known isChordLyricsPair --known isTag --known isComment --known shouldRenderLine --known hasChordContents --known lineHasContents --known lineClasses --known toUpperCase --known paragraphClasses --commonjs handlebars",
|
|
35
35
|
"build:templates": "TEMPLATE=html_div_formatter yarn build:template && TEMPLATE=html_table_formatter yarn build:template",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"pretest": "yarn build:templates && yarn build:pegjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"chordjs": "^2.0.0",
|
|
45
44
|
"handlebars": "^4.7.6"
|
|
46
45
|
}
|
|
47
46
|
}
|