okami.mom/strata

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

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

main
650 B2 linesraw
1export type Request = {id:string;sku:string;quantity:number};
2export function uniqueRequests(requests:Request[]):Request[]{const out:Request[]=[];const seen=new Set<string>();for(const r of requests){if(typeof r.id!=='string'||typeof r.sku!=='string'||typeof r.quantity!=='number')throw new RangeError('invalid request');const id=r.id.trim();const sku=r.sku.trim();if(!id)throw new RangeError('empty request id');if(!sku)throw new RangeError('empty request sku');if(!Number.isInteger(r.quantity)||r.quantity<1)throw new RangeError('invalid request quantity');if(seen.has(id))continue;seen.add(id);out.push({id,sku,quantity:r.quantity});}return out;}