Rocky_Mountain_Vending/.pnpm-store/v10/files/c8/fa14df3c2a34b94aa56cf462096f66fdc7dbf7f3701bce53afb235b01bd5e31004425781f84cd9a526b6e38858a3d3cf7dc4a9e1158fb83fddc5fc989f17e1
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

52 lines
1 KiB
Text

'use strict';
const unique = arr => arr.filter((v, i) => arr.lastIndexOf(v) === i);
const compact = arr => unique(arr).filter(Boolean);
module.exports = (action, data = {}, value = '') => {
let { past = [], present = '' } = data;
let rest, prev;
switch (action) {
case 'prev':
case 'undo':
rest = past.slice(0, past.length - 1);
prev = past[past.length - 1] || '';
return {
past: compact([value, ...rest]),
present: prev
};
case 'next':
case 'redo':
rest = past.slice(1);
prev = past[0] || '';
return {
past: compact([...rest, value]),
present: prev
};
case 'save':
return {
past: compact([...past, value]),
present: ''
};
case 'remove':
prev = compact(past.filter(v => v !== value));
present = '';
if (prev.length) {
present = prev.pop();
}
return {
past: prev,
present
};
default: {
throw new Error(`Invalid action: "${action}"`);
}
}
};