UNPKG

conductor

Version:

A modern & functional JavaScript utility library

16 lines (14 loc) 291 B
const type = require('./type') const length = collection => { switch(type(collection)){ case 'set': case 'map': return collection.size case 'object': return Object.keys(collection).length case 'array': default: return collection.length } } module.exports = length