Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class ItemsFactory {
- items: any[];
- constructor() {
- this.items = [];
- }
- public getCount() {
- return this.items.length;
- }
- public pushOrUpdate(
- variant: number,
- id: number,
- order: number,
- items: any[]
- ): any {
- const itemIdx = this.items.findIndex(x => x.variant.id === id);
- if (itemIdx) {
- this.items[itemIdx].items = items;
- } else {
- this.items.push({
- variant: {
- id,
- variant,
- order,
- items
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement