Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@google-cloud/promisify

googleapis21.6mApache-2.04.0.0TypeScript support: included

A simple utility for promisifying functions and classes.

readme

Google Cloud Platform logo

Google Cloud Common Promisify: Node.js Client

release level npm version

A simple utility for promisifying functions and classes.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Installing the client library

npm install @google-cloud/promisify

Using the client library

const {promisify} = require('@google-cloud/promisify');

/**
 * This is a very basic example function that accepts a callback.
 */
function someCallbackFunction(name, callback) {
  if (!name) {
    callback(new Error('Name is required!'));
  } else {
    callback(null, `Well hello there, ${name}!`);
  }
}

// let's promisify it!
const somePromiseFunction = promisify(someCallbackFunction);

async function quickstart() {
  // now we can just `await` the function to use it like a promisified method
  const [result] = await somePromiseFunction('nodestronaut');
  console.log(result);
}
quickstart();

It's unlikely you will need to install this package directly, as it will be installed as a dependency when you install other @google-cloud packages.

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
Quickstart source code Open in Cloud Shell

The Google Cloud Common Promisify Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/promisify@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

changelog

Changelog

npm history

4.0.0 (2023-08-08)

⚠ BREAKING CHANGES

  • upgrade to Node 14 (#325)

Miscellaneous Chores

3.0.1 (2022-08-23)

Bug Fixes

3.0.0 (2022-05-03)

⚠ BREAKING CHANGES

  • drop node 10 from engines list, update typescript to 4.6.3 (#300)

Build System

  • drop node 10 from engines list, update typescript to 4.6.3 (#300) (fed2f14)

2.0.4 (2021-09-09)

Bug Fixes

  • build: switch primary branch to main (#270) (11242f7)

2.0.3 (2020-09-04)

Bug Fixes

2.0.2 (2020-07-06)

Bug Fixes

2.0.1 (2020-05-08)

Bug Fixes

2.0.0 (2020-03-23)

⚠ BREAKING CHANGES

  • update to latest version of gts/typescript (#183)
  • drop Node 8 from engines field (#184)

Features

Build System

  • update to latest version of gts/typescript (#183) (9c3ed12)

1.0.4 (2019-12-05)

Bug Fixes

  • deps: pin TypeScript below 3.7.0 (e48750e)

1.0.3 (2019-11-13)

Bug Fixes

1.0.2 (2019-06-26)

Bug Fixes

  • docs: link to reference docs section on googleapis.dev (#128) (5a8bd90)

1.0.1 (2019-06-14)

Bug Fixes

1.0.0 (2019-05-02)

Build System

BREAKING CHANGES

  • upgrade engines field to >=8.10.0 (#108)

v0.4.0

02-12-2019 19:44 PST

New features

  • feat: add callbackify() and callbackifyAll() methods (#82)

Documentation

  • docs: update contributing path in README (#86)
  • chore: move CONTRIBUTING.md to root (#85)
  • docs: add lint/fix example to contributing guide (#83)

Internal / Testing Changes

  • build: create docs test npm scripts (#88)
  • build: test using @grpc/grpc-js in CI (#87)
  • build: ignore googleapis.com in doc link check (#81)
  • build: check broken links in generated docs (#79)
  • chore(deps): update dependency @types/sinon to v7 (#78)
  • chore(build): inject yoshi automation key (#77)
  • chore: update nyc and eslint configs (#76)
  • chore: fix publish.sh permission +x (#74)
  • fix(build): fix Kokoro release script (#73)
  • build: add Kokoro configs for autorelease (#72)
  • chore: always nyc report before calling codecov (#69)
  • chore: nyc ignore build/test by default (#68)
  • chore(build): update prettier config (#66)
  • fix: get the build passing (#65)
  • chore: update license file (#64)
  • fix(build): fix system key decryption (#60)
  • chore(deps): update dependency @types/sinon to v5.0.7 (#58)
  • fix: Pin @types/sinon to last compatible version (#57)
  • chore: add synth.metadata
  • chore(deps): update dependency gts to ^0.9.0 (#54)
  • chore: update eslintignore config (#53)
  • chore: use latest npm on Windows (#52)
  • chore: update CircleCI config (#51)
  • chore: include build in eslintignore (#48)
  • chore: update issue templates (#44)
  • chore: remove old issue template (#42)
  • build: run tests on node11 (#41)
  • chores(build): do not collect sponge.xml from windows builds (#40)
  • chores(build): run codecov on continuous builds (#39)
  • chore: update new issue template (#38)
  • chore(deps): update dependency sinon to v7 (#33)
  • build: fix codecov uploading on Kokoro (#34)
  • Update kokoro config (#30)
  • Update CI config (#28)
  • Don't publish sourcemaps (#26)
  • Update kokoro config (#24)
  • test: remove appveyor config (#23)
  • Update CI config (#22)
  • Enable prefer-const in the eslint config (#21)
  • Enable no-var in eslint (#19)
  • Update CI config (#18)

v0.3.1

Internal / Testing Changes

  • Add synth script and update CI (#14)
  • chore(deps): update dependency nyc to v13 (#12)
  • chore: ignore package-lock.json (#11)
  • chore(deps): lock file maintenance (#10)
  • chore: update renovate config (#9)
  • remove that whitespace (#8)
  • chore(deps): lock file maintenance (#7)
  • chore(deps): update dependency typescript to v3 (#6)
  • chore: assert.deelEqual => assert.deepStrictEqual (#5)
  • chore: move mocha options to mocha.opts (#4)
  • chore(deps): update dependency gts to ^0.8.0 (#1)
  • chore(deps): lock file maintenance (#3)
  • chore(deps): lock file maintenance (#2)