Sha256: fc48c33556d90668af1c08d97160af98b72496835722ed1cd59e92b65043908d

Contents?: true

Size: 1.37 KB

Versions: 276

Compression:

Stored size: 1.37 KB

Contents

var Symbol = require('./_Symbol'),
    copyArray = require('./_copyArray'),
    getTag = require('./_getTag'),
    isArrayLike = require('./isArrayLike'),
    isString = require('./isString'),
    iteratorToArray = require('./_iteratorToArray'),
    mapToArray = require('./_mapToArray'),
    setToArray = require('./_setToArray'),
    stringToArray = require('./_stringToArray'),
    values = require('./values');

/** `Object#toString` result references. */
var mapTag = '[object Map]',
    setTag = '[object Set]';

/** Built-in value references. */
var symIterator = Symbol ? Symbol.iterator : undefined;

/**
 * Converts `value` to an array.
 *
 * @static
 * @since 0.1.0
 * @memberOf _
 * @category Lang
 * @param {*} value The value to convert.
 * @returns {Array} Returns the converted array.
 * @example
 *
 * _.toArray({ 'a': 1, 'b': 2 });
 * // => [1, 2]
 *
 * _.toArray('abc');
 * // => ['a', 'b', 'c']
 *
 * _.toArray(1);
 * // => []
 *
 * _.toArray(null);
 * // => []
 */
function toArray(value) {
  if (!value) {
    return [];
  }
  if (isArrayLike(value)) {
    return isString(value) ? stringToArray(value) : copyArray(value);
  }
  if (symIterator && value[symIterator]) {
    return iteratorToArray(value[symIterator]());
  }
  var tag = getTag(value),
      func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);

  return func(value);
}

module.exports = toArray;

Version data entries

276 entries across 274 versions & 30 rubygems

Version Path
rapid_stack-0.2.0 templates/frontend/node_modules/lodash/toArray.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/lodash/toArray.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/lodash/toArray.js
immosquare-cleaner-0.1.60 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.59 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.58 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.57 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.56 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.55 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.54 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.53 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.52 node_modules/lodash/toArray.js
trusty-cms-6.3.1 node_modules/lodash/toArray.js
immosquare-cleaner-0.1.51 node_modules/lodash/toArray.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/toArray.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/toArray.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/toArray.js
immosquare-cleaner-0.1.50 node_modules/lodash/toArray.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/toArray.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/toArray.js