UNPKG

@pwrdrvr/dynamodb-session-store

Version:

express-session library for DynamoDB with configurable `touch` write reductions and configurable eventually consistent reads for higher reliability/throughput and lower costs

30 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deepReplaceDatesWithISOStrings = void 0; /** * Deep clones the object and replaces all Date objects with their ISO string representation. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function deepReplaceDatesWithISOStrings(obj) { if (obj instanceof Date) { return obj.toISOString(); } else if (Array.isArray(obj)) { return obj.map(deepReplaceDatesWithISOStrings); } else if (typeof obj === 'object' && obj !== null) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const result = {}; for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { result[key] = deepReplaceDatesWithISOStrings(obj[key]); } } return result; } else { return obj; } } exports.deepReplaceDatesWithISOStrings = deepReplaceDatesWithISOStrings; //# sourceMappingURL=deep-replace-dates-with-strings.js.map