Get shot buffer from location
0 indexed

@method getShotBuffer

@param {Number} shot Index of shots called
@param {Function} callback Returns a call from FS.readFile data

@return {Boolean}
332748
function( shot, callback ) {

        var scope = this;

        if( typeof( shot ) === "number" ) {

            shot = scope.getShot( shot );

        }

        if( shot.location ) {

            FS.readFile( shot.location, function( err, data ) {

                callback( err, data );

            });

        } else if( ! shot.data ) {

            callback(
                new Error( "Shot not valid" )
            );

        } else {

            callback( null, shot.data );

        }

    }
599923
function(rawBuffer) {
    if (rawBuffer && this.offset === 0) return this.buffer;

    var out = new Buffer(8);
    this.buffer.copy(out, 0, this.offset, this.offset + 8);
    return out;
  }
273544
function fetchSnapshot(conn, params) {
	// For Debug --------------------------------------------
	//if(start_time === 0) {
	//	start_time = Date.now();
	//}
	// ------------------------------------------------------
	var device = devices[params.address];
	if(!device) {
		var res = {'id': 'fetchSnapshot', 'error': 'The specified device is not found: ' + params.address};
		conn.send(JSON.stringify(res));
		return;
	}
	device.fetchSnapshot((error, result) => {
		var res = {'id': 'fetchSnapshot'};
		if(error) {
			res['error'] = error.toString();
		} else {
			var ct = result['headers']['content-type'];
			var buffer = result['body'];
			var b64 = buffer.toString('base64');
			var uri = 'data:' + ct + ';base64,' + b64;
			res['result'] = uri;

			// For Debug --------------------------------------------
			/*
			total_size += parseInt(result['headers']['content-length'], 10);
			var duration = Date.now() - start_time;
			var bps = total_size * 1000 / duration;
			var kbps = parseInt(bps / 1000);
			total_frame ++;
			var fps = Math.round(total_frame * 1000 / duration);
			console.log(kbps + ' kbps / ' + fps + ' fps');
			*/
			// ------------------------------------------------------
		}
		conn.send(JSON.stringify(res));
	});
}
446610
function _getByIndex(indexName, indexData, callback) {
    // generate the index
    var index = indexName + '-' +
      crypto.createHash('sha256').update(indexData).digest('hex');

    // fetch the value of the index
    client.get(index, function(err, reply) {
      if(err) {
        return callback(err);
      }
      if(!reply) {
        // index does not exist
        return callback(null, null);
      }

      // fetch the actual data
      client.get(reply, _deserializeJson(callback));
    });
  }
1028265
function readAsBinaryString(blob, callback) {
  if (typeof FileReader === 'undefined') {
    // fix for Firefox in a web worker
    // https://bugzilla.mozilla.org/show_bug.cgi?id=901097
    return callback(arrayBufferToBinaryString(
      new FileReaderSync().readAsArrayBuffer(blob)));
  }

  var reader = new FileReader();
  var hasBinaryString = typeof reader.readAsBinaryString === 'function';
  reader.onloadend = function (e) {
    var result = e.target.result || '';
    if (hasBinaryString) {
      return callback(result);
    }
    callback(arrayBufferToBinaryString(result));
  };
  if (hasBinaryString) {
    reader.readAsBinaryString(blob);
  } else {
    reader.readAsArrayBuffer(blob);
  }
}
1167555
function( callback, shot ) {

        var scope = this;

        switch( scope.opts.callbackReturn ) {

            case Webcam.CallbackReturnTypes.location:

                return callback( null, shot.location );


            case Webcam.CallbackReturnTypes.buffer:

                return scope.getShotBuffer( shot, callback );


            case Webcam.CallbackReturnTypes.base64:

                return scope.getBase64( shot, callback );

            default:

                return callback(
                    new Error(
                        "Callback return type not valid " + scope.opts.callbackReturn
                    )
                );

        }

    }
407471
function getBabelFrameIndexes(frames) {
  const startIndexes = frames.reduce((accumulator, frame, index) => {
    if (
      getFrameUrl(frame).match(/regenerator-runtime/i) &&
      frame.displayName === "tryCatch"
    ) {
      return [...accumulator, index];
    }
    return accumulator;
  }, []);

  const endIndexes = frames.reduce((accumulator, frame, index) => {
    if (
      getFrameUrl(frame).match(/_microtask/i) &&
      frame.displayName === "flush"
    ) {
      return [...accumulator, index];
    }
    if (frame.displayName === "_asyncToGenerator/<") {
      return [...accumulator, index + 1];
    }
    return accumulator;
  }, []);

  if (startIndexes.length != endIndexes.length || startIndexes.length === 0) {
    return frames;
  }

  // Receives an array of start and end index tuples and returns
  // an array of async call stack index ranges.
  // e.g. [[1,3], [5,7]] => [[1,2,3], [5,6,7]]
  // $FlowIgnore
  return flatMap(zip(startIndexes, endIndexes), ([startIndex, endIndex]) =>
    range(startIndex, endIndex + 1)
  );
}
762844
function getCaller (offset) {
  /* eslint-disable handle-callback-err */
  if (typeof offset !== 'number') offset = 1
  var old = Error.prepareStackTrace
  var err = new Error()
  Error.prepareStackTrace = function (err, stack) {
    return stack
  }
  var fname = err.stack[1 + offset].getFileName()
  Error.prepareStackTrace = old
  return fname
}
948065
function retrieve(uri, callback) {
  var buffer = '';
  http.get(uri, function(res) {
    res.on('data', function (chunk) {
      buffer += chunk;
    });
    res.on('end', function() {
      callback(null, buffer);
    });
  }).on('error', function(e) {
    callback(e);
  });
}
616917
function(file, callback) {
        if (isBrowser && file instanceof window.File) {
            // Browser File instance
            return this.addImageFromBuffer(file, callback);
        }

        // File on filesystem. Note: the reason why we need the size of the file
        // is because of reverse proxies like Varnish which doesn't handle chunked
        // Transfer-Encoding properly - instead we need to explicitly pass the
        // content length so it knows not to terminate the HTTP connection
        readers.getLengthOfFile(file, function(err, fileSize) {
            if (err) {
                return callback(err);
            }

            readers.createReadStream(file).pipe(request({
                method: 'POST',
                uri: this.getSignedResourceUrl('POST', this.getImagesUrl()),
                json: true,
                headers: {
                    'Accept': 'application/json',
                    'User-Agent': 'imboclient-js',
                    'Content-Length': fileSize
                },
                onComplete: function(addErr, res, body) {
                    callback(addErr, body ? body.imageIdentifier : null, body, res);
                }
            }));
        }.bind(this));

        return this;
    }
72137
public boolean bufferKestrelGet(int index)
    {
        KestrelClientInfo info = this.clientInfoList.get(index);

        long now = System.currentTimeMillis();
        if (now > info.blacklistTillTimeMs)
        {
            List<Item> items = null;
            try
            {
                items = info.getValidClient().get(this.queueName, DEFAULT_BATCH_SIZE, 0,
                        this.messageTimeoutMs);
            }
            catch (TException e)
            {
                blacklist(info, e);
                return false;
            }

            Set<Long> toAck = Sets.newHashSet();

            for (Item item : items)
            {
                Iterable<List<Object>> retItems = this.messageScheme.deserialize(item.get_data());

                if (retItems != null)
                {
                    for (List<Object> retItem : retItems)
                    {
                        EmitItem emitItem = generateEmitItem(retItem, new KestrelSourceId(index,
                                item.get_id()));

                        if (!this.emitBuffer.offer(emitItem))
                        {
                            throw new RuntimeException(
                                    "KestrelThriftSpout's Internal Buffer Enqeueue Failed.");
                        }
                    }

                }
                else
                {
                    toAck.add(item.get_id());
                }
            }

            if (toAck.size() > 0)
            {
                try
                {
                    info.getClient().confirm(this.queueName, toAck);
                }
                catch (TException e)
                {
                    blacklist(info, e);
                }
            }

            if (items.size() > 0)
            {
                return true;
            }
        }
        return false;
    }
5739
function takeSnapshot(page, ph, callback) {
    page.evaluate(function () {
        return document.documentElement.outerHTML;
    }, function (document) {
        if (document) {
            callback(null, page, ph, document);
        } else {
            callback('Nothing retrieved', page, ph, null);
        }
    });
}
412576
function(callback) {
                var ret,
                    isFunc  = Util.type.function(callback),
                    args    = [].slice.call(arguments, 1);
               
                if (isFunc)
                    ret     = callback.apply(null, args);
                
                return ret;
            }
1059296
function (callback) {
            getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
                if (error) {
                    callback (error);
                    return;
                }

                originalDom = dom;
                callback();
            });
        }
779037
function( location, callback ) {

        var scope = this;

        if(
            location === null
            && scope.opts.callbackReturn ===
                Webcam.CallbackReturnTypes.buffer
        ) {

            console.warn(
                "If capturing image in memory\
                your callback return type cannot be the location"
            );

            scope.opts.callbackReturn = "buffer";

        }

        var fileType = Webcam.OutputTypes[ scope.opts.output ];

        var location = location === null
            ? null
            : ( location.match( /\..*$/ )
                ? location
                : location + "." + fileType
            );


        //Shell statement grab

        var sh = scope.generateSh( location );

        if( scope.opts.verbose ) {

            console.log( sh );

        }


        //Shell execute

        var shArgs = {
            maxBuffer: 1024 * 10000
        };

        EXEC( sh, shArgs, function( err, out, derr ) {

            if( err ) {

                return callback && callback( err );

            }

            if( scope.opts.verbose && derr ) {

                console.log( derr );

            }


            //Run validation overrides

            var validationErrors;

            if( validationErrors = scope.runCaptureValidations( derr ) ) {

                return callback && callback( validationErrors );

            }


            //Callbacks

            var shot = scope.createShot( location, derr );

            if( scope.opts.saveShots ) {

                scope.shots.push( shot );

            }

            scope.dispatch({ type: "capture", shot: shot });

            callback && (
                scope.handleCallbackReturnType( callback, shot )
            );

        });

    }
461280
function oneShot(callback) {
  var done = false;
  return function (err) {
    if (!done) {
      done = true;
      return callback.apply(this, arguments);
    }
    if (err) console.error(err.stack);
  }
}
1295422
function indexOf(haystack, needle, i) {
    if (!Buffer.isBuffer(needle)) needle = new Buffer(needle);
    if (typeof i === 'undefined') i = 0;
    var l = haystack.length - needle.length + 1;
    while (i<l) {
      var good = true;
      for (var j=0, n=needle.length; j<n; j++) {
        if (haystack[i+j] !== needle[j]) {
          good = false;
          break;
        }
      }
      if (good) return i;
      i++;
    }
    return -1;
  }