Filter parts using array methods instead of separate function
This commit is contained in:
parent
2584a58df2
commit
70e444d6a3
@ -1,9 +1,9 @@
|
|||||||
import { isJunk } from './utils';
|
import { csvConfig, rejectedParts } from './config';
|
||||||
import { csvConfig } from './config';
|
|
||||||
const csv = require('csvtojson');
|
const csv = require('csvtojson');
|
||||||
|
|
||||||
export async function getBOM(csvBOM: string) {
|
export async function getBOM(csvBOM: string) {
|
||||||
const rawBOM = await csv(csvConfig).fromString(csvBOM);
|
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;
|
return bom;
|
||||||
}
|
}
|
||||||
|
20
src/parts.d.ts
vendored
20
src/parts.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
enum PartType {
|
enum ComponentType {
|
||||||
R,
|
R,
|
||||||
C,
|
C,
|
||||||
D,
|
D,
|
||||||
@ -7,12 +7,26 @@ enum PartType {
|
|||||||
COMPONENT,
|
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;
|
Part: string;
|
||||||
PartType?: PartType;
|
|
||||||
Value: string;
|
Value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare interface Component extends Part {
|
||||||
|
Designator: string; //A letter like R, C, D etc
|
||||||
|
ComponentType: ComponentType;
|
||||||
|
}
|
||||||
|
|
||||||
declare interface structuredParts {
|
declare interface structuredParts {
|
||||||
C: {
|
C: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
|
@ -2,7 +2,7 @@ export class PartsTable {
|
|||||||
constructor(
|
constructor(
|
||||||
public htmlTable: HTMLTableElement,
|
public htmlTable: HTMLTableElement,
|
||||||
public headers: string[],
|
public headers: string[],
|
||||||
public jsonBOM: part[],
|
public jsonBOM: Part[],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
//Reset table
|
//Reset table
|
||||||
|
10
src/utils.ts
10
src/utils.ts
@ -1,9 +1,9 @@
|
|||||||
import { rejectedParts } from './config';
|
import { rejectedParts } from './config';
|
||||||
|
// no longer needed
|
||||||
export function isJunk(element: part): boolean {
|
// export function isJunk(element: Part): boolean {
|
||||||
// Returns true if element is in the rejected list
|
// // Returns true if element is in the rejected list
|
||||||
return rejectedParts.includes(element.Part);
|
// return rejectedParts.includes(element.Part);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user