okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-142c-small into f-142407ea8192

main
390 B10 linesraw
1export type Stock = {sku:string;units:number};
2export function buildStock(stock:Stock[]):Map<string,number>{
3 const map=new Map<string,number>();
4 for(const s of stock){
5  if(typeof s?.sku!=='string'||s.sku.trim()===''||!Number.isInteger(s.units)||s.units<0)throw new RangeError('invalid stock record');
6  const sku=s.sku.trim();
7  map.set(sku,(map.get(sku)??0)+s.units);
8 }
9 return map;
10}