Packages

@google-cloud/vision

6.2.0 · 12 Oct 2026Apache-2.01.1M / weekRepositoryHomepagenpmAtom feed

Your version

0.25.0

25 Feb 2019Where it was published

In short

3 new2 changed

Release note

The section about @google-cloud/vision of a note shared by several packages.

Updating

$ npm install gcloud@0.25

:warning: Breaking Changes

Creating a BigQuery table: parameters changed!

Previously:

dataset.createTable({
  id: 'new-table-id',
  // ...
}, function(err, table, apiResponse) {});

Now:

dataset.createTable('new-table-id', [options], function(err, table, apiResponse) {});

Compute Engine operations are now event emitters

#921, #939

Previously:

operation.onComplete(function(err, metadata) {
  // metadata is the result of the operation.
});

Now:

operation.on('complete', function(metadata) {
  // `metadata` is the result of the operation.
});

Also, we now parse the results of the operation and consider an operation failure an error. Listen for the error event to catch these errors, as well as anything else that might go wrong during an API call.

operation.on('error', function(err) {
  // The operation may have failed.
});

:balloon: New methods available! :tada

#928, #931, #932, #942, #943, #944, #945, #946

All* of our APIs have new methods that might be more useful for you! Our paradigm so far has looked like this:

Service (e.g. BigQuery, Storage)
|_ Object (e.g. a BigQuery dataset, a Storage bucket)

An object can typically be created or "gotten"-- a vague term to describe two things, depending on your use case:

  1. Simply reference an object. This has no async side effects.

    var gcs = gcloud.storage();
    var bucket = storage.bucket('i-know-this-bucket-exists');
  2. Get information about an object.

    var gcs = gcloud.storage();
    var bucket = storage.bucket('i-know-this-bucket-exists');
    
    bucket.getMetadata(function(err, metadata) {
    // `metadata` contains information about this bucket.
    });

There was a bit of confusion around this, though. Like, is that really the only way to check if something exists? Seeing if there was an error with a 404 returned? What if I want to get a bucket, otherwise have it created?

Check out the examples below to see some before and afters with these use cases in mind.

Previously:

function createTopic() {
  pubsub.createTopic('new-topic-name', function(err, topic, apiResponse) {
    // Topic created!
  });
}

function doesBucketExist() {
  bucket.getMetadata(function(err, apiResponse) {
    if (err.code === 404) {
      // Bucket doesn't exist!
    }
  });
}

function getDataset() {
  dataset.getMetadata(function(err, metadata, apiResponse) {
    // dataset.metadata is populated.
  });
}

function getOrCreateDataset() {
  dataset.getMetadata(function(err) {
    if (err && err.code === 404) {
      bigQuery.createDataset(dataset.name, function(err, dataset) {
        // Dataset created!
      });
    }
  });
}

Now:

function createTopic() {
  topic.create(function(err, topic, apiResponse) {
    // Topic created!
  });
}

function doesBucketExist() {
  bucket.exists(function(err, exists) {
    if (exists) {
      // Bucket exists!
    }
  });
}

function getDataset() {
  dataset.get(function(err, dataset, apiResponse) {
    // dataset.metadata is populated.
  });
}

function getOrCreateDataset() {
  dataset.get({ autoCreate: true }, function(err, dataset, apiResponse) {
    // Dataset exists and is ready to use!
  });
}

NOTE The old methods are still supported and will continue to be.

* All except Datastore. For now.

Features

  • Core (#923): Return better API errors.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.