How to use the is_js.undefined function in is_js

To help you get started, we’ve selected a few is_js 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 qiscus / qiscus-sdk-web-core / src / lib / adapters / custom-event.js View on Github external
subscribeEvent (roomId, callback) {
      if (is.undefined(roomId)) throw new Error('`roomId` required')
      if (is.not.string(roomId)) throw new TypeError('`roomId` must have type of string')
      if (is.undefined(callback)) throw new Error('`callback` required')
      if (is.not.function(callback)) throw new TypeError('`callback` must have type of function')

      const topic = getTopic(roomId)
      // Only allow 1 subcription for now
      if (subscribedTopics[topic]) return
      mqttAdapter.mqtt.subscribe(topic)

      const cb = (payload) => {
        const parsedPayload = JSON.parse(payload)
        callback(parsedPayload)
      }
      events.on(topic, cb)
      subscribedTopics[topic] = cb
    },
github vadimdemedes / mongorito / src / query.js View on Github external
// if object was passed instead of key-value pair
    // iterate over that object and call .where(key, value)
    if (is.object(key)) {
      let conditions = key;
      let keys = Object.keys(conditions);

      keys.forEach(key => {
        this.where(key, conditions[key]);
      });
    }

    if (is.string(key)) {
      // if only one argument was supplied
      // save the key in this.lastKey
      // for future methods, like .equals()
      if (is.undefined(value)) {
        this.lastKey = key;
        return this;
      }

      // if value is a regular expression
      // use $regex modifier
      if (is.regexp(value)) {
        value = { $regex: value };
      }

      this.query[key] = value;
    }

    return this;
  }
github qiscus / qiscus-sdk-web-core / src / utils / adapters / custom-event.js View on Github external
subscribeEvent (roomId, callback) {
      if (is.undefined(roomId)) throw new Error('`roomId` required')
      if (is.not.string(roomId)) throw new TypeError('`roomId` must have type of string')
      if (is.undefined(callback)) throw new Error('`callback` required')
      if (is.not.function(callback)) throw new TypeError('`callback` must have type of function')

      const topic = getTopic(roomId)
      // Only allow 1 subcription for now
      if (subscribedTopics[topic]) return
      mqttAdapter.mqtt.subscribe(topic)

      const cb = (payload) => {
        const parsedPayload = JSON.parse(payload)
        callback(parsedPayload)
      }
      events.addListener(topic, cb)
      subscribedTopics[topic] = cb
    },
    unsubscribeEvent (roomId) {
github qiscus / qiscus-sdk-web-core / src / lib / adapters / custom-event.js View on Github external
subscribeEvent (roomId, callback) {
      if (is.undefined(roomId)) throw new Error('`roomId` required')
      if (is.not.string(roomId)) throw new TypeError('`roomId` must have type of string')
      if (is.undefined(callback)) throw new Error('`callback` required')
      if (is.not.function(callback)) throw new TypeError('`callback` must have type of function')

      const topic = getTopic(roomId)
      // Only allow 1 subcription for now
      if (subscribedTopics[topic]) return
      mqttAdapter.mqtt.subscribe(topic)

      const cb = (payload) => {
        const parsedPayload = JSON.parse(payload)
        callback(parsedPayload)
      }
      events.on(topic, cb)
      subscribedTopics[topic] = cb
    },
    unsubscribeEvent (roomId) {
github lithiumtech / lithium-sdk / lib / project.js View on Github external
.on('end', function () {
          var sdkConf = require(path.join(process.cwd(), 'sdk.conf.json'));
          if (!is.undefined(sdkConf.ng)) {
            gutil.log(gutil.colors.red('Angularjs support is already enabled on this project.'));
            process.exit(1);
          }
        })
        .on('error', function () {
github vadimdemedes / mongorito / build / mongorito.js View on Github external
keys.forEach(function (key) {
      var defaultValue = defaults[key];
      var actualValue = _this.get(key);

      if (is.undefined(actualValue)) {
        _this.set(key, defaultValue);
      }
    });
  };
github vadimdemedes / mongorito / lib / mongorito.js View on Github external
keys.forEach(function (key) {
		let defaultValue = defaults[key];
		let actualValue = self.get(key);

		if (is.undefined(actualValue)) {
			self.set(key, defaultValue);
		}
	});
};
github dot-microservices / dot-rest / src / server.js View on Github external
_on(method, path, handler) {
        if (is.undefined(handler)) handler = () => {};
        if (is.not.function(handler)) throw new Exception('invalid handler');
        if (is.not.function(this.$r[method])) throw new Exception('invalid method');

        this.$r[method](path, (req, res, params) => {
            req.params = params || {};
            const query = url.parse(req.url, true);
            req.query = query ? query.query || {} : {};
            body(req, (e, payload) => {
                req.body = payload;
                handler(req, res)
                    .then(r => {
                        if (r instanceof Buffer) return r.toString();
                        else if (r instanceof Array || is.object(r)) return JSON.stringify(r);
                        else if (is.not.existy(r) || is.nan(r)) throw new Exception('invalid value');
                        else return r.toString();
                    })
github vadimdemedes / mongorito / src / mongorito.js View on Github external
keys.forEach(key => {
      let defaultValue = defaults[key];
      let actualValue = this.get(key);

      if (is.undefined(actualValue)) {
        this.set(key, defaultValue);
      }
    });
  }