UNPKG

dynamodb-toolbox

Version:

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

21 lines (20 loc) 604 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Deduper = void 0; 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; } } exports.Deduper = Deduper;