lib/api.js
function createResourceConstructor(resourcePrototype) {
		function APIResource(resourceOptions) {
			// Allow creating resources without `new` keyword
			if (!(this instanceof APIResource)) {
				return new APIResource(resourceOptions);
			}

			resourceOptions = resourceOptions || {};
			// Override any default options for all requests on this resource
			_.defaults(resourceOptions.defaultParams,
				apiRoot.options.defaultParams);
			_.defaults(resourceOptions.headers,
				apiRoot.options.headers);
			_.defaults(resourceOptions, apiRoot.options);

			this.format = resourceOptions.format;
			this.logger = resourceOptions.logger;
			this.defaultParams = resourceOptions.defaultParams;
			this.headers = resourceOptions.headers;
		}

		APIResource.prototype = resourcePrototype;
		return APIResource;
	}
function createResourceConstructor(resourcePrototype) {
		function APIResource(resourceOptions) {
			// Allow creating resources without `new` keyword
			if (!(this instanceof APIResource)) {
				return new APIResource(resourceOptions);
			}

			resourceOptions = resourceOptions || {};
			// Override any default options for all requests on this resource
			_.defaults(resourceOptions.defaultParams,
				apiRoot.options.defaultParams);
			_.defaults(resourceOptions.headers,
				apiRoot.options.headers);
			_.defaults(resourceOptions, apiRoot.options);

			this.format = resourceOptions.format;
			this.logger = resourceOptions.logger;
			this.defaultParams = resourceOptions.defaultParams;
			this.headers = resourceOptions.headers;
		}

		APIResource.prototype = resourcePrototype;
		return APIResource;
	}
function createResourceConstructor ( resourcePrototype ) { function APIResource ( resourceOptions ) { // Allow creating resources without `new` keyword if ( ! ( this instanceof APIResource ) ) { return new APIResource ( resourceOptions ) ; } resourceOptions = resourceOptions || { } ; // Override any default options for all requests on this resource _ . defaults ( resourceOptions . defaultParams , apiRoot . options . defaultParams ) ; _ . defaults ( resourceOptions . headers , apiRoot . options . headers ) ; _ . defaults ( resourceOptions , apiRoot . options ) ; this . format = resourceOptions . format ; this . logger = resourceOptions . logger ; this . defaultParams = resourceOptions . defaultParams ; this . headers = resourceOptions . headers ; } APIResource . prototype = resourcePrototype ; return APIResource ; }
Creates a constructor with the pre-built resource as its prototype this is syntactic sugar to allow callers to new up the resources.
Creates a constructor with the pre - built resource as its prototype this is syntactic sugar to allow callers to new up the resources .