UNPKG

@incdevco/framework

Version:
57 lines (28 loc) 772 B
module.exports = class ExpressionAttributeNames { constructor() { this._names = {}; } determineKey(value) { let possibleKey = '#'; let parts = value.split('.'); possibleKey = parts[0]; return possibleKey; } determineValue(value) { let possibleValue; let parts = value.split('.'); possibleValue = parts[0]; return possibleValue; } name(value, key) { if (key) { if (this._names[key]) { throw new Error('key already exists'); } } else { key = this.determineKey(value); } this._names[key] = this.determineValue(value); return key; } };