Skip to content

Commit

Permalink
fix: support options in packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tale committed Mar 15, 2022
1 parent f05e756 commit bdd4715
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ export class Package extends BinaryControl implements IPackage {
* It will populate the strictly typed fields and also leave the raw-string value and key.
*/
export class Packages extends Array<Package> {
constructor(args: string) {
constructor(args: string, options?: ParserOptions) {
if (typeof args === 'string') {
const cleanedData = args.replaceAll(/\r\n|\r|\n/g, '\n').replaceAll(/\0/g, '').normalize().trim()
const packageChunks = cleanedData.split('\n\n') // We know it will always be \n\n because of our cleanup

const cleanedArray = packageChunks.map(chunk => {
if (chunk.trim().length > 0) {
return new Package(chunk)
return new Package(chunk, options)
}
}).filter(item => item) as Package[]
super(...cleanedArray)
Expand Down

0 comments on commit bdd4715

Please sign in to comment.