How to use the cuid/dist/node-cuid function in cuid

To help you get started, we’ve selected a few cuid 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 yhat / rodeo / src / node / kernels / python / client.js View on Github external
function request(client, invocation, options) {
  const childProcess = client.childProcess,
    requestMap = client.requestMap,
    id = cuid(),
    inputPromise = write(childProcess, _.assign({id}, invocation)),
    resolveEvent = options.resolveEvent,
    hidden = options.hidden,
    startTime = new Date().getTime(),
    outputPromise = new Promise(function (resolve, reject) {
      requestMap[id] = {id, invocation, resolveEvent, hidden, deferred: {resolve, reject}};
    });

  return inputPromise
    .then(() => outputPromise)
    .finally(function () {
      const endTime = (new Date().getTime() - startTime) + 'ms',
        timeoutTime = endTime - 60000 * 10, // ten minutes
        maxSize = 50;
      let currentSize = _.size(requestMap);
github yhat / rodeo / src / node / services / browser-windows.js View on Github external
function send(windowName, eventName) {
  let inboundEmitter = electron.ipcMain,
    window = getByName(windowName),
    outboundEmitter = window && window.webContents,
    eventId = cuid(),
    startTime = new Date().getTime(),
    args = _.map(_.slice(arguments, 2), arg => _.isBuffer(arg) ? arg.toString() : arg);

  if (!outboundEmitter) {
    return bluebird.resolve();
  }

  return new Promise(function (resolve, reject) {
    // noinspection JSDuplicatedDeclaration
    let response,
      eventReplyName = eventName + '_reply',
      timer = setInterval(function () {
        if (outboundEmitter.isDestroyed()) {
          log('info', 'ipc ' + eventId + ': will never complete because target window is gone', eventName);
          inboundEmitter.removeListener(eventReplyName, response);
          clearInterval(timer);
github yhat / rodeo / src / node / kernels / python / client.js View on Github external
input(str) {
    return write(this.childProcess, {id: cuid(), method: 'input', args: [str]});
  }
github yhat / rodeo / src / node / kernels / python / client.js View on Github external
interrupt() {
    const id = cuid(),
      target = 'manager',
      method = 'interrupt_kernel';

    return write(this.childProcess, {method, target, id});
  }
github yhat / rodeo / src / node / index.js View on Github external
return new bluebird(function (resolveInstanceId) {
    let instanceId = cuid();

    kernelClients[instanceId] = new bluebird(function (resolveClient) {
      log('info', 'creating new python kernel process', 'creating python client');
      const client = kernelsPythonClient.create(options)
        .on('ready', function () {
          log('info', 'new python kernel process is ready', instanceId, 'process', client.childProcess.pid, optionsForLog);
          resolveClient(client);
        })
        .on('event', function (source, data) {
          log('info', 'python kernel process event', instanceId, 'process', client.childProcess.pid, optionsForLog, {source, data});
        })
        .on('error', function (error) {
          log('info', 'python kernel process error', instanceId, 'process', client.childProcess.pid, optionsForLog, error);
          browserWindows.send('mainWindow', 'error', instanceId, errorClone.toObject(error)).catch(_.noop);
        })
        .on('close', function (code, signal) {

cuid

Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis