Version 1
[yaffs-website] / node_modules / uncss / node_modules / lodash / toArray.js
diff --git a/node_modules/uncss/node_modules/lodash/toArray.js b/node_modules/uncss/node_modules/lodash/toArray.js
new file mode 100644 (file)
index 0000000..582a0f6
--- /dev/null
@@ -0,0 +1,57 @@
+var Symbol = require('./internal/Symbol'),
+    copyArray = require('./internal/copyArray'),
+    getTag = require('./internal/getTag'),
+    isArrayLike = require('./isArrayLike'),
+    isString = require('./isString'),
+    iteratorToArray = require('./internal/iteratorToArray'),
+    mapToArray = require('./internal/mapToArray'),
+    setToArray = require('./internal/setToArray'),
+    stringToArray = require('./internal/stringToArray'),
+    values = require('./values');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+    setTag = '[object Set]';
+
+/** Built-in value references. */
+var iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined;
+
+/**
+ * Converts `value` to an array.
+ *
+ * @static
+ * @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 (iteratorSymbol && value[iteratorSymbol]) {
+    return iteratorToArray(value[iteratorSymbol]());
+  }
+  var tag = getTag(value),
+      func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
+
+  return func(value);
+}
+
+module.exports = toArray;