diff --git a/README.md b/README.md index ae875e3..7081fc7 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,9 @@ npm install songshowplus-parser --save ``` ## Usage +Simply import and create a new instance of `SongShowPlus`, then pass the contents of a SSP7 file as a string to the `.parse()` method. -TypeScript projects +### For TypeScript projects ``` import {readFile} from 'fs'; import { SongShowPlus } from 'songshowplus-parser'; @@ -18,12 +19,12 @@ import { SongShowPlus } from 'songshowplus-parser'; const sspParser = new SongShowPlus(); readFile('Be Near.sbsong', (contents) => { - const song = sspParser.parse(contents); + const song = sspParser.parse(contents.toString()); console.log(song); }); ``` -JavaScript projects +### For JavaScript projects ``` const fs = require('fs'); const { SongShowPlus } = require('songshowplus-parser'); @@ -31,7 +32,7 @@ const { SongShowPlus } = require('songshowplus-parser'); const sspParser = new SongShowPlus(); fs.readFile('Be Near.sbsong', (contents) => { - const song = sspParser.parse(contents); + const song = sspParser.parse(contents.toString()); console.log(song); }); ``` diff --git a/package.json b/package.json index b97c2ff..4840c2c 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "dist/module", "!**/*.spec.*", "!**/*.json", + "!**/*.tsbuildinfo*", "LICENSE", "README.md" ], diff --git a/src/index.spec.ts b/src/index.spec.ts index 60ad1f5..61d7b52 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -13,7 +13,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for an ENGLISH SongShow Plus 7 file: "Be Near.sbsong"', () => { - const testFile = readFileSync('./sample-files/Be Near.sbsong'); + const testFile = readFileSync('./sample-files/Be Near.sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'Be Near', @@ -56,7 +56,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for an ENGLISH SongShow Plus 7 file: "Give Us Clean Hands.sbsong"', () => { - const testFile = readFileSync('./sample-files/Give Us Clean Hands.sbsong'); + const testFile = readFileSync('./sample-files/Give Us Clean Hands.sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'Give Us Clean Hands', @@ -85,7 +85,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for an ENGLISH SongShow Plus 7 file: "Jesus Saves.sbsong"', () => { - const testFile = readFileSync('./sample-files/Jesus Saves.sbsong'); + const testFile = readFileSync('./sample-files/Jesus Saves.sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'Jesus Saves (2)', @@ -138,7 +138,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for an ENGLISH SongShow Plus 7 file: "You Are.sbsong"', () => { - const testFile = readFileSync('./sample-files/You Are.sbsong'); + const testFile = readFileSync('./sample-files/You Are.sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'You Are (2)', @@ -172,7 +172,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for a SPANISH SongShow Plus 7 file: "Devuelveme El Gozo.sbsong"', () => { - const testFile = readFileSync('./sample-files/Devuelveme El Gozo.sbsong'); + const testFile = readFileSync('./sample-files/Devuelveme El Gozo.sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'Devuelveme El Gozo', @@ -196,7 +196,7 @@ describe('SongShowPlus', (): void => { }); it('should return a song for a SPANISH SongShow Plus 7 file: "La Sangre (The Blood).sbsong"', () => { - const testFile = readFileSync('./sample-files/La Sangre (The Blood).sbsong'); + const testFile = readFileSync('./sample-files/La Sangre (The Blood).sbsong').toString(); expect(sspParser.parse(testFile)).toEqual({ title: 'La Sangre (The Blood)', diff --git a/src/index.ts b/src/index.ts index c34b8d4..6b3ce2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,11 +10,7 @@ export class SongShowPlus { private readonly textCleaner = new TextCleaner(); - parse(fileContent: string | Buffer): ISongShowPlusSong { - if (fileContent instanceof Buffer) { - fileContent = fileContent.toString(); - } - + parse(fileContent: string): ISongShowPlusSong { let title = ''; let artist = ''; let copyright = ''; diff --git a/src/models.d.ts b/src/models.ts similarity index 100% rename from src/models.d.ts rename to src/models.ts