UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

17 lines (16 loc) 481 B
export class Deduper { constructor({ serializer = JSON.stringify } = {}) { this.values = []; this.serializedValues = new Set(); this.serializer = serializer; } push(value) { const serializedValue = this.serializer(value); const hit = this.serializedValues.has(serializedValue); if (!hit) { this.values.push(value); this.serializedValues.add(serializedValue); } return hit; } }