Permalink
Browse files

Replaced util.isArray() usage with Array.isArray(). Replaced __define…

…Getter__() with standardized defineProperty().
  • Loading branch information...
Jordan Ryan Moore
Jordan Ryan Moore committed Jan 25, 2012
1 parent 7181f28 commit efc85fde5fd0fdfcd705efa019403cb5b02b4b9f
View
@@ -37,8 +37,10 @@ var services = [
var Credentials = function(accessKeyId, secretAccessKey) {
var self = this;
- self.__defineGetter__('accessKeyId', function() {
- return accessKeyId;
+ Object.defineProperty(self, 'accessKeyId', {
+ get: function() {
+ return accessKeyId;
+ },
});
/**
@@ -66,16 +68,22 @@ var Service = function(serviceModule) {
var self = this;
var methods = {};
- self.__defineGetter__('version', function() {
- return serviceModule.version;
- });
-
- self.__defineGetter__('xmlns', function() {
- return serviceModule.xmlns;
- });
-
- self.__defineGetter__('methods', function() {
- return serviceModule.methods;
+ Object.defineProperties(self, {
+ 'version': {
+ get: function() {
+ return serviceModule.version;
+ },
+ },
+ 'xmlns': {
+ get: function() {
+ return serviceModule.xmlns;
+ },
+ },
+ 'methods': {
+ get: function() {
+ return serviceModule.methods;
+ },
+ },
});
/**
@@ -226,30 +234,37 @@ var Client = function(credentials, endpoints) {
endpoints = {};
}
- self.__defineGetter__('credentials', function() {
- return credentials;
- });
-
- self.__defineGetter__('endpoints', function() {
- return endpoints;
+ Object.defineProperties(self, {
+ 'credentials': {
+ get: function() {
+ return credentials;
+ },
+ },
+ 'endpoints': {
+ get: function() {
+ return endpoints;
+ },
+ },
});
var serviceMethods = {};
services.forEach(function(serviceName) {
- self.__defineGetter__(serviceName, function() {
- if (!serviceMethods[serviceName]) {
- serviceMethods[serviceName] = {};
- var service = new Service(require('./services/' + serviceName));
-
- service.methods.forEach(function(method) {
- serviceMethods[serviceName][method] = function(args, endpoint) {
- return service.request(method, args, credentials, endpoint || self.endpoints[serviceName]);
- };
- });
- }
+ Object.defineProperty(self, serviceName, {
+ get: function() {
+ if (!serviceMethods[serviceName]) {
+ serviceMethods[serviceName] = {};
+ var service = new Service(require('./services/' + serviceName));
+
+ service.methods.forEach(function(method) {
+ serviceMethods[serviceName][method] = function(args, endpoint) {
+ return service.request(method, args, credentials, endpoint || self.endpoints[serviceName]);
+ };
+ });
+ }
- return serviceMethods[serviceName];
+ return serviceMethods[serviceName];
+ },
});
});
};
@@ -560,16 +575,22 @@ var Response = function(httpResponse) {
self.requestId = null;
self.data = {};
- self.__defineGetter__('headers', function() {
- return httpResponse.headers;
- });
-
- self.__defineGetter__('body', function() {
- return httpResponse.body;
- })
-
- self.__defineGetter__('xml', function() {
- return xml;
+ Object.defineProperties(self, {
+ 'headers': {
+ get: function() {
+ return httpResponse.headers;
+ },
+ },
+ 'body': {
+ get: function() {
+ return httpResponse.body;
+ },
+ },
+ 'xml': {
+ get: function() {
+ return xml;
+ },
+ },
});
if (0 < self.body.length &&
View
@@ -211,7 +211,7 @@ util.inherits(Request, aws.QueryRequest);
Request.prototype.encodeFilters = function(args) {
var self = this;
- if (util.isArray(args.filters)) {
+ if (Array.isArray(args.filters)) {
for (var i in args.filters) {
var filter = args.filters[i];
@@ -220,7 +220,7 @@ Request.prototype.encodeFilters = function(args) {
self.query['Filter.' + i +'.Name'] = filter.name;
}
- if (util.isArray(filter.values)) {
+ if (Array.isArray(filter.values)) {
for (var j in filter.values) {
self.query['Filter.' + i +'.Value.' + j] = filter.values[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DescribeAddresses
*
@@ -9,13 +7,13 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'DescribeAddresses';
- if (util.isArray(args.publicIps)) {
+ if (Array.isArray(args.publicIps)) {
for (var i in args.publicIps) {
request.query['PublicIp.' + i] = args.publicIps[i];
}
}
- if (util.isArray(args.allocationIds)) {
+ if (Array.isArray(args.allocationIds)) {
for (var i in args.allocationIds) {
request.query['AllocationId.' + i] = args.publicIps[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DescribeAvailabilityZones
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'DescribeAvailabilityZones';
- if (util.isArray(args.zoneNames)) {
+ if (Array.isArray(args.zoneNames)) {
for (var i in args.zoneNames) {
request.query['ZoneName.' + i] = args.zoneNames[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DescribeInstances
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'DescribeInstances';
- if (util.isArray(args.instanceIds)) {
+ if (Array.isArray(args.instanceIds)) {
for (var i in args.instanceIds) {
request.query['InstanceId.' + i] = args.instanceIds[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DescribeKeyPairs
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'DescribeKeyPairs';
- if (util.isArray(args.keyNames)) {
+ if (Array.isArray(args.keyNames)) {
for (var i in args.keyNames) {
request.query['KeyName.' + i] = args.keyNames[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DescribeRegions
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'DescribeRegions';
- if (util.isArray(args.regionNames)) {
+ if (Array.isArray(args.regionNames)) {
for (var i in args.regionNames) {
request.query['RegionName.' + i] = args.regionNames[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET RebootInstances
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'RebootInstances';
- if (util.isArray(args.instanceIds)) {
+ if (Array.isArray(args.instanceIds)) {
for (var i in args.instanceIds) {
request.query['InstanceId.' + i] = args.instanceIds[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET StartInstances
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'StartInstances';
- if (util.isArray(args.instanceIds)) {
+ if (Array.isArray(args.instanceIds)) {
for (var i in args.instanceIds) {
request.query['InstanceId.' + i] = args.instanceIds[i];
}
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET StopInstances
*
@@ -9,7 +7,7 @@ var util = require('util');
module.exports.encodeRequest = function(request, args) {
request.query['Action'] = 'StopInstances';
- if (util.isArray(args.instanceIds)) {
+ if (Array.isArray(args.instanceIds)) {
for (var i in args.instanceIds) {
request.query['InstanceId.' + i] = args.instanceIds[i];
}
@@ -1,6 +1,4 @@
-var
- util = require('util'),
- route53 = require('../route53');
+var route53 = require('../route53');
/**
* POST ChangeResourceRecordSets
@@ -18,7 +16,7 @@ module.exports.encodeRequest = function(request, args) {
xmlBatch.node('Comment').text(args.comment);
}
- if (util.isArray(args.changes)) {
+ if (Array.isArray(args.changes)) {
var xmlChanges = xmlBatch.node('Changes');
args.changes.forEach(function(change) {
@@ -46,7 +44,7 @@ module.exports.encodeRequest = function(request, args) {
var resourceRecords = change.resourceRecordSet.resourceRecords;
- if (util.isArray(resourceRecords)) {
+ if (Array.isArray(resourceRecords)) {
var xmlResourceRecords = xmlResourceRecordSet.node('ResourceRecords');
resourceRecords.forEach(function(resourceRecord) {
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET BatchDeleteAttributes
*
@@ -13,7 +11,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['DomainName'] = args.domainName;
}
- if (util.isArray(args.items)) {
+ if (Array.isArray(args.items)) {
for (var i in args.items) {
var item = args.items[i];
@@ -22,7 +20,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['Item.' + i + '.ItemName'] = item.itemName;
}
- if (util.isArray(item.attributes)) {
+ if (Array.isArray(item.attributes)) {
for (var j in item.attributes) {
var attribute = item.attributes[j];
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET BatchPutAttributes
*
@@ -13,7 +11,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['DomainName'] = args.domainName;
}
- if (util.isArray(args.items)) {
+ if (Array.isArray(args.items)) {
for (var i in args.items) {
var item = args.items[i];
@@ -22,7 +20,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['Item.' + i + '.ItemName'] = item.itemName;
}
- if (util.isArray(item.attributes)) {
+ if (Array.isArray(item.attributes)) {
for (var j in item.attributes) {
var attribute = item.attributes[j];
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET DeleteAttributes
*
@@ -17,7 +15,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['ItemName'] = args.itemName;
}
- if (util.isArray(args.attributes)) {
+ if (Array.isArray(args.attributes)) {
for (var i in args.attributes) {
var attribute = args.attributes[i];
@@ -33,7 +31,7 @@ module.exports.encodeRequest = function(request, args) {
}
}
- if (util.isArray(args.expecteds)) {
+ if (Array.isArray(args.expecteds)) {
for (var i in args.expecteds) {
var expected = args.expecteds[i];
@@ -1,5 +1,3 @@
-var util = require('util');
-
/**
* GET GetAttributes
*
@@ -21,7 +19,7 @@ module.exports.encodeRequest = function(request, args) {
request.query['ConsistentRead'] = args.consistentRead;
}
- if (util.isArray(args.attributeNames)) {
+ if (Array.isArray(args.attributeNames)) {
for (var i in args.attributeNames) {
request.query['AttributeName.' + i] = args.attributeNames[i];
}
Oops, something went wrong.

0 comments on commit efc85fd

Please sign in to comment.