okami.mom/strata

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

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

main
546 B13 linesraw
1export type Request = {id:string;sku:string;quantity:number};
2export function uniqueRequests(requests:Request[]):Request[]{
3 const seen=new Set<string>();const out:Request[]=[];
4 for(const r of requests){
5  const id=r.id.trim();const sku=r.sku.trim();
6  if(!id)throw new RangeError('empty id');
7  if(!sku)throw new RangeError('empty sku');
8  if(!Number.isInteger(r.quantity)||r.quantity<=0)throw new RangeError('invalid quantity');
9  if(seen.has(id))continue;
10  seen.add(id);out.push({id,sku,quantity:r.quantity});
11 }
12 return out;
13}