How to use busyman - 10 common examples

To help you get started, we’ve selected a few busyman 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 PeterEB / coap-shepherd / lib / reqHandler.js View on Github external
function buildDevAttr(req) {
    var devAttr = {},  
        query = req.url ? req.url.split('?')[1] : undefined,
        queryParams = query ? query.split('&') : undefined,
        invalidAttrs = [];

    _.forEach(queryParams, function (queryParam, idx) {
        queryParams[idx] = queryParam.split('=');
    });

    _.forEach(queryParams, function(queryParam) {     // 'ep=clientName&lt=86400&lwm2m=1.0.0'
        if(queryParam[0] === 'ep') {
            devAttr.clientName = queryParam[1];
        } else if (queryParam[0] === 'lt') {
            devAttr.lifetime = parseInt(queryParam[1]);
        } else if (queryParam[0] === 'lwm2m') {
            devAttr.version = queryParam[1];
        } else if (queryParam[0] === 'mac') {
            devAttr.mac = queryParam[1];
        } else {
            invalidAttrs.push(queryParam[0]);
        }
    });
github freebirdjs / freebird / lib / components / handlers.js View on Github external
.removeAllListeners(EVT_BTM.NcBannedDevIncoming)
            .removeAllListeners(EVT_BTM.NcBannedDevReporting)
            .removeAllListeners(EVT_BTM.NcBannedGadIncoming)
            .removeAllListeners(EVT_BTM.NcBannedGadReporting)
            .removeAllListeners(EVT_BTM.DevError)
            .removeAllListeners(EVT_BTM.DevNetChanged)
            .removeAllListeners(EVT_BTM.DevPropsChanged)
            .removeAllListeners(EVT_BTM.DevAttrsChanged)
            .removeAllListeners(EVT_BTM.GadError)
            .removeAllListeners(EVT_BTM.GadPanelChanged)
            .removeAllListeners(EVT_BTM.GadPropsChanged)
            .removeAllListeners(EVT_BTM.GadAttrsChanged)
            .removeAllListeners(EVT_BTM.GadAttrsAppend);

    // Firstly bind the handlers to freebird
    _.forEach(handlers, function (lsn, key) {
        ncLsns[key] = lsn.bind(freebird);
    });

    // Then, attach the handlers to events                                  // VVVVVVVVVVVVVVVVVVVVVV [TODO] all kvps need to be checked
    freebird.on(EVT_BTM.NcError, ncLsns.ncError);                           // { ncName, error: err }
    freebird.on(EVT_BTM.NcEnabled, ncLsns.ncEnabled);
    freebird.on(EVT_BTM.NcDisabled, ncLsns.ncDisabled);
    freebird.on(EVT_BTM.NcStarted, ncLsns.ncStarted);
    freebird.on(EVT_BTM.NcStopped, ncLsns.ncStopped);
    freebird.on(EVT_BTM.NcReady, ncLsns.ncReady);                           // { ncName }
    freebird.on(EVT_BTM.NcPermitJoin, ncLsns.ncPermitJoin);                 // { ncName, timeLeft: self._joinTicks }

    freebird.on(EVT_BTM.NcDevIncoming, ncLsns.ncDevIncoming);               // { ncName, permAddr: permAddr, raw: rawDev }
    freebird.on(EVT_BTM.NcDevLeaving, ncLsns.ncDevLeaving);                 // { ncName, permAddr: permAddr }
    freebird.on(EVT_BTM.NcDevNetChanging, ncLsns.ncDevNetChanging);         // { ncName, permAddr: permAddr, data: changes }
    freebird.on(EVT_BTM.NcDevReporting, ncLsns.ncDevReporting);             // { ncName, permAddr: permAddr, data: devAttrs }
github freebirdjs / freebird / lib / legacy / nc_listeners.js View on Github external
module.exports = function attachEventListeners(freebird) {
    var ncLsns;

    freebird._ncEventListeners = freebird._ncEventListeners || {};
    ncLsns = freebird._ncEventListeners;

    // Firstly bind the handlers to freebird
    _.forEach(listeners, function (lsn, key) {
        if (key !== 'attachEventListeners')
            ncLsns[key] = lsn.bind(freebird);
    });

    // Then, attach the handlers to events
    freebird.on(LLEVT.NETCORE.ready, ncLsns.ncReady);                           // {}
    freebird.on(LLEVT.NETCORE.error, ncLsns.ncError);                           // { error: err }
    freebird.on(LLEVT.NETCORE.permitJoin, ncLsns.ncPermitJoin);                 // { timeLeft: self._joinTicks }
    freebird.on(LLEVT.NETCORE.started, ncLsns.ncStarted);
    freebird.on(LLEVT.NETCORE.stopped, ncLsns.ncStopped);
    freebird.on(LLEVT.NETCORE.enabled, ncLsns.ncEnabled);
    freebird.on(LLEVT.NETCORE.disabled, ncLsns.ncDisabled);
    freebird.on(LLEVT.NETCORE.devNetChanging, ncLsns.ncDevNetChanging);         // { permAddr: permAddr, data: changes }
    freebird.on(LLEVT.NETCORE.devIncoming, ncLsns.ncDevIncoming);               // { permAddr: permAddr, raw: rawDev }
    freebird.on(LLEVT.NETCORE.bannedDevIncoming, ncLsns.ncBannedDevIncoming);   // { permAddr: permAddr, raw: rawDev }
    freebird.on(LLEVT.NETCORE.devLeaving, ncLsns.ncDevLeaving);                 // { permAddr: permAddr }
github lwmqn / shepherd / lib / components / qnode.js View on Github external
_.forEach(self.objList, (iids, oid) => {
      _.forEach(iids, (iid) => {
        const path = mutils.createPath('/', oid, iid)
        readAllProms.push(self.readReq(path)) // readReq will update the database
      })
    })
    return Q.all(readAllProms)
github freebirdjs / freebird / lib / components / registry.js View on Github external
function registerDevice(freebird, dev, callback) {
    var devId, oldDev;

    if (!validate.isDevice(dev)) {
        setImmediate(callback, new TypeError('Input dev is not a valid device instance'));
        return freebird;
    }

    devId = dev.get('id');
    oldDev = _.isNil(devId) ? undefined : freebird.findById('device', devId);

    if (oldDev) {
        setImmediate(callback, new Error('Device with id: ' + devId + ' already exists, unregister it first'));
        return freebird;
    }

    if (dev._recovering) {   // recovered from database (when at booting up or restarting stage)
        freebird._devbox.set(devId, dev, function (err, id) {
            if (!err)
                dev._recovering = false;

            callback(err, id);
        });
    } else {
        dev._poke();
        dev.set('net', {
github lwmqn / qnode / lib / qnode.js View on Github external
subscribe (topics, opts, callback) {
    if (_.isFunction(opts)) {
      callback = opts
      opts = { qos: 0 }
    }

    if (!_.isFunction(callback)) throw new TypeError('callback should be given and should be a function.')
    this.mc.subscribe(topics, opts, callback) // function (err, granted)
    return this
  }
github PeterEB / coap-shepherd / lib / coap-node.js View on Github external
function getAttrQuery(attr) {
    var query = '';

    _.forEach(attr, function (value, key) {
        if (key === 'step')
            query = query + 'stp=' + value + '&'; 
        else 
            query = query + key + '=' + value + '&';
    });

    return query.slice(0, query.length - 1);    // take off the last '&'
}
github PeterEB / coap-shepherd / lib / components / coap-node.js View on Github external
function getAttrQuery(attr) {
    var query = '';

    _.forEach(attr, function (value, key) {
        if (key === 'step')
            query = query + 'stp=' + value + '&'; 
        else 
            query = query + key + '=' + value + '&';
    });

    return query.slice(0, query.length - 1);    // take off the last '&'
}
github Alliasd / ELIoT / lib / coap-node.js View on Github external
CoapNode.prototype._disableAllReport = function () {
    var self = this;

    helper.heartbeat(this, false);

    _.forEach(this._reporters, function (rpt, key) {
        var oid = key.split('/')[0],
            iid = key.split('/')[1],
            rid = key.split('/')[2];

        self._disableReport(oid, iid, rid, function (err, result) {
            if (err)
                self.emit('error', err);
        });
    });
};
github lwmqn / qnode / lib / reporter.js View on Github external
rRpt.max = setInterval(() => {
      rAttrs.mute = true
      dumper((err, val) => {
        if (err) console.warn(err)
        rAttrs.mute = false
        notifier.data = val
        qn.notify(notifier, () => {})
      })

      if (!_.isNil(rRpt.min)) clearTimeout(rRpt.min)

      rRpt.min = null
      rRpt.min = setTimeout(() => {
        if (pmin === 0) {
          rAttrs.mute = false
        } else {
          dumper((err, val) => {
            if (err) console.warn(err)
            rAttrs.mute = false
            notifier.data = val
            qn.notify(notifier, () => {})
          })
        }
      }, pmin)
    }, pmax)

busyman

A lightweight and lodash-like JavaScript utility library

MIT
Latest version published 8 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages