chordsheetjs 6.2.2 → 7.1.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 CHANGED
@@ -1,4 +1,4 @@
1
- # ChordChartJS [![Code Climate](https://codeclimate.com/github/PraiseCharts/ChordChartJS/badges/gpa.svg)](https://codeclimate.com/github/PraiseCharts/ChordChartJS)
1
+ # ChordSheetJS [![Code Climate](https://codeclimate.com/github/martijnversluis/ChordSheetJS/badges/gpa.svg)](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
@@ -422,7 +424,8 @@ Inherits from [ChordSheetParser](#ChordSheetParser)</p></dd>
422
424
  <dt><a href="#END_OF_VERSE">END_OF_VERSE</a> : <code>string</code></dt>
423
425
  <dd><p>Key meta directive. See https://www.chordpro.org/chordpro/directives-key/</p></dd>
424
426
  <dt><a href="#KEY">KEY</a> : <code>string</code></dt>
425
- <dd><p>Key meta directive. See https://www.chordpro.org/chordpro/directives-key/</p></dd>
427
+ <dd><p>_Key meta directive. Reflects the key as transposed by the capo value
428
+ See https://www.chordpro.org/chordpro/directives-key/</p></dd>
426
429
  <dt><a href="#_KEY">_KEY</a> : <code>string</code></dt>
427
430
  <dd><p>Lyricist meta directive. See https://www.chordpro.org/chordpro/directives-lyricist/</p></dd>
428
431
  <dt><a href="#LYRICIST">LYRICIST</a> : <code>string</code></dt>
@@ -631,10 +634,15 @@ If not, it returns [INDETERMINATE](#INDETERMINATE)</p>
631
634
  * [new Song(metadata)](#new_Song_new)
632
635
  * [.bodyLines](#Song+bodyLines) ⇒ <code>Array.&lt;Line&gt;</code>
633
636
  * [.bodyParagraphs](#Song+bodyParagraphs) ⇒ [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
637
+ * [.paragraphs](#Song+paragraphs) : [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
634
638
  * ~~[.metaData](#Song+metaData) ⇒~~
635
639
  * [.clone()](#Song+clone) ⇒ [<code>Song</code>](#Song)
636
- * [.setCapo(capo)](#Song+setCapo) ⇒ [<code>Song</code>](#Song)
637
640
  * [.setKey(key)](#Song+setKey) ⇒ [<code>Song</code>](#Song)
641
+ * [.setCapo(capo)](#Song+setCapo) ⇒ [<code>Song</code>](#Song)
642
+ * [.changeKey(newKey)](#Song+changeKey) ⇒ [<code>Song</code>](#Song)
643
+ * [.changeMetadata(name, value)](#Song+changeMetadata)
644
+ * [.mapItems(func)](#Song+mapItems) ⇒ [<code>Song</code>](#Song)
645
+ * [.mapLines(func)](#Song+mapLines) ⇒ [<code>Song</code>](#Song)
638
646
 
639
647
  <a name="new_Song_new"></a>
640
648
 
@@ -662,6 +670,12 @@ if you want to skip the &quot;header lines&quot;: the lines that only contain me
662
670
 
663
671
  **Kind**: instance property of [<code>Song</code>](#Song)
664
672
  **See**: [bodyLines](bodyLines)
673
+ <a name="Song+paragraphs"></a>
674
+
675
+ ### song.paragraphs : [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
676
+ <p>The [Paragraph](#Paragraph) items of which the song consists</p>
677
+
678
+ **Kind**: instance property of [<code>Song</code>](#Song)
665
679
  <a name="Song+metaData"></a>
666
680
 
667
681
  ### ~~song.metaData ⇒~~
@@ -678,13 +692,29 @@ if you want to skip the &quot;header lines&quot;: the lines that only contain me
678
692
 
679
693
  **Kind**: instance method of [<code>Song</code>](#Song)
680
694
  **Returns**: [<code>Song</code>](#Song) - <p>The cloned song</p>
695
+ <a name="Song+setKey"></a>
696
+
697
+ ### song.setKey(key) ⇒ [<code>Song</code>](#Song)
698
+ <p>Returns a copy of the song with the key value set to the specified key. It changes:</p>
699
+ <ul>
700
+ <li>the value for <code>key</code> in the <code>metadata</code> set</li>
701
+ <li>any existing <code>key</code> directive</li>
702
+ </ul>
703
+
704
+ **Kind**: instance method of [<code>Song</code>](#Song)
705
+ **Returns**: [<code>Song</code>](#Song) - <p>The changed song</p>
706
+
707
+ | Param | Type | Description |
708
+ | --- | --- | --- |
709
+ | key | <code>number</code> \| <code>null</code> | <p>the key. Passing <code>null</code> will:</p> <ul> <li>remove the current key from <code>metadata</code></li> <li>remove any <code>key</code> directive</li> </ul> |
710
+
681
711
  <a name="Song+setCapo"></a>
682
712
 
683
713
  ### song.setCapo(capo) ⇒ [<code>Song</code>](#Song)
684
- <p>Returns a copy of the song with the capo value set to the specified capo. It changes:</p>
714
+ <p>Returns a copy of the song with the key value set to the specified capo. It changes:</p>
685
715
  <ul>
686
716
  <li>the value for <code>capo</code> in the <code>metadata</code> set</li>
687
- <li>any existing <code>capo</code> directive)</li>
717
+ <li>any existing <code>capo</code> directive</li>
688
718
  </ul>
689
719
 
690
720
  **Kind**: instance method of [<code>Song</code>](#Song)
@@ -694,9 +724,9 @@ if you want to skip the &quot;header lines&quot;: the lines that only contain me
694
724
  | --- | --- | --- |
695
725
  | capo | <code>number</code> \| <code>null</code> | <p>the capo. Passing <code>null</code> will:</p> <ul> <li>remove the current key from <code>metadata</code></li> <li>remove any <code>capo</code> directive</li> </ul> |
696
726
 
697
- <a name="Song+setKey"></a>
727
+ <a name="Song+changeKey"></a>
698
728
 
699
- ### song.setKey(key) ⇒ [<code>Song</code>](#Song)
729
+ ### song.changeKey(newKey) ⇒ [<code>Song</code>](#Song)
700
730
  <p>Returns a copy of the song with the key set to the specified key. It changes:</p>
701
731
  <ul>
702
732
  <li>the value for <code>key</code> in the <code>metadata</code> set</li>
@@ -709,8 +739,71 @@ if you want to skip the &quot;header lines&quot;: the lines that only contain me
709
739
 
710
740
  | Param | Type | Description |
711
741
  | --- | --- | --- |
712
- | key | <code>string</code> | <p>The new key.</p> |
742
+ | newKey | <code>string</code> | <p>The new key.</p> |
743
+
744
+ <a name="Song+changeMetadata"></a>
713
745
 
746
+ ### song.changeMetadata(name, value)
747
+ <p>Returns a copy of the song with the directive value set to the specified value.</p>
748
+ <ul>
749
+ <li>when there is a matching directive in the song, it will update the directive</li>
750
+ <li>when there is no matching directive, it will be inserted
751
+ If <code>value</code> is <code>null</code> it will act as a delete, any directive matching <code>name</code> will be removed.</li>
752
+ </ul>
753
+
754
+ **Kind**: instance method of [<code>Song</code>](#Song)
755
+
756
+ | Param | Type | Description |
757
+ | --- | --- | --- |
758
+ | name | <code>string</code> | <p>The directive name</p> |
759
+ | value | <code>string</code> \| <code>null</code> | <p>The value to set, or <code>null</code> to remove the directive</p> |
760
+
761
+ <a name="Song+mapItems"></a>
762
+
763
+ ### song.mapItems(func) ⇒ [<code>Song</code>](#Song)
764
+ <p>Change the song contents inline. Return a new [Item](Item) to replace it. Return <code>null</code> to remove it.</p>
765
+
766
+ **Kind**: instance method of [<code>Song</code>](#Song)
767
+ **Returns**: [<code>Song</code>](#Song) - <p>the changed song</p>
768
+
769
+ | Param | Type | Description |
770
+ | --- | --- | --- |
771
+ | func | <code>MapItemsCallback</code> | <p>the callback function</p> |
772
+
773
+ **Example**
774
+ ```js
775
+ // transpose all chords:
776
+ song.mapItems((item) => {
777
+ if (item instanceof ChordLyricsPair) {
778
+ return item.transpose(2, 'D');
779
+ }
780
+
781
+ return item;
782
+ });
783
+ ```
784
+ <a name="Song+mapLines"></a>
785
+
786
+ ### song.mapLines(func) ⇒ [<code>Song</code>](#Song)
787
+ <p>Change the song contents inline. Return a new [Line](Line) to replace it. Return <code>null</code> to remove it.</p>
788
+
789
+ **Kind**: instance method of [<code>Song</code>](#Song)
790
+ **Returns**: [<code>Song</code>](#Song) - <p>the changed song</p>
791
+
792
+ | Param | Type | Description |
793
+ | --- | --- | --- |
794
+ | func | <code>MapLinesCallback</code> | <p>the callback function</p> |
795
+
796
+ **Example**
797
+ ```js
798
+ // remove lines with only Tags:
799
+ song.mapLines((line) => {
800
+ if (line.items.every(item => item instanceof Tag)) {
801
+ return null;
802
+ }
803
+
804
+ return line;
805
+ });
806
+ ```
714
807
  <a name="Tag"></a>
715
808
 
716
809
  ## Tag
@@ -1335,7 +1428,8 @@ Can be deserialized using [deserialize](deserialize)</p>
1335
1428
  <a name="KEY"></a>
1336
1429
 
1337
1430
  ## KEY : <code>string</code>
1338
- <p>Key meta directive. See https://www.chordpro.org/chordpro/directives-key/</p>
1431
+ <p>_Key meta directive. Reflects the key as transposed by the capo value
1432
+ See https://www.chordpro.org/chordpro/directives-key/</p>
1339
1433
 
1340
1434
  **Kind**: global variable
1341
1435
  <a name="_KEY"></a>