Dev Helpers
← Back

Collect empty shelf locations

Collect empty shelf locations. Start with typed records and inspect the inferred result.

Open this example in the interactive library

Source code

type Row = { sku: string; bin: string; qty: number };
const rows: Row[] = [
  { sku: "pen", bin: "A", qty: 4 },
  { sku: "pad", bin: "B", qty: 0 },
  { sku: "pen", bin: "B", qty: 3 },
  { sku: "clip", bin: "A", qty: 9 },
];
const result = rows
  .filter((r) => r.qty === 0)
  .map((r) => ({ part: r.sku, location: r.bin }));
console.log(JSON.stringify(result, null, 2));

Sample output

[
  {
    "part": "pad",
    "location": "B"
  }
]