okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
407ea8192
main
1export type Request = { id :string ; sku :string ; quantity :number }; 2export function uniqueRequests ( requests :Request []) :Request []{ 3const out :Request [] = []; const seen = new Set < string >(); 4for ( const r of requests ){ 5if ( typeof r . id !== 'string' || typeof r . sku !== 'string' ) throw new RangeError ( 'id and sku must be strings' ); 6const id = r . id . trim (); const sku = r . sku . trim (); 7if ( id === '' || sku === '' ) throw new RangeError ( 'id and sku must be nonempty' ); 8if ( ! Number . isInteger ( r . quantity ) || r . quantity <= 0 ) throw new RangeError ( 'quantity must be a positive integer' ); 9if ( seen . has ( id )) continue ; 10seen . add ( id ); 11out . push ({ id, sku, quantity :r . quantity }); 12} 13return out ; 14}