dynamo-as-promised.js
function createDynodeOptions(dynamoAsPromisedOptions, key, extraDynodeOptions) {
    var dynodeOptions = _.clone(extraDynodeOptions || {});

    // If given an `onlyIfExists` option, assemble the `Expected` Dynode option value by looking at the key and values.
    // Example:
    //     var key = { hash: "H", range: 5 };
    //     var dapOptions = { onlyIfExists: { hash: "h", range: "r" } };
    //     createDynodeOptions(dapOptions, key) === {
    //         Expected: { h: { Value: { S: "H" }, r: { Value: { N: 5 } } }
    //     };
    if (typeof dynamoAsPromisedOptions === "object" && dynamoAsPromisedOptions.onlyIfExists) {
        dynodeOptions.Expected = {};

        var keyValues = typeof key === "string" ? { hash: key } : key;
        var keysThatMustExist = typeof dynamoAsPromisedOptions.onlyIfExists === "string" ?
                                    { hash: dynamoAsPromisedOptions.onlyIfExists } :
                                    dynamoAsPromisedOptions.onlyIfExists;
        Object.keys(keysThatMustExist).forEach(function (keyType) {
            var keyName = keysThatMustExist[keyType];
            var beforeTypeAnnotations = {};
            beforeTypeAnnotations[keyName] = keyValues[keyType];
            var withTypeAnnotations = addDynamoTypeAnnotations(beforeTypeAnnotations);
            dynodeOptions.Expected[keyName] = { Value: withTypeAnnotations[keyName] };
        });
    }

    return dynodeOptions;
}
function createDynodeOptions(dynamoAsPromisedOptions, key, extraDynodeOptions) {
    var dynodeOptions = _.clone(extraDynodeOptions || {});

    // If given an `onlyIfExists` option, assemble the `Expected` Dynode option value by looking at the key and values.
    // Example:
    //     var key = { hash: "H", range: 5 };
    //     var dapOptions = { onlyIfExists: { hash: "h", range: "r" } };
    //     createDynodeOptions(dapOptions, key) === {
    //         Expected: { h: { Value: { S: "H" }, r: { Value: { N: 5 } } }
    //     };
    if (typeof dynamoAsPromisedOptions === "object" && dynamoAsPromisedOptions.onlyIfExists) {
        dynodeOptions.Expected = {};

        var keyValues = typeof key === "string" ? { hash: key } : key;
        var keysThatMustExist = typeof dynamoAsPromisedOptions.onlyIfExists === "string" ?
                                    { hash: dynamoAsPromisedOptions.onlyIfExists } :
                                    dynamoAsPromisedOptions.onlyIfExists;
        Object.keys(keysThatMustExist).forEach(function (keyType) {
            var keyName = keysThatMustExist[keyType];
            var beforeTypeAnnotations = {};
            beforeTypeAnnotations[keyName] = keyValues[keyType];
            var withTypeAnnotations = addDynamoTypeAnnotations(beforeTypeAnnotations);
            dynodeOptions.Expected[keyName] = { Value: withTypeAnnotations[keyName] };
        });
    }

    return dynodeOptions;
}
function createDynodeOptions ( dynamoAsPromisedOptions , key , extraDynodeOptions ) { var dynodeOptions = _ . clone ( extraDynodeOptions || { } ) ; // If given an `onlyIfExists` option, assemble the `Expected` Dynode option value by looking at the key and values. // Example: //     var key = { hash: "H", range: 5 }; //     var dapOptions = { onlyIfExists: { hash: "h", range: "r" } }; //     createDynodeOptions(dapOptions, key) === { //         Expected: { h: { Value: { S: "H" }, r: { Value: { N: 5 } } } //     }; if ( typeof dynamoAsPromisedOptions === "object" && dynamoAsPromisedOptions . onlyIfExists ) { dynodeOptions . Expected = { } ; var keyValues = typeof key === "string" ? { hash : key } : key ; var keysThatMustExist = typeof dynamoAsPromisedOptions . onlyIfExists === "string" ? { hash : dynamoAsPromisedOptions . onlyIfExists } : dynamoAsPromisedOptions . onlyIfExists ; Object . keys ( keysThatMustExist ) . forEach ( function ( keyType ) { var keyName = keysThatMustExist [ keyType ] ; var beforeTypeAnnotations = { } ; beforeTypeAnnotations [ keyName ] = keyValues [ keyType ] ; var withTypeAnnotations = addDynamoTypeAnnotations ( beforeTypeAnnotations ) ; dynodeOptions . Expected [ keyName ] = { Value : withTypeAnnotations [ keyName ] } ; } ) ; } return dynodeOptions ; }
Used with `spread` to transform (data, metadata) pairs from dynode into just data
Used with spread to transform ( data metadata ) pairs from dynode into just data