How to use the promise.adaptToPromise function in promise

To help you get started, we’ve selected a few promise 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 Azure / azure-sdk-for-node / test / services / servermanagement / servermanagement-tests.js View on Github external
suite.setupSuiteAsync(function (setUpDone) {

      // commonly used variables
      location = suite.Get('location', 'centralus');
      resourceGroupName = suite.Get('resourceGroupName', 'rsmt-rnr-rg');
      client = new ServerManagement(suite.credentials, suite.subscriptionId, baseUrl);

      // adapt the SMT client library to use promises.
      Promise.adaptToPromise(client.gateway);
      Promise.adaptToPromise(client.node);
      Promise.adaptToPromise(client.session);
      Promise.adaptToPromise(client.powerShell);

      setUpDone(); // We tell the test framework we are done setting up
      done(); // We tell mocha we are done with the 'before' part
    });
  });
github Azure / azure-sdk-for-node / test / services / servermanagement / servermanagement-tests.js View on Github external
suite.setupSuiteAsync(function (setUpDone) {

      // commonly used variables
      location = suite.Get('location', 'centralus');
      resourceGroupName = suite.Get('resourceGroupName', 'rsmt-rnr-rg');
      client = new ServerManagement(suite.credentials, suite.subscriptionId, baseUrl);

      // adapt the SMT client library to use promises.
      Promise.adaptToPromise(client.gateway);
      Promise.adaptToPromise(client.node);
      Promise.adaptToPromise(client.session);
      Promise.adaptToPromise(client.powerShell);

      setUpDone(); // We tell the test framework we are done setting up
      done(); // We tell mocha we are done with the 'before' part
    });
  });
github Azure / azure-sdk-for-node / test / services / servermanagement / servermanagement-tests.js View on Github external
suite.setupSuiteAsync(function (setUpDone) {

      // commonly used variables
      location = suite.Get('location', 'centralus');
      resourceGroupName = suite.Get('resourceGroupName', 'rsmt-rnr-rg');
      client = new ServerManagement(suite.credentials, suite.subscriptionId, baseUrl);

      // adapt the SMT client library to use promises.
      Promise.adaptToPromise(client.gateway);
      Promise.adaptToPromise(client.node);
      Promise.adaptToPromise(client.session);
      Promise.adaptToPromise(client.powerShell);

      setUpDone(); // We tell the test framework we are done setting up
      done(); // We tell mocha we are done with the 'before' part
    });
  });
github Azure / azure-sdk-for-node / test / services / servermanagement / servermanagement-tests.js View on Github external
Promise.adaptToPromise = function (fn, argumentCount) {
  if (typeof (fn) == 'object') {
    // adapt members of an object
    for (var each in fn) {
      if (typeof (fn[each]) == 'function' && !each.startsWith("begin")) {
        fn[each] = Promise.adaptToPromise(fn[each]);
      }
    }
    return;
  }
  if (typeof (fn) != 'function') {
    return;
  }
  // adapt a function.
  argumentCount = argumentCount || Infinity;
  return function () {
    var self = this;
    var args = Array.prototype.slice.call(arguments);
    return new Promise(function (resolve, reject) {
      while (args.length && args.length > argumentCount) {
        args.pop();
      }
github Azure / azure-sdk-for-node / test / services / servermanagement / servermanagement-tests.js View on Github external
suite.setupSuiteAsync(function (setUpDone) {

      // commonly used variables
      location = suite.Get('location', 'centralus');
      resourceGroupName = suite.Get('resourceGroupName', 'rsmt-rnr-rg');
      client = new ServerManagement(suite.credentials, suite.subscriptionId, baseUrl);

      // adapt the SMT client library to use promises.
      Promise.adaptToPromise(client.gateway);
      Promise.adaptToPromise(client.node);
      Promise.adaptToPromise(client.session);
      Promise.adaptToPromise(client.powerShell);

      setUpDone(); // We tell the test framework we are done setting up
      done(); // We tell mocha we are done with the 'before' part
    });
  });