chordsheetjs 6.2.2 → 6.3.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 +58 -1
- package/lib/bundle.js +73 -37
- package/lib/index.js +73 -37
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +45 -12
- package/lib/main.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ChordSheetJS [](https://codeclimate.com/github/martijnversluis/ChordSheetJS)
|
|
2
2
|
|
|
3
3
|
A JavaScript library for parsing and formatting chord sheets
|
|
4
4
|
|
|
@@ -11,6 +11,8 @@ A JavaScript library for parsing and formatting chord sheets
|
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
|
+
### Package managers
|
|
15
|
+
|
|
14
16
|
`ChordSheetJS` is on npm, to install run:
|
|
15
17
|
|
|
16
18
|
```bash
|
|
@@ -631,10 +633,13 @@ If not, it returns [INDETERMINATE](#INDETERMINATE)</p>
|
|
|
631
633
|
* [new Song(metadata)](#new_Song_new)
|
|
632
634
|
* [.bodyLines](#Song+bodyLines) ⇒ <code>Array.<Line></code>
|
|
633
635
|
* [.bodyParagraphs](#Song+bodyParagraphs) ⇒ [<code>Array.<Paragraph></code>](#Paragraph)
|
|
636
|
+
* [.paragraphs](#Song+paragraphs) : [<code>Array.<Paragraph></code>](#Paragraph)
|
|
634
637
|
* ~~[.metaData](#Song+metaData) ⇒~~
|
|
635
638
|
* [.clone()](#Song+clone) ⇒ [<code>Song</code>](#Song)
|
|
636
639
|
* [.setCapo(capo)](#Song+setCapo) ⇒ [<code>Song</code>](#Song)
|
|
637
640
|
* [.setKey(key)](#Song+setKey) ⇒ [<code>Song</code>](#Song)
|
|
641
|
+
* [.mapItems(func)](#Song+mapItems) ⇒ [<code>Song</code>](#Song)
|
|
642
|
+
* [.mapLines(func)](#Song+mapLines) ⇒ [<code>Song</code>](#Song)
|
|
638
643
|
|
|
639
644
|
<a name="new_Song_new"></a>
|
|
640
645
|
|
|
@@ -662,6 +667,12 @@ if you want to skip the "header lines": the lines that only contain me
|
|
|
662
667
|
|
|
663
668
|
**Kind**: instance property of [<code>Song</code>](#Song)
|
|
664
669
|
**See**: [bodyLines](bodyLines)
|
|
670
|
+
<a name="Song+paragraphs"></a>
|
|
671
|
+
|
|
672
|
+
### song.paragraphs : [<code>Array.<Paragraph></code>](#Paragraph)
|
|
673
|
+
<p>The [Paragraph](#Paragraph) items of which the song consists</p>
|
|
674
|
+
|
|
675
|
+
**Kind**: instance property of [<code>Song</code>](#Song)
|
|
665
676
|
<a name="Song+metaData"></a>
|
|
666
677
|
|
|
667
678
|
### ~~song.metaData ⇒~~
|
|
@@ -711,6 +722,52 @@ if you want to skip the "header lines": the lines that only contain me
|
|
|
711
722
|
| --- | --- | --- |
|
|
712
723
|
| key | <code>string</code> | <p>The new key.</p> |
|
|
713
724
|
|
|
725
|
+
<a name="Song+mapItems"></a>
|
|
726
|
+
|
|
727
|
+
### song.mapItems(func) ⇒ [<code>Song</code>](#Song)
|
|
728
|
+
<p>Change the song contents inline. Return a new [Item](Item) to replace it. Return <code>null</code> to remove it.</p>
|
|
729
|
+
|
|
730
|
+
**Kind**: instance method of [<code>Song</code>](#Song)
|
|
731
|
+
**Returns**: [<code>Song</code>](#Song) - <p>the changed song</p>
|
|
732
|
+
|
|
733
|
+
| Param | Type | Description |
|
|
734
|
+
| --- | --- | --- |
|
|
735
|
+
| func | <code>MapItemsCallback</code> | <p>the callback function</p> |
|
|
736
|
+
|
|
737
|
+
**Example**
|
|
738
|
+
```js
|
|
739
|
+
// transpose all chords:
|
|
740
|
+
song.mapItems((item) => {
|
|
741
|
+
if (item instanceof ChordLyricsPair) {
|
|
742
|
+
return item.transpose(2, 'D');
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
return item;
|
|
746
|
+
});
|
|
747
|
+
```
|
|
748
|
+
<a name="Song+mapLines"></a>
|
|
749
|
+
|
|
750
|
+
### song.mapLines(func) ⇒ [<code>Song</code>](#Song)
|
|
751
|
+
<p>Change the song contents inline. Return a new [Line](Line) to replace it. Return <code>null</code> to remove it.</p>
|
|
752
|
+
|
|
753
|
+
**Kind**: instance method of [<code>Song</code>](#Song)
|
|
754
|
+
**Returns**: [<code>Song</code>](#Song) - <p>the changed song</p>
|
|
755
|
+
|
|
756
|
+
| Param | Type | Description |
|
|
757
|
+
| --- | --- | --- |
|
|
758
|
+
| func | <code>MapLinesCallback</code> | <p>the callback function</p> |
|
|
759
|
+
|
|
760
|
+
**Example**
|
|
761
|
+
```js
|
|
762
|
+
// remove lines with only Tags:
|
|
763
|
+
song.mapLines((line) => {
|
|
764
|
+
if (line.items.every(item => item instanceof Tag)) {
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
return line;
|
|
769
|
+
});
|
|
770
|
+
```
|
|
714
771
|
<a name="Tag"></a>
|
|
715
772
|
|
|
716
773
|
## Tag
|
package/lib/bundle.js
CHANGED
|
@@ -3388,6 +3388,11 @@ var $26f57998457eb2d4$export$2e2bcd8739ae039 = $26f57998457eb2d4$var$Chord;
|
|
|
3388
3388
|
set(properties) {
|
|
3389
3389
|
return new $d454f4215ba01af2$var$ChordLyricsPair(properties.chords || this.chords, properties.lyrics || this.lyrics);
|
|
3390
3390
|
}
|
|
3391
|
+
setLyrics(lyrics) {
|
|
3392
|
+
return this.set({
|
|
3393
|
+
lyrics: lyrics
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3391
3396
|
transpose(delta, key) {
|
|
3392
3397
|
const chordObj = $26f57998457eb2d4$export$2e2bcd8739ae039.parse(this.chords);
|
|
3393
3398
|
if (chordObj) return this.set({
|
|
@@ -3564,6 +3569,11 @@ const $5e9ede69210ec54a$var$translateTagNameAlias = (name)=>{
|
|
|
3564
3569
|
set({ value: value }) {
|
|
3565
3570
|
return new $5e9ede69210ec54a$var$Tag(this._originalName, value);
|
|
3566
3571
|
}
|
|
3572
|
+
setValue(value) {
|
|
3573
|
+
return this.set({
|
|
3574
|
+
value: value
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3567
3577
|
}
|
|
3568
3578
|
var $5e9ede69210ec54a$export$2e2bcd8739ae039 = $5e9ede69210ec54a$var$Tag;
|
|
3569
3579
|
|
|
@@ -3962,12 +3972,7 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
3962
3972
|
* The {@link Line} items of which the song consists
|
|
3963
3973
|
* @member {Line[]}
|
|
3964
3974
|
*/ lines = [];
|
|
3965
|
-
/**
|
|
3966
|
-
* The {@link Paragraph} items of which the song consists
|
|
3967
|
-
* @member {Paragraph[]}
|
|
3968
|
-
*/ paragraphs = [];
|
|
3969
3975
|
currentLine = null;
|
|
3970
|
-
currentParagraph = null;
|
|
3971
3976
|
warnings = [];
|
|
3972
3977
|
sectionType = $af8d31735c159a26$export$c53d0f541b41b88e;
|
|
3973
3978
|
currentKey = null;
|
|
@@ -4016,37 +4021,35 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4016
4021
|
this.ensureLine();
|
|
4017
4022
|
this.currentLine.lyrics(chr);
|
|
4018
4023
|
}
|
|
4019
|
-
addLine() {
|
|
4020
|
-
this.
|
|
4021
|
-
this.flushLine();
|
|
4022
|
-
this.currentLine = $21a34a464e7bc609$export$13215d9ce4923f76(this.lines, $bc411321e9739719$export$2e2bcd8739ae039);
|
|
4024
|
+
addLine(line) {
|
|
4025
|
+
this.currentLine = line || $21a34a464e7bc609$export$13215d9ce4923f76(this.lines, $bc411321e9739719$export$2e2bcd8739ae039);
|
|
4023
4026
|
this.setCurrentLineType(this.sectionType);
|
|
4024
4027
|
this.currentLine.transposeKey = this.transposeKey ?? this.currentKey;
|
|
4025
4028
|
this.currentLine.key = this.currentKey || this.metadata.getSingle($5e9ede69210ec54a$export$7167c830cefcb6b5);
|
|
4026
4029
|
return this.currentLine;
|
|
4027
4030
|
}
|
|
4031
|
+
/**
|
|
4032
|
+
* The {@link Paragraph} items of which the song consists
|
|
4033
|
+
* @member {Paragraph[]}
|
|
4034
|
+
*/ get paragraphs() {
|
|
4035
|
+
let currentParagraph = new $0c3420c6a3e8a9d7$export$2e2bcd8739ae039();
|
|
4036
|
+
const paragraphs = [
|
|
4037
|
+
currentParagraph
|
|
4038
|
+
];
|
|
4039
|
+
this.lines.forEach((line)=>{
|
|
4040
|
+
if (line.isEmpty()) {
|
|
4041
|
+
currentParagraph = new $0c3420c6a3e8a9d7$export$2e2bcd8739ae039();
|
|
4042
|
+
paragraphs.push(currentParagraph);
|
|
4043
|
+
} else if (line.hasRenderableItems()) currentParagraph.addLine(line);
|
|
4044
|
+
});
|
|
4045
|
+
return paragraphs;
|
|
4046
|
+
}
|
|
4028
4047
|
setCurrentLineType(sectionType) {
|
|
4029
4048
|
this.currentLine.type = sectionType;
|
|
4030
4049
|
}
|
|
4031
|
-
flushLine() {
|
|
4032
|
-
if (this.currentLine !== null) {
|
|
4033
|
-
if (this.currentLine.isEmpty()) this.addParagraph();
|
|
4034
|
-
else if (this.currentLine.hasRenderableItems()) this.currentParagraph.addLine(this.currentLine);
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
|
-
finish() {
|
|
4038
|
-
this.flushLine();
|
|
4039
|
-
}
|
|
4040
4050
|
ensureLine() {
|
|
4041
4051
|
if (this.currentLine === null) this.addLine();
|
|
4042
4052
|
}
|
|
4043
|
-
addParagraph() {
|
|
4044
|
-
this.currentParagraph = $21a34a464e7bc609$export$13215d9ce4923f76(this.paragraphs, $0c3420c6a3e8a9d7$export$2e2bcd8739ae039);
|
|
4045
|
-
return this.currentParagraph;
|
|
4046
|
-
}
|
|
4047
|
-
ensureParagraph() {
|
|
4048
|
-
if (this.currentParagraph === null) this.addParagraph();
|
|
4049
|
-
}
|
|
4050
4053
|
addTag(tagContents) {
|
|
4051
4054
|
const tag = $5e9ede69210ec54a$export$2e2bcd8739ae039.parse(tagContents);
|
|
4052
4055
|
if (tag.isMetaTag()) this.setMetadata(tag.name, tag.value);
|
|
@@ -4108,7 +4111,8 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4108
4111
|
* Returns a deep clone of the song
|
|
4109
4112
|
* @returns {Song} The cloned song
|
|
4110
4113
|
*/ clone() {
|
|
4111
|
-
return this.mapItems(
|
|
4114
|
+
return this.mapItems((item)=>item
|
|
4115
|
+
);
|
|
4112
4116
|
}
|
|
4113
4117
|
setMetadata(name, value) {
|
|
4114
4118
|
this.metadata.add(name, value);
|
|
@@ -4179,19 +4183,53 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4179
4183
|
];
|
|
4180
4184
|
return clonedSong;
|
|
4181
4185
|
}
|
|
4182
|
-
|
|
4186
|
+
/**
|
|
4187
|
+
* Change the song contents inline. Return a new {@link Item} to replace it. Return `null` to remove it.
|
|
4188
|
+
* @example
|
|
4189
|
+
* // transpose all chords:
|
|
4190
|
+
* song.mapItems((item) => {
|
|
4191
|
+
* if (item instanceof ChordLyricsPair) {
|
|
4192
|
+
* return item.transpose(2, 'D');
|
|
4193
|
+
* }
|
|
4194
|
+
*
|
|
4195
|
+
* return item;
|
|
4196
|
+
* });
|
|
4197
|
+
* @param {MapItemsCallback} func the callback function
|
|
4198
|
+
* @returns {Song} the changed song
|
|
4199
|
+
*/ mapItems(func) {
|
|
4183
4200
|
const clonedSong = new $6f653df65dfdf4ef$var$Song();
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4201
|
+
this.lines.forEach((line)=>{
|
|
4202
|
+
clonedSong.addLine();
|
|
4203
|
+
line.items.forEach((item)=>{
|
|
4204
|
+
const changedItem = func(item);
|
|
4205
|
+
if (changedItem) clonedSong.addItem(changedItem);
|
|
4206
|
+
});
|
|
4207
|
+
});
|
|
4187
4208
|
return clonedSong;
|
|
4188
4209
|
}
|
|
4189
|
-
|
|
4210
|
+
/**
|
|
4211
|
+
* Change the song contents inline. Return a new {@link Line} to replace it. Return `null` to remove it.
|
|
4212
|
+
* @example
|
|
4213
|
+
* // remove lines with only Tags:
|
|
4214
|
+
* song.mapLines((line) => {
|
|
4215
|
+
* if (line.items.every(item => item instanceof Tag)) {
|
|
4216
|
+
* return null;
|
|
4217
|
+
* }
|
|
4218
|
+
*
|
|
4219
|
+
* return line;
|
|
4220
|
+
* });
|
|
4221
|
+
* @param {MapLinesCallback} func the callback function
|
|
4222
|
+
* @returns {Song} the changed song
|
|
4223
|
+
*/ mapLines(func) {
|
|
4190
4224
|
const clonedSong = new $6f653df65dfdf4ef$var$Song();
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4225
|
+
this.lines.forEach((line)=>{
|
|
4226
|
+
const changedLine = func(line);
|
|
4227
|
+
if (changedLine) {
|
|
4228
|
+
clonedSong.addLine();
|
|
4229
|
+
changedLine.items.forEach((item)=>clonedSong.addItem(item)
|
|
4230
|
+
);
|
|
4231
|
+
}
|
|
4232
|
+
});
|
|
4195
4233
|
return clonedSong;
|
|
4196
4234
|
}
|
|
4197
4235
|
updateItem(findCallback, updateCallback, notFoundCallback) {
|
|
@@ -4394,7 +4432,6 @@ const $1c14afc274b727b7$var$LINE = 'line';
|
|
|
4394
4432
|
* @returns {Song} The deserialized song
|
|
4395
4433
|
*/ deserialize(serializedSong) {
|
|
4396
4434
|
this.parseAstComponent(serializedSong);
|
|
4397
|
-
this.song.finish();
|
|
4398
4435
|
return this.song;
|
|
4399
4436
|
}
|
|
4400
4437
|
parseAstComponent(astComponent) {
|
|
@@ -4528,7 +4565,6 @@ const $c049675f48c823b2$var$CHORD_LINE_REGEX = /^\s*((([A-G])(#|b)?([^/\s]*)(\/(
|
|
|
4528
4565
|
this.parseLine(line);
|
|
4529
4566
|
}
|
|
4530
4567
|
this.endOfSong();
|
|
4531
|
-
this.song.finish();
|
|
4532
4568
|
return this.song;
|
|
4533
4569
|
}
|
|
4534
4570
|
endOfSong() {}
|
package/lib/index.js
CHANGED
|
@@ -3387,6 +3387,11 @@ var $26f57998457eb2d4$export$2e2bcd8739ae039 = $26f57998457eb2d4$var$Chord;
|
|
|
3387
3387
|
set(properties) {
|
|
3388
3388
|
return new $d454f4215ba01af2$var$ChordLyricsPair(properties.chords || this.chords, properties.lyrics || this.lyrics);
|
|
3389
3389
|
}
|
|
3390
|
+
setLyrics(lyrics) {
|
|
3391
|
+
return this.set({
|
|
3392
|
+
lyrics: lyrics
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3390
3395
|
transpose(delta, key) {
|
|
3391
3396
|
const chordObj = $26f57998457eb2d4$export$2e2bcd8739ae039.parse(this.chords);
|
|
3392
3397
|
if (chordObj) return this.set({
|
|
@@ -3563,6 +3568,11 @@ const $5e9ede69210ec54a$var$translateTagNameAlias = (name)=>{
|
|
|
3563
3568
|
set({ value: value }) {
|
|
3564
3569
|
return new $5e9ede69210ec54a$var$Tag(this._originalName, value);
|
|
3565
3570
|
}
|
|
3571
|
+
setValue(value) {
|
|
3572
|
+
return this.set({
|
|
3573
|
+
value: value
|
|
3574
|
+
});
|
|
3575
|
+
}
|
|
3566
3576
|
}
|
|
3567
3577
|
var $5e9ede69210ec54a$export$2e2bcd8739ae039 = $5e9ede69210ec54a$var$Tag;
|
|
3568
3578
|
|
|
@@ -3961,12 +3971,7 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
3961
3971
|
* The {@link Line} items of which the song consists
|
|
3962
3972
|
* @member {Line[]}
|
|
3963
3973
|
*/ lines = [];
|
|
3964
|
-
/**
|
|
3965
|
-
* The {@link Paragraph} items of which the song consists
|
|
3966
|
-
* @member {Paragraph[]}
|
|
3967
|
-
*/ paragraphs = [];
|
|
3968
3974
|
currentLine = null;
|
|
3969
|
-
currentParagraph = null;
|
|
3970
3975
|
warnings = [];
|
|
3971
3976
|
sectionType = $af8d31735c159a26$export$c53d0f541b41b88e;
|
|
3972
3977
|
currentKey = null;
|
|
@@ -4015,37 +4020,35 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4015
4020
|
this.ensureLine();
|
|
4016
4021
|
this.currentLine.lyrics(chr);
|
|
4017
4022
|
}
|
|
4018
|
-
addLine() {
|
|
4019
|
-
this.
|
|
4020
|
-
this.flushLine();
|
|
4021
|
-
this.currentLine = $21a34a464e7bc609$export$13215d9ce4923f76(this.lines, $bc411321e9739719$export$2e2bcd8739ae039);
|
|
4023
|
+
addLine(line) {
|
|
4024
|
+
this.currentLine = line || $21a34a464e7bc609$export$13215d9ce4923f76(this.lines, $bc411321e9739719$export$2e2bcd8739ae039);
|
|
4022
4025
|
this.setCurrentLineType(this.sectionType);
|
|
4023
4026
|
this.currentLine.transposeKey = this.transposeKey ?? this.currentKey;
|
|
4024
4027
|
this.currentLine.key = this.currentKey || this.metadata.getSingle($5e9ede69210ec54a$export$7167c830cefcb6b5);
|
|
4025
4028
|
return this.currentLine;
|
|
4026
4029
|
}
|
|
4030
|
+
/**
|
|
4031
|
+
* The {@link Paragraph} items of which the song consists
|
|
4032
|
+
* @member {Paragraph[]}
|
|
4033
|
+
*/ get paragraphs() {
|
|
4034
|
+
let currentParagraph = new $0c3420c6a3e8a9d7$export$2e2bcd8739ae039();
|
|
4035
|
+
const paragraphs = [
|
|
4036
|
+
currentParagraph
|
|
4037
|
+
];
|
|
4038
|
+
this.lines.forEach((line)=>{
|
|
4039
|
+
if (line.isEmpty()) {
|
|
4040
|
+
currentParagraph = new $0c3420c6a3e8a9d7$export$2e2bcd8739ae039();
|
|
4041
|
+
paragraphs.push(currentParagraph);
|
|
4042
|
+
} else if (line.hasRenderableItems()) currentParagraph.addLine(line);
|
|
4043
|
+
});
|
|
4044
|
+
return paragraphs;
|
|
4045
|
+
}
|
|
4027
4046
|
setCurrentLineType(sectionType) {
|
|
4028
4047
|
this.currentLine.type = sectionType;
|
|
4029
4048
|
}
|
|
4030
|
-
flushLine() {
|
|
4031
|
-
if (this.currentLine !== null) {
|
|
4032
|
-
if (this.currentLine.isEmpty()) this.addParagraph();
|
|
4033
|
-
else if (this.currentLine.hasRenderableItems()) this.currentParagraph.addLine(this.currentLine);
|
|
4034
|
-
}
|
|
4035
|
-
}
|
|
4036
|
-
finish() {
|
|
4037
|
-
this.flushLine();
|
|
4038
|
-
}
|
|
4039
4049
|
ensureLine() {
|
|
4040
4050
|
if (this.currentLine === null) this.addLine();
|
|
4041
4051
|
}
|
|
4042
|
-
addParagraph() {
|
|
4043
|
-
this.currentParagraph = $21a34a464e7bc609$export$13215d9ce4923f76(this.paragraphs, $0c3420c6a3e8a9d7$export$2e2bcd8739ae039);
|
|
4044
|
-
return this.currentParagraph;
|
|
4045
|
-
}
|
|
4046
|
-
ensureParagraph() {
|
|
4047
|
-
if (this.currentParagraph === null) this.addParagraph();
|
|
4048
|
-
}
|
|
4049
4052
|
addTag(tagContents) {
|
|
4050
4053
|
const tag = $5e9ede69210ec54a$export$2e2bcd8739ae039.parse(tagContents);
|
|
4051
4054
|
if (tag.isMetaTag()) this.setMetadata(tag.name, tag.value);
|
|
@@ -4107,7 +4110,8 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4107
4110
|
* Returns a deep clone of the song
|
|
4108
4111
|
* @returns {Song} The cloned song
|
|
4109
4112
|
*/ clone() {
|
|
4110
|
-
return this.mapItems(
|
|
4113
|
+
return this.mapItems((item)=>item
|
|
4114
|
+
);
|
|
4111
4115
|
}
|
|
4112
4116
|
setMetadata(name, value) {
|
|
4113
4117
|
this.metadata.add(name, value);
|
|
@@ -4178,19 +4182,53 @@ var $ce1dd7d0f2cd2369$export$2e2bcd8739ae039 = $ce1dd7d0f2cd2369$var$ParserWarni
|
|
|
4178
4182
|
];
|
|
4179
4183
|
return clonedSong;
|
|
4180
4184
|
}
|
|
4181
|
-
|
|
4185
|
+
/**
|
|
4186
|
+
* Change the song contents inline. Return a new {@link Item} to replace it. Return `null` to remove it.
|
|
4187
|
+
* @example
|
|
4188
|
+
* // transpose all chords:
|
|
4189
|
+
* song.mapItems((item) => {
|
|
4190
|
+
* if (item instanceof ChordLyricsPair) {
|
|
4191
|
+
* return item.transpose(2, 'D');
|
|
4192
|
+
* }
|
|
4193
|
+
*
|
|
4194
|
+
* return item;
|
|
4195
|
+
* });
|
|
4196
|
+
* @param {MapItemsCallback} func the callback function
|
|
4197
|
+
* @returns {Song} the changed song
|
|
4198
|
+
*/ mapItems(func) {
|
|
4182
4199
|
const clonedSong = new $6f653df65dfdf4ef$var$Song();
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4200
|
+
this.lines.forEach((line)=>{
|
|
4201
|
+
clonedSong.addLine();
|
|
4202
|
+
line.items.forEach((item)=>{
|
|
4203
|
+
const changedItem = func(item);
|
|
4204
|
+
if (changedItem) clonedSong.addItem(changedItem);
|
|
4205
|
+
});
|
|
4206
|
+
});
|
|
4186
4207
|
return clonedSong;
|
|
4187
4208
|
}
|
|
4188
|
-
|
|
4209
|
+
/**
|
|
4210
|
+
* Change the song contents inline. Return a new {@link Line} to replace it. Return `null` to remove it.
|
|
4211
|
+
* @example
|
|
4212
|
+
* // remove lines with only Tags:
|
|
4213
|
+
* song.mapLines((line) => {
|
|
4214
|
+
* if (line.items.every(item => item instanceof Tag)) {
|
|
4215
|
+
* return null;
|
|
4216
|
+
* }
|
|
4217
|
+
*
|
|
4218
|
+
* return line;
|
|
4219
|
+
* });
|
|
4220
|
+
* @param {MapLinesCallback} func the callback function
|
|
4221
|
+
* @returns {Song} the changed song
|
|
4222
|
+
*/ mapLines(func) {
|
|
4189
4223
|
const clonedSong = new $6f653df65dfdf4ef$var$Song();
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4224
|
+
this.lines.forEach((line)=>{
|
|
4225
|
+
const changedLine = func(line);
|
|
4226
|
+
if (changedLine) {
|
|
4227
|
+
clonedSong.addLine();
|
|
4228
|
+
changedLine.items.forEach((item)=>clonedSong.addItem(item)
|
|
4229
|
+
);
|
|
4230
|
+
}
|
|
4231
|
+
});
|
|
4194
4232
|
return clonedSong;
|
|
4195
4233
|
}
|
|
4196
4234
|
updateItem(findCallback, updateCallback, notFoundCallback) {
|
|
@@ -4393,7 +4431,6 @@ const $1c14afc274b727b7$var$LINE = 'line';
|
|
|
4393
4431
|
* @returns {Song} The deserialized song
|
|
4394
4432
|
*/ deserialize(serializedSong) {
|
|
4395
4433
|
this.parseAstComponent(serializedSong);
|
|
4396
|
-
this.song.finish();
|
|
4397
4434
|
return this.song;
|
|
4398
4435
|
}
|
|
4399
4436
|
parseAstComponent(astComponent) {
|
|
@@ -4527,7 +4564,6 @@ const $c049675f48c823b2$var$CHORD_LINE_REGEX = /^\s*((([A-G])(#|b)?([^/\s]*)(\/(
|
|
|
4527
4564
|
this.parseLine(line);
|
|
4528
4565
|
}
|
|
4529
4566
|
this.endOfSong();
|
|
4530
|
-
this.song.finish();
|
|
4531
4567
|
return this.song;
|
|
4532
4568
|
}
|
|
4533
4569
|
endOfSong() {}
|