Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* const request = {
* image: {
* source: {imageUri: 'gs://path/to/image.jpg'}
* }
* };
*
* client
* .documentTextDetection(request)
* .then(response => {
* // doThingsWith(response);
* })
* .catch(err => {
* console.error(err);
* });
*/
methods.documentTextDetection = promisify(
_createSingleFeatureMethod(features.DOCUMENT_TEXT_DETECTION)
);
/**
* Annotate a single image with safe search detection.
*
* @see v1.ImageAnnotatorClient#batchAnnotateImages
* @see google.cloud.vision.v1.AnnotateImageRequest
*
* @method v1.ImageAnnotatorClient#safeSearchDetection
* @param {object|string|Buffer} request A representation of the request
* being sent to the Vision API. This is an
* {@link google.cloud.vision.v1.AnnotateImageRequest AnnotateImageRequest}.
* For simple cases, you may also send a string (the URL or filename of
* the image) or a buffer (the image itself).
* @param {object} request.image A dictionary-like object representing the
* const request = {
* image: {
* source: {imageUri: 'gs://path/to/image.jpg'}
* }
* };
*
* client
* .faceDetection(request)
* .then(response => {
* // doThingsWith(response);
* })
* .catch(err => {
* console.error(err);
* });
*/
methods.faceDetection = promisify(
_createSingleFeatureMethod(features.FACE_DETECTION)
);
/**
* Annotate a single image with landmark detection.
*
* @see v1.ImageAnnotatorClient#batchAnnotateImages
* @see google.cloud.vision.v1.AnnotateImageRequest
*
* @method v1.ImageAnnotatorClient#landmarkDetection
* @param {object|string|Buffer} request A representation of the request
* being sent to the Vision API. This is an
* {@link google.cloud.vision.v1.AnnotateImageRequest AnnotateImageRequest}.
* For simple cases, you may also send a string (the URL or filename of
* the image) or a buffer (the image itself).
* @param {object} request.image A dictionary-like object representing the
* const request = {
* image: {
* source: {imageUri: 'gs://path/to/image.jpg'}
* }
* };
*
* client
* .cropHints(request)
* .then(response => {
* // doThingsWith(response);
* })
* .catch(err => {
* console.error(err);
* });
*/
methods.cropHints = promisify(
_createSingleFeatureMethod(features.CROP_HINTS)
);
/**
* Annotate a single image with web detection.
*
* @see v1.ImageAnnotatorClient#batchAnnotateImages
* @see google.cloud.vision.v1.AnnotateImageRequest
*
* @method v1.ImageAnnotatorClient#webDetection
* @param {object|string|Buffer} request A representation of the request
* being sent to the Vision API. This is an
* {@link google.cloud.vision.v1.AnnotateImageRequest AnnotateImageRequest}.
* For simple cases, you may also send a string (the URL or filename of
* the image) or a buffer (the image itself).
* @param {object} request.image A dictionary-like object representing the
it('should execute callback with instance & metadata', done => {
const metadata = {} as SO.Metadata;
serviceObject.getMetadata = promisify(
(options: SO.GetMetadataOptions, callback: SO.MetadataCallback) => {
callback(null, metadata);
}
);
serviceObject.get((err, instance, metadata_) => {
assert.ifError(err);
assert.strictEqual(instance, serviceObject);
assert.strictEqual(metadata_, metadata);
done();
});
});
it('handles not getting a config', (done) => {
serviceObject.getMetadata =
promisify((_callback: SO.MetadataCallback): void => {
done();
});
(serviceObject as FakeServiceObject).get(undefined, assert.ifError);
});
private async _waitForClientReady(client: ClientStub): Promise {
const deadline = Date.now() + this._options.timeout!;
try {
await promisify(client.waitForReady).call(client, deadline);
} catch (e) {
throw new ChannelError(e);
}
}
}
async getClient(): Promise {
const pubsub = this._subscription.pubsub;
const [client] = await promisify(pubsub.getClient_).call(pubsub, {
client: 'SubscriberClient',
});
return client;
}
/**