lib/progress.js
function client(table) {
  table = table || process.env.ProgressTable;
  if (!table) throw new Error('ProgressTable environment variable is not set');

  var dyno = module.exports.Dyno({
    table: table.split(':')[5].split('/')[1],
    region: table.split(':')[3],
    endpoint: process.env.DynamoDbEndpoint
  });

  /**
   * Watchbot's progress client
   *
   * @name client
   */
  return {
    /**
     * Sets the total number of parts for a map-reduce job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} total - the total number of parts
     * @param {function} [callback] - a function that will be called when the total
     * number of parts for this job has been recorded
     * @returns {promise}
     */
    setTotal: setTotal.bind(null, dyno),

    /**
     * Mark one part of a map-reduce job as complete
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} part - the part that has completed (1-based, not 0-based)
     * @param {function} [callback] - a function that will be called indicating whether
     * or not the entire map-reduce job is complete
     * @returns {promise}
     */
    completePart: completePart.bind(null, dyno),

    /**
     * Fetch the status of a pending job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} [part] - the part number to check on
     * @param {function} [callback] - a function that will be called indicating the
     * current job status
     * @returns {promise}
     * @example
     * // a pending job that is 25% complete
     * { "progress": 0.25 }
     * @example
     * // a completed job
     * { "progress": 1 }
     * @example
     * // a job that failed after completing 60% of the work
     * { "progress": 0.60, "failed": "the reason for the failure" }
     * @example
     * // a job 75% complete which includes metadata
     * { "progress": 0.75, "metadata": { "name": "favorite-map-reduce" } }
     * @example
     * // a job 75% complete indicating that the requested part has already been completed
     * { "progress": 0.75, "partComplete": true }
     * @example
     * // a job 100% complete indicating that the reduce step has been taken
     * { "progress": 0.75, "reduceSent": true }
     */
    status: status.bind(null, dyno),

    /**
     * Flag a job record to indicate that a reduce step has been taken.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {function} [callback] - a function that will be called when the flag has been set
     * @returns {promise}
     */
    reduceSent: reduceSent.bind(null, dyno),

    /**
     * Fail a job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {string} reason - a description of why the job failed
     * @param {function} [callback] - a function that will be called when the reason
     * for the failure has been recorded
     * @returns {promise}
     */
    failJob: failJob.bind(null, dyno),

    /**
     * Associate arbitrary metadata with the progress record which can be retrieved
     * with a status request.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {object} metadata - arbitrary metadata to store with the progress record.
     * @param {function} [callback] - a function that will be called when the metadata
     * has been recorded
     * @returns {promise}
     */
    setMetadata: setMetadata.bind(null, dyno)
  };
}
function client(table) {
  table = table || process.env.ProgressTable;
  if (!table) throw new Error('ProgressTable environment variable is not set');

  var dyno = module.exports.Dyno({
    table: table.split(':')[5].split('/')[1],
    region: table.split(':')[3],
    endpoint: process.env.DynamoDbEndpoint
  });

  /**
   * Watchbot's progress client
   *
   * @name client
   */
  return {
    /**
     * Sets the total number of parts for a map-reduce job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} total - the total number of parts
     * @param {function} [callback] - a function that will be called when the total
     * number of parts for this job has been recorded
     * @returns {promise}
     */
    setTotal: setTotal.bind(null, dyno),

    /**
     * Mark one part of a map-reduce job as complete
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} part - the part that has completed (1-based, not 0-based)
     * @param {function} [callback] - a function that will be called indicating whether
     * or not the entire map-reduce job is complete
     * @returns {promise}
     */
    completePart: completePart.bind(null, dyno),

    /**
     * Fetch the status of a pending job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} [part] - the part number to check on
     * @param {function} [callback] - a function that will be called indicating the
     * current job status
     * @returns {promise}
     * @example
     * // a pending job that is 25% complete
     * { "progress": 0.25 }
     * @example
     * // a completed job
     * { "progress": 1 }
     * @example
     * // a job that failed after completing 60% of the work
     * { "progress": 0.60, "failed": "the reason for the failure" }
     * @example
     * // a job 75% complete which includes metadata
     * { "progress": 0.75, "metadata": { "name": "favorite-map-reduce" } }
     * @example
     * // a job 75% complete indicating that the requested part has already been completed
     * { "progress": 0.75, "partComplete": true }
     * @example
     * // a job 100% complete indicating that the reduce step has been taken
     * { "progress": 0.75, "reduceSent": true }
     */
    status: status.bind(null, dyno),

    /**
     * Flag a job record to indicate that a reduce step has been taken.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {function} [callback] - a function that will be called when the flag has been set
     * @returns {promise}
     */
    reduceSent: reduceSent.bind(null, dyno),

    /**
     * Fail a job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {string} reason - a description of why the job failed
     * @param {function} [callback] - a function that will be called when the reason
     * for the failure has been recorded
     * @returns {promise}
     */
    failJob: failJob.bind(null, dyno),

    /**
     * Associate arbitrary metadata with the progress record which can be retrieved
     * with a status request.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {object} metadata - arbitrary metadata to store with the progress record.
     * @param {function} [callback] - a function that will be called when the metadata
     * has been recorded
     * @returns {promise}
     */
    setMetadata: setMetadata.bind(null, dyno)
  };
}
function client ( table ) { table = table || process . env . ProgressTable ; if ( ! table ) throw new Error ( 'ProgressTable environment variable is not set' ) ; var dyno = module . exports . Dyno ( { table : table . split ( ':' ) [ 5 ] . split ( '/' ) [ 1 ] , region : table . split ( ':' ) [ 3 ] , endpoint : process . env . DynamoDbEndpoint } ) ; /**
   * Watchbot's progress client
   *
   * @name client
   */ return { /**
     * Sets the total number of parts for a map-reduce job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} total - the total number of parts
     * @param {function} [callback] - a function that will be called when the total
     * number of parts for this job has been recorded
     * @returns {promise}
     */ setTotal : setTotal . bind ( null , dyno ) , /**
     * Mark one part of a map-reduce job as complete
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} part - the part that has completed (1-based, not 0-based)
     * @param {function} [callback] - a function that will be called indicating whether
     * or not the entire map-reduce job is complete
     * @returns {promise}
     */ completePart : completePart . bind ( null , dyno ) , /**
     * Fetch the status of a pending job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {number} [part] - the part number to check on
     * @param {function} [callback] - a function that will be called indicating the
     * current job status
     * @returns {promise}
     * @example
     * // a pending job that is 25% complete
     * { "progress": 0.25 }
     * @example
     * // a completed job
     * { "progress": 1 }
     * @example
     * // a job that failed after completing 60% of the work
     * { "progress": 0.60, "failed": "the reason for the failure" }
     * @example
     * // a job 75% complete which includes metadata
     * { "progress": 0.75, "metadata": { "name": "favorite-map-reduce" } }
     * @example
     * // a job 75% complete indicating that the requested part has already been completed
     * { "progress": 0.75, "partComplete": true }
     * @example
     * // a job 100% complete indicating that the reduce step has been taken
     * { "progress": 0.75, "reduceSent": true }
     */ status : status . bind ( null , dyno ) , /**
     * Flag a job record to indicate that a reduce step has been taken.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {function} [callback] - a function that will be called when the flag has been set
     * @returns {promise}
     */ reduceSent : reduceSent . bind ( null , dyno ) , /**
     * Fail a job
     *
     * @memberof client
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {string} reason - a description of why the job failed
     * @param {function} [callback] - a function that will be called when the reason
     * for the failure has been recorded
     * @returns {promise}
     */ failJob : failJob . bind ( null , dyno ) , /**
     * Associate arbitrary metadata with the progress record which can be retrieved
     * with a status request.
     *
     * @param {string} jobId - the identifier for a map-reduce job
     * @param {object} metadata - arbitrary metadata to store with the progress record.
     * @param {function} [callback] - a function that will be called when the metadata
     * has been recorded
     * @returns {promise}
     */ setMetadata : setMetadata . bind ( null , dyno ) } ; }
mockable 
Create a progress-tracking client

@param {string} [table] - the ARN for the DynamoDB table used to track progress.
If not provided, it will look for `$ProgessTable` environment variable, and
fail if neither is provided.
@returns {object} a progress client
@example
var progress = require('watchbot-progress').progress;
mockable Create a progress - tracking client