How to use the lodash.isArray function in lodash

To help you get started, we’ve selected a few lodash 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 brochington / declarity / src / EntityWrapper_old.js View on Github external
function getRenderContent(entityClassInstance) {
    const content = entityClassInstance.render();
    // console.log('renderContent');
    // console.log(content);
    if (isNil(content)) return [];

    return isArray(content) ? content : [content];
}
github kupi-network / kupi-terminal / server / core_components / checkCcxt.js View on Github external
const checkOrderbook = async function(name) {
  // console.log('+-+-+-+')
  try {
    var data = await global.CHECKSTOCK[name].fetchOrderBook(global.CHECKSYMBOLS[name].symbols[0])
    // console.log(data)
    var isObject = _.isPlainObject(data)
    var isArray = _.isArray(data.bids)
    var isNumber = _.isNumber(data.bids[0][0])
    if (isObject && isArray && isNumber) {
      global.CHECKCCXT[name]['orderbook'] = 'ok'
    } else {
      global.CHECKCCXT[name]['orderbook'] = 'ok, but strange shema'
    }
  } catch(err) {
    global.CHECKCCXT[name]['orderbook'] = serializeError(err).message
  }
}
github rhaldkhein / mithril-data / source / collection.js View on Github external
getAll: function(mixed, falsy) {
    // Note that this will not get all matched.
    // Will only get the first match of each array item.
    if (!_.isArray(mixed))
      mixed = [mixed];
    var models = [];
    var i = 0;
    var exist;
    for (; i < mixed.length; i++) {
      exist = this.get(mixed[i]);
      if (exist || falsy) {
        models.push(exist);
      }
    }
    return models;
  },
  remove: function(mixed, silent) {
github XeroAPI / xero-node / lib / schemaobject / schemaobject.js View on Github external
// Null or undefined should be flexible and allow any value.
    if (properties.type === null || properties.type === undefined) {
        properties.type = 'any';

        // Convert object representation of type to lowercase string.
        // String is converted to 'string', Number to 'number', etc.
    } else if (properties.type.name) {
        properties.type = properties.type.name;
    }
    if (_.isString(properties.type)) {
        properties.type = properties.type.toLowerCase();
    }

    // index: [Type] or index: [] is translated to index: {type: Array, arrayType: Type}
    if (_.isArray(properties.type)) {
        if (_.size(properties.type)) {
            // Properties will be normalized when array is initialized.
            properties.arrayType = properties.type[0];
        }
        properties.type = 'array';
    }

    // index: {} or index: SchemaObject is translated to index: {type: Object, objectType: Type}
    // SchemaObject factory is initialized when raw schema is provided.
    if (!_.isString(properties.type)) {
        if (_.isFunction(properties.type)) {
            properties.objectType = properties.type;
            properties.type = 'object';
        } else if (properties.type === {}) {
            properties.type = 'object';
        } else if (_.isObject(properties.type) && _.size(properties.type)) {
github VisualComposer / builder / public / sources / attributes / attachimage / Getter.js View on Github external
export default (data, key, settings) => {
  let isMultiple = settings.options && settings.options.multiple
  let value = data[ key ]
  let returnValue = value
  if (lodash.isString(value) && isMultiple) {
    returnValue = [ value ]
  } else if (lodash.isArray(value) && !isMultiple) {
    returnValue = value[ 0 ]
  } else if (lodash.isObject(value) && !lodash.isArray(value)) {
    // Note: isObject(['test']) returns true!
    if (!value.ids && !value.urls && value.id) {
      returnValue = value
    } else {
      if (isMultiple) {
        returnValue = value.urls
      } else if (value.urls && value.urls.length) {
        returnValue = value.urls[ 0 ]
      } else {
        returnValue = value
      }
    }
  }
github Chimeejs / chimee / src / dispatcher / index.ts View on Github external
box: string;
    isLive: boolean;
    kernels: UserKernelsConfig;
    preset: {
        flv?: IVideoKernelConstructor;
        hls?: IVideoKernelConstructor;
        mp4?: IVideoKernelConstructor;
    };
    src: string;
}) {
    const { kernels, preset } = config;
    /* istanbul ignore else  */
    if (process.env.NODE_ENV !== 'production' && isEmpty(kernels) && !isEmpty(preset)) { chimeeLog.warn('preset will be deprecated in next major version, please use kernels instead.'); }
    const presetConfig: { [key: string]: SingleKernelConfig } = {};
    let newPreset: UserKernelsConstructorMap = {};
    if (isArray(kernels)) {
      // SKC means SingleKernelConfig
      newPreset = (kernels as (Array< SupportedKernelType | SingleKernelConfig >)).reduce((kernels: UserKernelsConstructorMap, keyOrSKC: SupportedKernelType | SingleKernelConfig) => {
        // if it is a string key, it means the kernel has been pre installed.
        if (isString(keyOrSKC)) {
          if (!isSupportedKernelType(keyOrSKC)) {
            throw new Error(`We have not support ${keyOrSKC} kernel type`);
          }
          const kernelFn = kernelsSet[keyOrSKC];
          if (!isFunction(kernelFn)) {
            chimeeLog.warn(`You have not installed kernel for ${keyOrSKC}.`);
            return kernels;
          }
          kernels[keyOrSKC] = kernelFn;
          return kernels;
        }
        // if it is a SingleKernelConfig, it means user may pass in some config here
github appium / appium-remote-debugger / lib / remote-debugger.js View on Github external
function getValueString (key, value) {
      if (_.isFunction(value)) {
        return '[Function]';
      }
      if (key === 'pageArray' && !_.isArray(value)) {
        return `'Waiting for data'`;
      }
      return JSON.stringify(value);
    }
    log.debug('Current applications available:');
github vpdb / server / src / app / common / api.cache.ts View on Github external
private getIdsFromBody(body: any, path: string): string[] {
		if (!path) {
			return [];
		}
		if (isArray(body)) {
			const ids: string[] = [];
			body.forEach(item => ids.push(...this.getIdsFromBody(item, path)));
			return ids;
		}
		const field = path.substr(0, path.indexOf('.') > 0 ? path.indexOf('.') : path.length);
		const value = body[field];
		if (!value) {
			return [];
		}
		if (isObject(value)) {
			return this.getIdsFromBody(value, path.substr((path.indexOf('.') > 0 ? path.indexOf('.') : path.length) + 1));
		}
		return [ value ];
	}
github shyras / osweb / src / js / osweb / util / matrix.js View on Github external
export function weight (matrix, weightCol) {
  if (!isArray(matrix)) {
    throw new TypeError('matrix should be of type array')
  }
  if (!isString(weightCol)) {
    throw new TypeError('Invalid argument passed to weight. Expects a column name')
  }
  if (!matrix[0].hasOwnProperty(weightCol)) {
    throw new ReferenceError(`Column '${weightCol}' not found in matrix`)
  }
  return matrix.reduce((result, item) => {
    const weight = parseInt(item[weightCol])
    if (!isInteger(weight)) {
      throw new TypeError('Specified weight value is not an integer')
    }
    for (let i = 0; i < weight; i++) {
      result.push(item)
    }
github keen / explorer / lib / js / app / validations / FilterValidations.js View on Github external
validate: function(model) {
      var value = model.property_value.coordinates;
      var valid = _.isArray(value) && value.length === 2;
      if (!valid) return valid;

      for(var i=0; i