How to use the busyman.isFunction function in busyman

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 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 Alliasd / ELIoT / lib / coap-node.js View on Github external
req.on('error', function(err) {
        if (!_.isFunction(callback))
            self.emit('error', err);
        else if (err.retransmitTimeout)
            callback(null, { code: RSP.timeout });
        else
            callback(err);
    });
github freebirdjs / freebird-base / lib / device.js View on Github external
Device.prototype.ping = function (callback) {
    validate.fn(callback);

    var self = this,
        nc = this.get('netcore'),
        ping = nc ? nc.ping : undefined,
        err = anyEnableError.call(this),
        permAddr = this.get('permAddr');

    if (err)
        return setImmediate(callback, err);
    else if (!_.isFunction(ping))
        return setImmediate(callback, new Error('Net driver ping is not implemented'));

    ping.call(nc, permAddr, callback);
};
github freebirdjs / freebird-base / lib / gadget.js View on Github external
args = undefined;
    }

    validate.argTypes({ attrName: attrName, callback: callback });
    validate.array(args, 'args should be an array.');

    var self = this,
        nc = this.get('netcore'),
        exec = nc ? nc._findDriver('gad', 'exec') : undefined,
        err = anyEnableError.call(this),
        permAddr = this.get('permAddr'),
        auxId = this.get('auxId');

    if (err)
        return setImmediate(callback, err);
    else if (!_.isFunction(exec))
        return setImmediate(callback, 'Gadget driver exec is not implemented');

    exec(permAddr, auxId, attrName, args, function (err, data) {
        var result;

        if (!err) {
            result =  _.set({}, attrName, data); 
            self._handoff(EVTS.GadExec, { permAddr: permAddr, auxId: auxId, data: result });
        }

        callback(err, data);
    });
};
github freebirdjs / freebird-base / lib / gadget.js View on Github external
Gadget.prototype.write = function (attrName, val, callback) {
    validate.argTypes({ attrName: attrName, val: val, callback: callback });

    var self = this,
        nc = this.get('netcore'),
        write = nc ? nc._findDriver('gad', 'write') : undefined,
        err = anyEnableError.call(this),
        permAddr = this.get('permAddr'),
        auxId = this.get('auxId');

    if (err)
        return setImmediate(callback, err);
    else if (!_.isFunction(write))
        return setImmediate(callback, 'Gadget driver write is not implemented');

    write(permAddr, auxId, attrName, val, function (err, data) {
        var result;

        if (!err) {
            result =  _.set({}, attrName, _.isNil(data) ? val : data); 
            self.set('attrs', result);
            self._handoff(EVTS.GadWrite, { permAddr: permAddr, auxId: auxId, data: result });
        }

        callback(err, _.isNil(data) ? val : data);
    });
};
github freebirdjs / freebird-base / lib / gadget.js View on Github external
Gadget.prototype.read = function (attrName, callback) {
    validate.argTypes({ attrName: attrName, callback: callback });

    var self = this,
        nc = this.get('netcore'),
        read = nc ? nc._findDriver('gad', 'read') : undefined,
        err = anyEnableError.call(this),
        permAddr = this.get('permAddr'),
        auxId = this.get('auxId');

    if (err)
        return setImmediate(callback, err);
    else if (!_.isFunction(read))
        return setImmediate(callback, 'Gadget driver read is not implemented');

    read(permAddr, auxId, attrName, function (err, data) {
        var result;

        if (!err) {
            result = _.set({}, attrName, data);

            self.set('attrs', result);
            self._handoff(EVTS.GadRead, { permAddr: permAddr, auxId: auxId, data: result });
        }

        callback(err, data);
    });
};
github freebirdjs / freebird-base / lib / device.js View on Github external
Device.prototype.read = function (attrName, callback) {
    validate.argTypes({ attrName: attrName, callback: callback });

    var self = this,
        nc = this.get('netcore'),
        read = nc ? nc._findDriver('dev', 'read') : undefined,
        err = anyEnableError.call(this),
        permAddr = this.get('permAddr');

    if (err)
        return setImmediate(callback, err);
    else if (!_.isFunction(read))
        return setImmediate(callback, new Error('Device driver read is not implemented'));

    read(permAddr, attrName, function (err, data) {
        var result;

        if (!err) {
            result = _.set({}, attrName, data);

            self._handoff(BTM_EVTS.DevRead, { permAddr: permAddr, data: result });
            self.set('attrs', result);
        }

        callback(err, data);
    });
};
github lwmqn / qnode / lib / qnode.js View on Github external
checkout (duration, callback) {
    if (_.isFunction(duration)) {
      callback = duration
      duration = undefined
    }

    if (!_.isFunction(callback)) throw new TypeError('callback should be given and should be a function.')

    duration = duration || 0
    reporter.clear(this)
    this._sleep = true

    return request.checkout(this, duration, callback)
  }
github lwmqn / qnode / lib / qnode.js View on Github external
checkin (callback) {
    if (!_.isFunction(callback)) throw new TypeError('callback should be given and should be a function.')
    this._sleep = false
    return request.checkin(this, callback)
  }
github lwmqn / qnode / lib / qnode.js View on Github external
ping (callback) {
    if (!_.isFunction(callback)) throw new TypeError('callback should be given and should be a function.')
    return request.ping(this, callback)
  }
}

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