diff --git a/src/csvToJSON.ts b/src/csvToJSON.ts index 974faf6..99bab67 100644 --- a/src/csvToJSON.ts +++ b/src/csvToJSON.ts @@ -1,9 +1,9 @@ -import { isJunk } from './utils'; -import { csvConfig } from './config'; +import { csvConfig, rejectedParts } from './config'; const csv = require('csvtojson'); export async function getBOM(csvBOM: string) { const rawBOM = await csv(csvConfig).fromString(csvBOM); - const bom = rawBOM.filter((part: part) => !isJunk(part)); + // const bom = rawBOM.filter((part: Part) => !isJunk(part)); + const bom = rawBOM.filter((part: Part) => !rejectedParts.includes(part.Part)); return bom; } diff --git a/src/parts.d.ts b/src/parts.d.ts index c930c7f..4a15509 100644 --- a/src/parts.d.ts +++ b/src/parts.d.ts @@ -1,4 +1,4 @@ -enum PartType { +enum ComponentType { R, C, D, @@ -7,12 +7,26 @@ enum PartType { COMPONENT, } -declare interface part { +enum Potentiometers { + VOL = 'VOL', + TONE = 'TONE', + GAIN = 'GAIN', + RES = 'RES', + LEVEL = 'LEVEL', + DIST = 'DIST', + PRESENCE = 'PRESENCE', +} + +declare interface Part { Part: string; - PartType?: PartType; Value: string; } +declare interface Component extends Part { + Designator: string; //A letter like R, C, D etc + ComponentType: ComponentType; +} + declare interface structuredParts { C: { [key: string]: string; diff --git a/src/table.ts b/src/table.ts index 800aef4..531a4d2 100644 --- a/src/table.ts +++ b/src/table.ts @@ -2,7 +2,7 @@ export class PartsTable { constructor( public htmlTable: HTMLTableElement, public headers: string[], - public jsonBOM: part[], + public jsonBOM: Part[], ) {} //Reset table diff --git a/src/utils.ts b/src/utils.ts index 146ad0d..4700a3d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,9 @@ import { rejectedParts } from './config'; - -export function isJunk(element: part): boolean { - // Returns true if element is in the rejected list - return rejectedParts.includes(element.Part); -} +// no longer needed +// export function isJunk(element: Part): boolean { +// // Returns true if element is in the rejected list +// return rejectedParts.includes(element.Part); +// } // TODO /*