UNPKG

@studyportals/sp-r2d2

Version:

A framework that contains various components used when developing projects that will be deployed via AWS λ.

51 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AttributeMapNormalizer = void 0; class AttributeMapNormalizer { normalizeMaps(input) { return input.map((_) => this.normalizeMap(_)); } normalizeMap(input) { const item = {}; for (const property of Object.keys(input)) { item[property] = this.normalizeAttributeValue(input[property]); } return item; } normalizeAttributeValue(input) { if (input.S || this.typeOfString(input.S)) { return input.S; } if (input.N) { return +input.N; } if (input.SS) { return input.SS; } if (input.NS) { return input.NS.map((_) => +_); } if (input.NULL) { return null; } if (undefined !== input.BOOL) { return input.BOOL; } if (input.M) { return this.normalizeMap(input.M); } if (input.L) { return input.L.map((_) => this.normalizeAttributeValue(_)); } // [B]inary and [B]inary[S]et are not implemented. throw new Error(`R2D2: Unsupported attribute type`); } typeOfString(input) { return this.typeOf(input, 'string'); } typeOf(input, type) { return typeof input === type; } } exports.AttributeMapNormalizer = AttributeMapNormalizer; //# sourceMappingURL=attribute-map-normalizer.class.js.map