lib/charged.js
function Charged(options) {
  if (!(this instanceof Charged)) {
    return new Charged(options);
  }

  this.options = options;
  this.subdomain = options.subdomain || options.product || options.name;
  this.apiKey = options.key || options.apiKey;
  this.siteKey = options.siteKey;
  this.defaultFamily = options.family || options.defaultFamily;
  this.smartValidation = options.smartValidation;
  this.debug = options.debug;
  this.retry = options.retry || 1;

  this.cache = options.cache || false;
  this.cacheTTL = options.cacheTTL || 20 * 1000;
  this.cacheThreshold = options.cacheThreshold || 100;
  this._cache = {
    customers: {},
    subscriptions: {},
    components: {},
    metadata: {},
    usage: {}
  };

  this.cacheSchemas = options.cacheSchemas;
  this._schemaCache = {
    components: {},
    products: {}
  };

  if (!this.subdomain || !this.apiKey) {
    throw new
      Error('Options `subdomain` and `apiKey` are required for Charged.');
  }
}
function Charged(options) {
  if (!(this instanceof Charged)) {
    return new Charged(options);
  }

  this.options = options;
  this.subdomain = options.subdomain || options.product || options.name;
  this.apiKey = options.key || options.apiKey;
  this.siteKey = options.siteKey;
  this.defaultFamily = options.family || options.defaultFamily;
  this.smartValidation = options.smartValidation;
  this.debug = options.debug;
  this.retry = options.retry || 1;

  this.cache = options.cache || false;
  this.cacheTTL = options.cacheTTL || 20 * 1000;
  this.cacheThreshold = options.cacheThreshold || 100;
  this._cache = {
    customers: {},
    subscriptions: {},
    components: {},
    metadata: {},
    usage: {}
  };

  this.cacheSchemas = options.cacheSchemas;
  this._schemaCache = {
    components: {},
    products: {}
  };

  if (!this.subdomain || !this.apiKey) {
    throw new
      Error('Options `subdomain` and `apiKey` are required for Charged.');
  }
}
Charged