How to use the thenify.withCallback function in thenify

To help you get started, we’ve selected a few thenify 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 node-opcua / node-opcua / packages / node-opcua-server / source / base_server.ts View on Github external
// xx response.serviceDiagnostics.push( new DiagnosticInfo({ additionalInfo: messages.join("\n")}));

    assert(_.isArray(messages));
    assert(typeof messages[0] === "string");

    response.responseHeader.stringTable = messages;
    // tslint:disable:no-console
    console.log(chalk.cyan(" messages "), messages.join("\n"));
    return response;
}

// tslint:disable:no-var-requires
const thenify = require("thenify");
const opts = { multiArgs: false };
OPCUABaseServer.prototype.resumeEndPoints = thenify.withCallback(OPCUABaseServer.prototype.resumeEndPoints, opts);
OPCUABaseServer.prototype.suspendEndPoints = thenify.withCallback(OPCUABaseServer.prototype.suspendEndPoints, opts);
OPCUABaseServer.prototype.suspendEndPoints = thenify.withCallback(OPCUABaseServer.prototype.suspendEndPoints, opts);
github node-opcua / node-opcua / packages / node-opcua-client / src / client_base.js View on Github external
console.log("        .initialDelay........... ", this.connectionStrategy.initialDelay);
    console.log("        .maxDelay............... ", this.connectionStrategy.maxDelay);
    console.log("        .randomisationFactor.... ", this.connectionStrategy.randomisationFactor);
    console.log("  keepSessionAlive.............. ", this.keepSessionAlive);
};

exports.OPCUAClientBase = OPCUAClientBase;

const thenify = require("thenify");
/**
 * @method connect
 * @param endpointUrl {string}
 * @async
 * @return {Promise}
 */
OPCUAClientBase.prototype.connect = thenify.withCallback(OPCUAClientBase.prototype.connect);
OPCUAClientBase.prototype.disconnect = thenify.withCallback(OPCUAClientBase.prototype.disconnect);
OPCUAClientBase.prototype.getEndpoints = thenify.withCallback(OPCUAClientBase.prototype.getEndpoints);
OPCUAClientBase.prototype.findServers = thenify.withCallback(OPCUAClientBase.prototype.findServers);
OPCUAClientBase.prototype.findServersOnNetwork = thenify.withCallback(OPCUAClientBase.prototype.findServersOnNetwork);
// deprecated:
OPCUAClientBase.prototype.getEndpointsRequest = thenify.withCallback(OPCUAClientBase.prototype.getEndpointsRequest);
github skale-me / skale / lib / dataset.js View on Github external
Dataset.prototype.values = function () {return this.map(a => a[1]);};

Dataset.prototype.lookup = thenify(function (key, done) {
  return this.filter((kv, args) => kv[0] === args.key, {key})
    .map(kv => kv[1])
    .collect(done);
});

Dataset.prototype.countByValue = thenify(function (done) {
  return this.map(e => [e, 1])
    .reduceByKey((a, b) => a + b, 0)
    .collect(done);
});

Dataset.prototype.countByKey = thenify(function (done) {
  return this.mapValues(function () {return 1;})
    .reduceByKey((a, b) => a + b, 0)
    .collect(done);
});

Dataset.prototype.collect = thenify(function (done) {
  return this.aggregate((a, b) => {a.push(b); return a;}, (a, b) => a.concat(b), [], done);
});

// The stream action allows the master to return a dataset as a stream
// Each worker spills its partitions to disk
// then master pipes each remote partition into output stream
Dataset.prototype.stream = function (options = {}) {
  const self = this;
  const outStream = merge2();
  const opt = {
github node-opcua / node-opcua / packages / node-opcua-client-proxy / src / proxy.js View on Github external
Object.defineProperty(proxyObject, "__monitoredItem_execution_flag", {value: monitoredItem, enumerable: false});

    proxyObject.__monitoredItem_execution_flag.on("changed", function (dataValue) {
        proxyObject.executableFlag = dataValue.value.value;
        //xx console.log(" execution flag = ", proxyObject.executableFlag , proxyObject.browseName , proxyObject.nodeId.toString());
        //xx proxyObject.emit("execution_flag_changed",proxyObject.executableFlag);
    });
};

exports.UAProxyManager = UAProxyManager;

const thenify = require("thenify");
UAProxyManager.prototype.start = thenify.withCallback(UAProxyManager.prototype.start);
UAProxyManager.prototype.stop = thenify.withCallback(UAProxyManager.prototype.stop);

UAProxyManager.prototype.getObject = thenify.withCallback(UAProxyManager.prototype.getObject);
ProxyBaseNode.prototype.readValue  = thenify.withCallback(ProxyBaseNode.prototype.readValue);
ProxyBaseNode.prototype.writeValue = thenify.withCallback(ProxyBaseNode.prototype.writeValue);
github node-opcua / node-opcua / packages / node-opcua-client / src / opcua_client.js View on Github external
* @param userIdentityInfo
 * @return {Promise}
 * @async
 */
OPCUAClient.prototype.changeSessionIdentity = thenify.withCallback(OPCUAClient.prototype.changeSessionIdentity);
/**
 * @method closeSession
 * @param session {ClientSession}
 * @param deleteSubscriptions  {Boolean} - whether to delete
 * @return {Promise}
 * @async
 * @example
 *    const session  = await client.createSession();
 *    await client.closeSession(session);
 */
OPCUAClient.prototype.closeSession = thenify.withCallback(OPCUAClient.prototype.closeSession);


const ClientSubscription = require("./client_subscription").ClientSubscription;
OPCUAClient.prototype.withSubscription = function (endpointUrl, subscriptionParameters, innerFunc, callback) {

    assert(_.isFunction(innerFunc));
    assert(_.isFunction(callback));

    this.withSession(endpointUrl, function (session, done) {
        assert(_.isFunction(done));

        const subscription = new ClientSubscription(session, subscriptionParameters);

        try {
            innerFunc(session, subscription, function () {
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
exports.ClientSession = ClientSession;



const thenify = require("thenify");
const opts = { multiArgs : false };
ClientSession.prototype.browse                = thenify.withCallback(ClientSession.prototype.browse,opts);
ClientSession.prototype.readVariableValue     = thenify.withCallback(ClientSession.prototype.readVariableValue,opts);
ClientSession.prototype.readHistoryValue      = thenify.withCallback(ClientSession.prototype.readHistoryValue,opts);
ClientSession.prototype.write                 = thenify.withCallback(ClientSession.prototype.write,opts);
ClientSession.prototype.writeSingleNode       = thenify.withCallback(ClientSession.prototype.writeSingleNode,opts);
ClientSession.prototype.readAllAttributes     = thenify.withCallback(ClientSession.prototype.readAllAttributes,opts);
ClientSession.prototype.read                  = thenify.withCallback(ClientSession.prototype.read,opts);
ClientSession.prototype.createSubscription    = thenify.withCallback(ClientSession.prototype.createSubscription,opts);
ClientSession.prototype.deleteSubscriptions   = thenify.withCallback(ClientSession.prototype.deleteSubscriptions,opts);
ClientSession.prototype.transferSubscriptions = thenify.withCallback(ClientSession.prototype.transferSubscriptions,opts);
ClientSession.prototype.createMonitoredItems  = thenify.withCallback(ClientSession.prototype.createMonitoredItems,opts);
ClientSession.prototype.modifyMonitoredItems  = thenify.withCallback(ClientSession.prototype.modifyMonitoredItems,opts);
ClientSession.prototype.modifySubscription    = thenify.withCallback(ClientSession.prototype.modifySubscription,opts);
ClientSession.prototype.setMonitoringMode     = thenify.withCallback(ClientSession.prototype.setMonitoringMode,opts);
ClientSession.prototype.publish               = thenify.withCallback(ClientSession.prototype.publish,opts);
ClientSession.prototype.republish             = thenify.withCallback(ClientSession.prototype.republish,opts);
ClientSession.prototype.deleteMonitoredItems  = thenify.withCallback(ClientSession.prototype.deleteMonitoredItems,opts);
ClientSession.prototype.setPublishingMode     = thenify.withCallback(ClientSession.prototype.setPublishingMode,opts);
ClientSession.prototype.translateBrowsePath   = thenify.withCallback(ClientSession.prototype.translateBrowsePath,opts);
ClientSession.prototype.performMessageTransaction= thenify.withCallback(ClientSession.prototype.performMessageTransaction,opts);
ClientSession.prototype.close                 = thenify.withCallback(ClientSession.prototype.close,opts);
ClientSession.prototype.call                  = thenify.withCallback(ClientSession.prototype.call,opts);
ClientSession.prototype.getMonitoredItems     = thenify.withCallback(ClientSession.prototype.getMonitoredItems,opts);
ClientSession.prototype.getArgumentDefinition = thenify.withCallback(ClientSession.prototype.getArgumentDefinition,opts);
github skale-me / skale / lib / client.js View on Github external
this.output.write(msg);
  } catch(err) {
    throw new Error('send error');
  }
});

Client.prototype.devices = thenify(function (o, callback) {
  var self = this;
  this.send(0, {cmd: 'devices', data: {query: o}}, function (err, dev) {
    for (var i in dev)
      self.hostId[dev[i].uuid] = dev[i].id;
    callback(err, dev);
  });
});

Client.prototype.get = thenify(function (uuid, callback) {
  this.send(0, {cmd: 'get', data: uuid}, callback);
});

Client.prototype.notify = function (uuid) {
  this.output.write({cmd: 'notify', data: uuid});
};

Client.prototype.subscribe = function (topic) {
  this.output.write({cmd: 'subscribe', data: topic});
  return this;
};

Client.prototype.unsubscribe = function (topic) {
  this.output.write({cmd: 'unsubscribe', data: topic});
};
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
ClientSession.prototype.browse                = thenify.withCallback(ClientSession.prototype.browse,opts);
ClientSession.prototype.readVariableValue     = thenify.withCallback(ClientSession.prototype.readVariableValue,opts);
ClientSession.prototype.readHistoryValue      = thenify.withCallback(ClientSession.prototype.readHistoryValue,opts);
ClientSession.prototype.write                 = thenify.withCallback(ClientSession.prototype.write,opts);
ClientSession.prototype.writeSingleNode       = thenify.withCallback(ClientSession.prototype.writeSingleNode,opts);
ClientSession.prototype.readAllAttributes     = thenify.withCallback(ClientSession.prototype.readAllAttributes,opts);
ClientSession.prototype.read                  = thenify.withCallback(ClientSession.prototype.read,opts);
ClientSession.prototype.createSubscription    = thenify.withCallback(ClientSession.prototype.createSubscription,opts);
ClientSession.prototype.deleteSubscriptions   = thenify.withCallback(ClientSession.prototype.deleteSubscriptions,opts);
ClientSession.prototype.transferSubscriptions = thenify.withCallback(ClientSession.prototype.transferSubscriptions,opts);
ClientSession.prototype.createMonitoredItems  = thenify.withCallback(ClientSession.prototype.createMonitoredItems,opts);
ClientSession.prototype.modifyMonitoredItems  = thenify.withCallback(ClientSession.prototype.modifyMonitoredItems,opts);
ClientSession.prototype.modifySubscription    = thenify.withCallback(ClientSession.prototype.modifySubscription,opts);
ClientSession.prototype.setMonitoringMode     = thenify.withCallback(ClientSession.prototype.setMonitoringMode,opts);
ClientSession.prototype.publish               = thenify.withCallback(ClientSession.prototype.publish,opts);
ClientSession.prototype.republish             = thenify.withCallback(ClientSession.prototype.republish,opts);
ClientSession.prototype.deleteMonitoredItems  = thenify.withCallback(ClientSession.prototype.deleteMonitoredItems,opts);
ClientSession.prototype.setPublishingMode     = thenify.withCallback(ClientSession.prototype.setPublishingMode,opts);
ClientSession.prototype.translateBrowsePath   = thenify.withCallback(ClientSession.prototype.translateBrowsePath,opts);
ClientSession.prototype.performMessageTransaction= thenify.withCallback(ClientSession.prototype.performMessageTransaction,opts);
ClientSession.prototype.close                 = thenify.withCallback(ClientSession.prototype.close,opts);
ClientSession.prototype.call                  = thenify.withCallback(ClientSession.prototype.call,opts);
ClientSession.prototype.getMonitoredItems     = thenify.withCallback(ClientSession.prototype.getMonitoredItems,opts);
ClientSession.prototype.getArgumentDefinition = thenify.withCallback(ClientSession.prototype.getArgumentDefinition,opts);
ClientSession.prototype.queryFirst            = thenify.withCallback(ClientSession.prototype.queryFirst,opts);
ClientSession.prototype.registerNodes         = thenify.withCallback(ClientSession.prototype.registerNodes,opts);
ClientSession.prototype.unregisterNodes       = thenify.withCallback(ClientSession.prototype.unregisterNodes,opts);
ClientSession.prototype.readNamespaceArray    = thenify.withCallback(ClientSession.prototype.readNamespaceArray,opts);
github node-modules / mm / lib / mm.js View on Github external
exports._mockError = function(mod, method, error, props, timeout, once) {
  if (typeof props === 'number') {
    timeout = props;
    props = {};
  }
  error = exports._createError(error, props);

  if (timeout) {
    timeout = parseInt(timeout, 10);
  }
  timeout = timeout || 0;
  mock(mod, method, thenify(function() {
    const callback = getCallback(arguments);
    setTimeout(function() {
      if (once) {
        exports.restore();
      }
      callback(error);
    }, timeout);
  }));
  return this;
};
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
return session._namespaceArray.indexOf(namespaceUri);
};

ClientSession.prototype.__defineGetter__("isReconnecting",function() {
    return this._client ? this._client.isReconnecting : false;
});



exports.ClientSession = ClientSession;



const thenify = require("thenify");
const opts = { multiArgs : false };
ClientSession.prototype.browse                = thenify.withCallback(ClientSession.prototype.browse,opts);
ClientSession.prototype.readVariableValue     = thenify.withCallback(ClientSession.prototype.readVariableValue,opts);
ClientSession.prototype.readHistoryValue      = thenify.withCallback(ClientSession.prototype.readHistoryValue,opts);
ClientSession.prototype.write                 = thenify.withCallback(ClientSession.prototype.write,opts);
ClientSession.prototype.writeSingleNode       = thenify.withCallback(ClientSession.prototype.writeSingleNode,opts);
ClientSession.prototype.readAllAttributes     = thenify.withCallback(ClientSession.prototype.readAllAttributes,opts);
ClientSession.prototype.read                  = thenify.withCallback(ClientSession.prototype.read,opts);
ClientSession.prototype.createSubscription    = thenify.withCallback(ClientSession.prototype.createSubscription,opts);
ClientSession.prototype.deleteSubscriptions   = thenify.withCallback(ClientSession.prototype.deleteSubscriptions,opts);
ClientSession.prototype.transferSubscriptions = thenify.withCallback(ClientSession.prototype.transferSubscriptions,opts);
ClientSession.prototype.createMonitoredItems  = thenify.withCallback(ClientSession.prototype.createMonitoredItems,opts);
ClientSession.prototype.modifyMonitoredItems  = thenify.withCallback(ClientSession.prototype.modifyMonitoredItems,opts);
ClientSession.prototype.modifySubscription    = thenify.withCallback(ClientSession.prototype.modifySubscription,opts);
ClientSession.prototype.setMonitoringMode     = thenify.withCallback(ClientSession.prototype.setMonitoringMode,opts);
ClientSession.prototype.publish               = thenify.withCallback(ClientSession.prototype.publish,opts);
ClientSession.prototype.republish             = thenify.withCallback(ClientSession.prototype.republish,opts);
ClientSession.prototype.deleteMonitoredItems  = thenify.withCallback(ClientSession.prototype.deleteMonitoredItems,opts);

thenify

Promisify a callback-based function

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis

Popular thenify functions