MCPcopy
hub / github.com/dunky11/react-saas-template / toArray

Function toArray

src/shared/functions/toArray.js:873–889  ·  view source on GitHub ↗

* 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']

(value)

Source from the content-addressed store, hash-verified

871 * // => []
872 */
873function toArray(value) {
874 if (!value) {
875 return [];
876 }
877 if (isArrayLike(value)) {
878 return isString(value) ? stringToArray(value) : copyArray(value);
879 }
880 if (iteratorSymbol && value[iteratorSymbol]) {
881 return iteratorToArray(value[iteratorSymbol]());
882 }
883 const tag = getTag(value);
884
885 const func =
886 tag === mapTag ? mapToArray : tag === setTag ? setToArray : values;
887
888 return func(value);
889}
890
891/**
892 * Creates an array of the own enumerable property names of `object`.

Callers 1

countWithEmojisFunction · 0.85

Calls 5

isArrayLikeFunction · 0.85
isStringFunction · 0.85
stringToArrayFunction · 0.85
copyArrayFunction · 0.85
iteratorToArrayFunction · 0.85

Tested by

no test coverage detected