How to use the is_js.object 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 vadimdemedes / mongorito / src / mongorito.js View on Github external
hook (when, action, method) {
    // if object is given
    // iterate and call .hook()
    // for each entry
    if (is.object(when)) {
      let hooks = when;
      let keys = Object.keys(hooks);

      keys.forEach(key => {
        let [when, action] = key.split(':');
        let method = hooks[key];

        this.hook(when, action, method);
      });

      return;
    }

    // if array is given
    // iterate and call .hook()
    // for each item
github vadimdemedes / mongorito / src / query.js View on Github external
where (key, value) {
    // 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;
      }
github vadimdemedes / mongorito / build / query.js View on Github external
Query.prototype.where = function where(key, value) {
    var _this = this;
    // if object was passed instead of key-value pair
    // iterate over that object and call .where(key, value)
    if (is.object(key)) {
      (function () {
        var conditions = key;
        var keys = Object.keys(conditions);

        keys.forEach(function (key) {
          return _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;
github vadimdemedes / mongorito / lib / mongorito.js View on Github external
Model.prototype.set = function (key, value) {
	// if object passed instead of key-value pair
	// iterate and call set on each item
	if (is.object(key)) {
		let attrs = key;
		let keys = Object.keys(attrs);

		let self = this;

		keys.forEach(function (key) {
			self.set(key, attrs[key]);
		});

		return;
	}

	// check if the value actually changed
	let previousValue = this.get(key);

	if (previousValue !== value) {
github dot-microservices / dot / src / base.js View on Github external
constructor(options) {
        this.COMMAND_CLEAN_SHUTDOWN = '#CS#';
        this.options = { delimiter: '.', iface: 'eth0', debug: false, secret: 'dot' };
        if (is.object(options) && is.not.array(options))
            this.options = Object.assign(this.options, options);
    }
github dot-microservices / dot-rest / src / server.js View on Github external
.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();
                    })
                    .then(d => {
github dot-microservices / dot-rest / src / client.js View on Github external
post(service, method, options) {
        if (is.object(method)) {
            options = method;
            method = null;
        }
        return this._request('post', service, method, options);
    }
github dot-microservices / dot-rest / src / client.js View on Github external
this._registry.get(service).then(address => {
                if (is.string(address) && is.not.empty(address) && address.includes(':')) {
                    let url = `http://${ address }/${ service }`;
                    if (is.string(method)) url += `/${ method }`;
                    const request = { method: httpMethod, url };
                    options = is.object(options) && is.not.array(options) ? options : {};
                    if (httpMethod === 'get' || httpMethod === 'delete')
                        request.params = options;
                    else request.data = options;
                    axios(request)
                        .then(r => {
                            this._logger.info(request, 'success');
                            resolve(r);
                        })
                        .catch(e => {
                            this._logger.error({ httpMethod, service, method, options }, e.message);
                            reject(e);
                        });
                } else {
                    this._logger.error({ httpMethod, service, method, options }, 'unknown service');
                    reject(new Error('UNKNOWN_SERVICE'));
                }
github vadimdemedes / mongorito / src / query.js View on Github external
exclude (key, value) {
    if (is.array(key)) {
      let fields = key;
      
      fields.forEach(key => {
        this.exclude(key);
      });
    }
    
    if (is.object(key)) {
      let fields = key;
      let keys = Object.keys(fields);
      
      keys.forEach(key => {
        this.exclude(key, fields[key]);
      });
    }
    
    if (is.string(key)) {
      this.options.fields[key] = value == undefined ? 0 : value;
    }
    
    return this;
  }
github be-fe / html-bundler / src / functions / server.js View on Github external
if (usage === 'bird' && is.object(config.birdConfig)) {
        var birdconf = config.birdConfig;
        var server = {};
        var TranspondRules = {};
        server[port] = {
            basePath: path.join(currentPath, birdconf.basePath)
        };
        TranspondRules[port] = {
            targetServer: birdconf.targetServer,
            ajaxOnly: birdconf.ajaxOnly
        };
        bird.start(server, TranspondRules, birdconf.toolsConf);
        logger.info('Bird server runing at port: ' + port + '.');
    }
    else if (usage && is.object(config.serverConfig)) {
        config.serverConfig.port = port;
        connect.server(config.serverConfig);
        logger.info('connect server runing at port: ' + port + '.');
    }
}