How to use the @google-cloud/promisify.promisify function in @google-cloud/promisify

To help you get started, we’ve selected a few @google-cloud/promisify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-vision / src / helpers.js View on Github external
* 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
github googleapis / nodejs-vision / src / helpers.js View on Github external
* 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
github googleapis / nodejs-vision / src / helpers.js View on Github external
* 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
github googleapis / nodejs-common / test / service-object.ts View on Github external
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();
      });
    });
github googleapis / nodejs-common / test / service-object.ts View on Github external
it('handles not getting a config', (done) => {
      serviceObject.getMetadata =
          promisify((_callback: SO.MetadataCallback): void => {
            done();
          });
      (serviceObject as FakeServiceObject).get(undefined, assert.ifError);
    });
github googleapis / nodejs-pubsub / src / message-stream.ts View on Github external
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);
    }
  }
}
github googleapis / nodejs-pubsub / src / subscriber.ts View on Github external
async getClient(): Promise {
    const pubsub = this._subscription.pubsub;
    const [client] = await promisify(pubsub.getClient_).call(pubsub, {
      client: 'SubscriberClient',
    });

    return client;
  }
  /**

@google-cloud/promisify

A simple utility for promisifying functions and classes.

Apache-2.0
Latest version published 9 months ago

Package Health Score

78 / 100
Full package analysis

Similar packages