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(item: any): any {
- const { _id, _variant } = item
- const index = this.items.findIndex(x => (x.variant.id === _id && x.variant._variant === _variant))
- if (index) {
- this.items[index] = item
- } else {
- this.items.push(item)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement