dynamodb-utils.js
function toValueFromAttributeValue(attributeValue) {
  if (!attributeValue || typeof attributeValue !== 'object') {
    return attributeValue;
  }
  const values = Object.getOwnPropertyNames(attributeValue).map(type => {
    return toValueFromAttributeTypeAndValue(type, attributeValue[type])
  });
  if (values.length !== 1) {
    throw new Error(`Found ${values.length} values on DynamoDB AttributeValue (${stringify(attributeValue)}), but expected only one!`);
  }
  return values[0];
}
function toValueFromAttributeValue(attributeValue) {
  if (!attributeValue || typeof attributeValue !== 'object') {
    return attributeValue;
  }
  const values = Object.getOwnPropertyNames(attributeValue).map(type => {
    return toValueFromAttributeTypeAndValue(type, attributeValue[type])
  });
  if (values.length !== 1) {
    throw new Error(`Found ${values.length} values on DynamoDB AttributeValue (${stringify(attributeValue)}), but expected only one!`);
  }
  return values[0];
}
function toValueFromAttributeValue ( attributeValue ) { if ( ! attributeValue || typeof attributeValue !== 'object' ) { return attributeValue ; } const values = Object . getOwnPropertyNames ( attributeValue ) . map ( type => { return toValueFromAttributeTypeAndValue ( type , attributeValue [ type ] ) } ) ; if ( values . length !== 1 ) { throw new Error ( ` ${ values . length } ${ stringify ( attributeValue ) } ` ) ; } return values [ 0 ] ; }
Attempts to convert the given DynamoDB AttributeValue object into its equivalent JavaScript value.
@param {Object} attributeValue - a DynamoDB AttributeValue object
@returns {*} a JavaScript value
Attempts to convert the given DynamoDB AttributeValue object into its equivalent JavaScript value .