X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Funcss%2Fnode_modules%2Fform-data%2Fnode_modules%2Flodash%2Fsize.js;fp=node_modules%2Funcss%2Fnode_modules%2Fform-data%2Fnode_modules%2Flodash%2Fsize.js;h=3561fc1010dce286306be36684cba8cd4ed70056;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/uncss/node_modules/form-data/node_modules/lodash/size.js b/node_modules/uncss/node_modules/form-data/node_modules/lodash/size.js new file mode 100644 index 000000000..3561fc101 --- /dev/null +++ b/node_modules/uncss/node_modules/form-data/node_modules/lodash/size.js @@ -0,0 +1,46 @@ +var baseKeys = require('./_baseKeys'), + getTag = require('./_getTag'), + isArrayLike = require('./isArrayLike'), + isString = require('./isString'), + stringSize = require('./_stringSize'); + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable string keyed properties for objects. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ +function size(collection) { + if (collection == null) { + return 0; + } + if (isArrayLike(collection)) { + return isString(collection) ? stringSize(collection) : collection.length; + } + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + return baseKeys(collection).length; +} + +module.exports = size;