andrew-templeton / cfn-lambda

CloudFormation custom resource helper for Lambda Node.js runtime
MIT License
82 stars 22 forks source link

JSONDeepEquals failed #6

Closed monamu closed 7 years ago

monamu commented 8 years ago

I encountered an error .

TypeError: Object.keys called on non-object
    at Function.keys (native)
    at JSONDeepEquals (/var/task/node_modules/cfn-lambda/src/JSONDeepEquals.js:13:19)
    at /var/task/node_modules/cfn-lambda/src/JSONDeepEquals.js:21:16
    at Array.every (native)
    at JSONDeepEquals (/var/task/node_modules/cfn-lambda/src/JSONDeepEquals.js:20:34)
    at /var/task/node_modules/cfn-lambda/src/JSONDeepEquals.js:29:9
    at Array.every (native)
    at JSONDeepEquals (/var/task/node_modules/cfn-lambda/src/JSONDeepEquals.js:24:40)
    at CfnLambda (/var/task/node_modules/cfn-lambda/index.js:172:11)

with these parameters.


var Params =  {
        "arr": [
            "str"
        ]
    };
var OldParams= {
        "arr": [
            "str"
        ]
    };    
console.log(JSONDeepEquals(Params, OldParams));

Perhaps , I think that because node version is v0.10.36. On node v5.6.0 environment , Object.keys('string') is no problem. But, on v0.10.36 environment , error occurs .

I suggest that you change the order of processing .

  if (Object(a) !== a) {
    return a === b;
  }
  var ka = Object.keys(a).sort();
  var kb = Object.keys(b).sort();
andrew-templeton commented 7 years ago

Closing b/c merged