How to use utile - 10 common examples

To help you get started, we’ve selected a few utile 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 nodejitsu / godot / lib / godot / net / server.js View on Github external
if (Array.isArray(options.reactors)) {
    options.reactors.forEach(function (reactor) {
      self.add(reactor);
    });
  }

  if (!this.multiplex) {
    this.createReactors('default');
  }
};

//
// Inherit from events.EventEmitter
//
utile.inherits(Server, events.EventEmitter);

//
// ### function add (reactor)
// #### @reactor {reactor} Reactor to add to this server
// Adds the specified `reactor` to this server. All data
// from incoming `host:port` pairs will be written to a unique
// instance of this reactor.
//
Server.prototype.add = function (reactor) {
  this.emit('add', reactor);
  reactor.on('error', this.emit.bind(this, 'error'));
  reactor.on('reactor:error', this.emit.bind(this, 'reactor:error'));
  this.reactors[reactor.id] = reactor;
  //
  // Add reactor to the running set
  // Remark: there will only be one host in case of multiplex = false;
github browserify / wzrd.in / lib / bundler / bundler.js View on Github external
bundler.ready = false;

  npm.load({}, function (err) {
    if (err) {
      // What would be really cool is if I checked to see if there was an error
      // event listener or not.
      bundler.emit('error', err);
    }

    bundler.ready = true;
    bundler.emit('bundler::ready');
  });
};

util.inherits(Bundler, EventEmitter2);

Bundler.prototype.bundle = function (src, cb) {
  var bundler = this,
      modules = detective(src);

  npm.commands.install(modules, function (err) {
    if (err) {
      cb(err);
    }

    var bundle, doc;

    try {
      bundle = browserify(bundler.options)
        .addEntry('index.js', { body: src || '' })
        .bundle();
github foreversd / forever / lib / forever / monitor.js View on Github external
this.args.unshift(script);
  }
  
  if (this.sourceDir) {
    this.args[0] = path.join(this.sourceDir, this.args[0]);
  }
  
  //
  // Bootstrap this instance now that options
  // have been set
  //
  broadway.App.call(this, { bootstrapper: { bootstrap: bootstrap } });
};

// Inherit from events.EventEmitter
utile.inherits(Monitor, broadway.App);

//
// ### function start ([restart])
// #### @restart {boolean} Value indicating whether this is a restart.
// Start the process that this instance is configured for
//
Monitor.prototype.start = function (restart) {
  var self = this,
      child;

  if (this.running && !restart) {
    process.nextTick(function () {
      self.emit('error', new Error('Cannot start process that is already running.'));
    });
    return this;
  }
github foreversd / forever-monitor / lib / forever-monitor / monitor.js View on Github external
this.args.unshift(script);
  }

  if (this.sourceDir) {
    this.args[0] = path.join(this.sourceDir, this.args[0]);
  }

  //
  // Bootstrap this instance now that options
  // have been set
  //
  broadway.App.call(this, { bootstrapper: { bootstrap: bootstrap } });
});

// Inherit from events.EventEmitter
utile.inherits(Monitor, broadway.App);

//
// ### function start ([restart])
// #### @restart {boolean} Value indicating whether this is a restart.
// Start the process that this instance is configured for
//
Monitor.prototype.start = function(restart) {
  const self = this;

  if (this.running && !restart) {
    process.nextTick(function() {
      self.emit(
        'error',
        new Error('Cannot start process that is already running.')
      );
    });
github garden20 / gardener / node_modules / forever-monitor / lib / forever-monitor / monitor.js View on Github external
this.args.unshift(script);
  }

  if (this.sourceDir) {
    this.args[0] = path.join(this.sourceDir, this.args[0]);
  }

  //
  // Bootstrap this instance now that options
  // have been set
  //
  broadway.App.call(this, { bootstrapper: { bootstrap: bootstrap } });
};

// Inherit from events.EventEmitter
utile.inherits(Monitor, broadway.App);

//
// ### function start ([restart])
// #### @restart {boolean} Value indicating whether this is a restart.
// Start the process that this instance is configured for
//
Monitor.prototype.start = function (restart) {
  var self = this,
      child;

  if (this.running && !restart) {
    process.nextTick(function () {
      self.emit('error', new Error('Cannot start process that is already running.'));
    });
    return this;
  }
github ezpaarse-project / ezpaarse / node_modules / forever / node_modules / forever-monitor / lib / forever-monitor / monitor.js View on Github external
this.args.unshift(script);
  }

  if (this.sourceDir) {
    this.args[0] = path.join(this.sourceDir, this.args[0]);
  }

  //
  // Bootstrap this instance now that options
  // have been set
  //
  broadway.App.call(this, { bootstrapper: { bootstrap: bootstrap } });
};

// Inherit from events.EventEmitter
utile.inherits(Monitor, broadway.App);

//
// ### function start ([restart])
// #### @restart {boolean} Value indicating whether this is a restart.
// Start the process that this instance is configured for
//
Monitor.prototype.start = function (restart) {
  var self = this,
      child;

  if (this.running && !restart) {
    process.nextTick(function () {
      self.emit('error', new Error('Cannot start process that is already running.'));
    });
    return this;
  }
github nodejitsu / godot / lib / godot / reactor / redis.js View on Github external
if (!this.client) {
    this.client = redis.createClient(this.port, this.host, this.redisOptions);

    this.client.on('error', this.emit.bind(this, 'reactor:error'));
    if (this.password) {
      this.client.auth(this.password, function () {
        // Remark: What if data is sent before we are authenticated?
      });
    }
  }
};

//
// Inherit from ReadWriteStream
//
utile.inherits(Redis, ReadWriteStream);

//
// ### function write (data)
// #### @data {Object} JSON to store in Redis
// Uses Redis to track active resources using a bitmap
//
Redis.prototype.write = function (data) {
  var self = this;
  this.redisFn(this.client, data, function (err, data) {
    if (err) { return self.emit('reactor:error', err) }
  });

  this.emit('data', data);

};
github nodejitsu / godot / lib / godot / common / metrics.js View on Github external
//
        // pass the metric name and the actual metric for processing.
        //
        data[id][metric] && that.process(metric, data[id][metric], socket.id);
      });
    });

    socket.emit('metrics::available', data);
    that.containers = containers;

  }, options.interval);

  eventvat.call(this, options);
};

utile.inherits(Metrics, eventvat);

//
// a method for consuming batches of metrics
//
Metrics.prototype.batch = function(data) {

  var autoexpire = this.autoexpire;

  //
  // Test Hook
  //
  this.socket.debug && this.socket.emit('metrics::batch', data);

  //
  // reconstitute the data into a working eventvat
  //
github nodejitsu / kohai / lib / router.js View on Github external
*
 */

// Mostly copy-pasted from the cli router from director core.
var utile = require('utile'),
    director = require('director');

var Router = exports.Router = function (routes) {
  director.Router.call(this, routes);
  this.recurse = 'backward';
};

//
// Inherit from `director.Router`.
//
utile.inherits(Router, director.Router);

//
// ### function configure (options)
// #### @options {Object} **Optional** Options to configure this instance with
// Configures this instance with the specified `options`.
//
Router.prototype.configure = function (options) {
  options = options || {};
  director.Router.prototype.configure.call(this, options);
  
  //
  // Our delimiter here is a space.
  // e.g. `!foo bar baz`
  //
  this.delimiter = ' ';
github flatiron / commandful / lib / commandful.js View on Github external
});
          })(m)
        }
      }
    }
  });

  return router;
};



//
// Inherit from `director.http.Router`.
//
utile.inherits(CommandfulRouter, director.cli.Router);


//
// Name this `broadway` plugin.
//
exports.name = 'commandful';

//
// ### function init ()
// Initializes the `commandful` plugin with the App.
//
exports.init = function (done) {
  var resources,
      app = this;

  //

utile

A drop-in replacement for `util` with some additional advantageous functions

MIT
Latest version published 9 years ago

Package Health Score

35 / 100
Full package analysis

Popular utile functions