lib/dynamodb/converter.js
function convertInput(data, options) {
    options = options || {};
    var type = typeOf(data);
    if (type === 'Object') {
      return formatMap(data, options);
    } else if (type === 'Array') {
      return formatList(data, options);
    } else if (type === 'Set') {
      return formatSet(data, options);
    } else if (type === 'String') {
      if (data.length === 0 && options.convertEmptyValues) {
        return convertInput(null);
      }
      return { S: data };
    } else if (type === 'Number' || type === 'NumberValue') {
      return { N: data.toString() };
    } else if (type === 'Binary') {
      if (data.length === 0 && options.convertEmptyValues) {
        return convertInput(null);
      }
      return { B: data };
    } else if (type === 'Boolean') {
      return { BOOL: data };
    } else if (type === 'null') {
      return { NULL: true };
    } else if (type !== 'undefined' && type !== 'Function') {
      // this value has a custom constructor
      return formatMap(data, options);
    }
  }
function convertInput(data, options) {
    options = options || {};
    var type = typeOf(data);
    if (type === 'Object') {
      return formatMap(data, options);
    } else if (type === 'Array') {
      return formatList(data, options);
    } else if (type === 'Set') {
      return formatSet(data, options);
    } else if (type === 'String') {
      if (data.length === 0 && options.convertEmptyValues) {
        return convertInput(null);
      }
      return { S: data };
    } else if (type === 'Number' || type === 'NumberValue') {
      return { N: data.toString() };
    } else if (type === 'Binary') {
      if (data.length === 0 && options.convertEmptyValues) {
        return convertInput(null);
      }
      return { B: data };
    } else if (type === 'Boolean') {
      return { BOOL: data };
    } else if (type === 'null') {
      return { NULL: true };
    } else if (type !== 'undefined' && type !== 'Function') {
      // this value has a custom constructor
      return formatMap(data, options);
    }
  }
function convertInput ( data , options ) { options = options || { } ; var type = typeOf ( data ) ; if ( type === 'Object' ) { return formatMap ( data , options ) ; } else if ( type === 'Array' ) { return formatList ( data , options ) ; } else if ( type === 'Set' ) { return formatSet ( data , options ) ; } else if ( type === 'String' ) { if ( data . length === 0 && options . convertEmptyValues ) { return convertInput ( null ) ; } return { S : data } ; } else if ( type === 'Number' || type === 'NumberValue' ) { return { N : data . toString ( ) } ; } else if ( type === 'Binary' ) { if ( data . length === 0 && options . convertEmptyValues ) { return convertInput ( null ) ; } return { B : data } ; } else if ( type === 'Boolean' ) { return { BOOL : data } ; } else if ( type === 'null' ) { return { NULL : true } ; } else if ( type !== 'undefined' && type !== 'Function' ) { // this value has a custom constructor return formatMap ( data , options ) ; } }
Convert a JavaScript value to its equivalent DynamoDB AttributeValue type

@param data [any] The data to convert to a DynamoDB AttributeValue
@param options [map]
@option options convertEmptyValues [Boolean] Whether to automatically
convert empty strings, blobs,
and sets to `null`
@option options wrapNumbers [Boolean]  Whether to return numbers as a
NumberValue object instead of
converting them to native JavaScript
numbers. This allows for the safe
round-trip transport of numbers of
arbitrary size.
@return [map] An object in the Amazon DynamoDB AttributeValue format

@see AWS.DynamoDB.Converter.marshall AWS.DynamoDB.Converter.marshall to
convert entire records (rather than individual attributes)
Convert a JavaScript value to its equivalent DynamoDB AttributeValue type