How to use the underscore.isArray function in underscore

To help you get started, we’ve selected a few underscore 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 baidu / NoahV / components / common / src / components / nv-datepicker / sidebar.vue View on Github external
}
                        else {
                            this.$set(this.items[i], 'selected', false);
                        }
                    }
                }
            }
            // 配置用户自定义的value
            if (item.value && typeof item.value === 'function') {
                let value = item.value();
                if (u.isDate(value)) {
                    if (['date', 'datetime'].indexOf(this.type) > -1) {
                        this.$emit('set-date-handler', value, '');
                    }
                }
                if (u.isArray(value) && value.length === 2 && u.isDate(value[0]) && u.isDate(value[1])) {
                    if (['daterange', 'daterangetime'].indexOf(this.type) > -1) {
                        this.$emit('set-date-handler', value[0], value[1]);
                    }
                }
            }
            // 调用用户自定义的点击事件函数
            if (item.onClick && typeof item.onClick === 'function') {
                item.onClick(item);
            }
            // 如果配置了快捷面板点击自动关闭
            if (this.autoClose && !this.confirm) {
                this.$emit('auto-close-picker');
            }
            // 暴露对外点击接口
            this.$emit('on-shortcut-click', item);
            this.$emit('on-date-change');
github ignitejs / ignite / lib / StateMachine.js View on Github external
return this._change("@error", evtargs) ;
      }
    }
    
    // Event not found, try higher level of event (e.g. readFile.done becomes readFile)
    splitevt = evtname.split('.') ;
    splitevt.pop() ;
    if (splitevt.length) {
      evtname = splitevt.join('.') ;
      evtlevel += 1 ;
      evtRightMatch = _calcRightMatch(evtRightMatch, evtname) ;
    } else {
      if (this.parent) {
        // Bubble event up to parent
        
        if (_.isArray(inevent)) {
          inevent[0] = fullevtname ;
        } else {
          inevent = fullevtname ;
        }
        
        this.parent._inject(this, inevent, argshift) ;
      } else {
        if (this.debugEmitter) {
          this.debugEmitter.emit('warn', this, this.stateName, evtname, "Unexpected event '"+fullevtname+"'.") ;
        }
        if (this.jsmFactory.options.strict) {
          evtargs.unshift(new Error("Event ["+evtname+"] received in ["+this.stateName+"].")) ;
          return this._change("@error") ;
        }
        
        // Otherwise ignore
github ether / etherpad-lite / src / node / utils / ExportHtml.js View on Github external
function getSpanClassFor(i){
      //return if author colors are disabled
      if (!authorColors) return false;

      var property = props[i];

      // we are not insterested on properties in the form of ['color', 'red'],
      // see hook exportHtmlAdditionalTagsWithData
      if (_.isArray(property)) {
        return false;
      }

      if(property.substr(0,6) === "author"){
        return stripDotFromAuthorID(property);
      }

      if(property === "removed"){
        return "removed";
      }

      return false;
    }
github Philmod / node-kmeans / lib / kmeans.js View on Github external
defineCentroid(self) {
    this.centroidOld = (this.centroid) ? this.centroid : [];
    if (this.centroid && this.cluster.length > 0) {
      this.calculateCentroid();
    } else { // random selection
      const i = Math.floor(Math.random() * self.indexes.length);
      this.centroidIndex = self.indexes[i];
      self.indexes.splice(i, 1);
      this.centroid = [];
      if (!_.isArray(self.v[this.centroidIndex])) { // only one dimension
        this.centroid[0] = self.v[this.centroidIndex];
      } else {
        for (let j = 0, max = self.v[this.centroidIndex].length; j < max; ++j) {
          this.centroid[j] = self.v[this.centroidIndex][j];
        }
      }
    }
    // Centroid has moved if old value != new value
    this.centroidMoved = !_.isEqual(this.centroid, this.centroidOld);
    return this;
  }
github mna / implement.js / lib / utils.js View on Github external
typeInfo[key] = {};
		if (keyType !== 'string' || _.indexOf(nativeTypes, expectedObj[key], true) < 0) {
			// Type is not a string or if it is, it is not a "typeof" string, convert
			typeInfo[key].typeofString = keyType;
			typeInfo[key].specificType = 'object';
			if (keyType === 'object') {
				if (_.isDate(expectedObj[key])) {
					typeInfo[key].isDate = true;
					typeInfo[key].specificType = 'Date';
				} else if (_.isRegExp(expectedObj[key])) {
					typeInfo[key].isRegExp = true;
					typeInfo[key].specificType = 'RegExp';
				} else if (_.isNull(expectedObj[key])) {
					typeInfo[key].isNull = true;
					typeInfo[key].specificType = 'null';
				} else if (_.isArray(expectedObj[key])) {
					typeInfo[key].isArray = true;
					typeInfo[key].specificType = 'Array';
				} else if (!_.isEmpty(expectedObj[key])) {
					typeInfo[key].isDeep = true;
				}
			}
		} else {
			typeInfo[key].typeofString = expectedObj[key];
			typeInfo[key].specificType = typeInfo[key].typeofString;
		}
	}

	return typeInfo;
};
github iazrael / ispriter / lib / Config.js View on Github external
exports.parse = function(config){

    if(us.isString(config)){

        if(!fs.existsSync(config)){

            throw 'place give in a sprite config or config file!';
        }
        var content = fs.readFileSync(config).toString();
        config = zTool.jsonParse(content);

    }else if(us.isArray(config)){

        config = {
            input: config
        };
    }
    config = config || {};

    // 适配最简配置
    if(us.isString(config.input) || us.isArray(config.input)){

        config.input = {
            cssSource: config.input
        };
    }
    if(!config.output){
github tdegrunt / mongodb-fixtures / mongodb-fixtures.js View on Github external
_.each(_.keys(obj), function(propertyName) {

    // If the key of a record is a singular of a fixture, do our magic.
    // TODO: It would probably be faster to singularize the collections and look up, but that doesn't always produce correct results.
    if (lingo.en.isPlural(propertyName)) {
      propertyPlural = fixtures[propertyName.toLowerCase()];
    } else {
      propertyPlural = fixtures[lingo.en.pluralize(propertyName).toLowerCase()];
    }
    if (propertyPlural) {
      
      if (_.isString(obj[propertyName])) {
        obj[propertyName] = get(propertyPlural, obj[propertyName]);
      } else if (_.isArray(obj[propertyName])) {
        
        obj[propertyName] = _.map(obj[propertyName], function(item){
          return get(propertyPlural, item);
        });
        
      } else {
        // FIXME: Throw error if 'as' is not there as we expect a path and 'as' in the object 
        guide = obj[propertyName];  
        if (guide.paths) {
          obj[guide.as] = _.map(guide.paths, function(item){
            return get(propertyPlural, item);
          });
        } else {
          // Assume guide.path
          obj[guide.as] = get(propertyPlural, guide.path);
        }
github kmalakoff / knockback / src / core / functions / unwrap-models.js View on Github external
export default (obj) => {
  if (!obj) return obj;
  if (obj.__kb) return (Object.prototype.hasOwnProperty.call(obj.__kb, 'object') ? obj.__kb.object : obj);
  if (_.isArray(obj)) return _.map(obj, test => unwrapModels(test));
  if (_.isObject(obj) && (obj.constructor === {}.constructor)) { // a simple object
    const result = {};
    _.each(obj, (value, key) => { result[key] = unwrapModels(value); });
    return result;
  }

  return obj;
};
github spencermountain / Freebase.js / freebase.js View on Github external
out=out.map(function(o){
          var property=o.property ||'';
          if(_.isArray(o.property)){
            property=o.property.join('');
          }
          o.sentence=topic.name +"'s " +_.last(property.split('/')).replace('_',' ') +" is "+ o.name; //ugly fallback
          var grammar=data.sentence_grammars.filter(function(v){return v.id==property})[0]||{}
          if(grammar["sen"] && topic.name && o.name){
            o.sentence=grammar["sen"].replace(/\bsubj\b/, topic.name).replace(/\bobj\b/, o.name);
          }
          return o
        })
        return ps.callback(out)
github jsreport / jsreport / extensionsManager.js View on Github external
ExtensionsManager.prototype.use = function(extension) {
    if (extension == "") {
        return Q("");
    }

    var self = this;
    if (!_.isArray(extension))
        extension = [extension];

    extension.forEach(function(e) { self._useInternal(e); });
    return this._refresh();
};