# vsize

> Counts the elements in an Array, Map, Object, Set, or other collection.

Latest version **1.0.0** (published 2018-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install vsize
pnpm add vsize
yarn add vsize
bun add vsize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-23 |
| First published | 2018-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 6 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | John Lamansky |
| Maintainers | lamansky |
| Keywords | count, size, length, collection, array, iterable, map, object, set, string, typed array |

## Links

- npm: https://www.npmjs.com/package/vsize
- Repository: https://github.com/lamansky/vsize
- Issues: https://github.com/lamansky/vsize/issues
- npm.io page: https://npm.io/package/vsize

## Dependencies (6)

- [sbo](https://npm.io/package/sbo.md) ^1.1.0
- [is-object](https://npm.io/package/is-object.md) ^1.0.1
- [prop-keys](https://npm.io/package/prop-keys.md) ^2.0.0
- [is-iterable](https://npm.io/package/is-iterable.md) ^1.1.1
- [typed-arrays](https://npm.io/package/typed-arrays.md) ^1.0.0
- [is-instance-of](https://npm.io/package/is-instance-of.md) ^1.0.1

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-05-23

## README

# vsize

Counts the elements in an Array, Map, Object, Set, or other collection.

## Installation

Requires [Node.js](https://nodejs.org/) 6.0.0 or above.

```bash
npm i vsize
```

## API

The module exports a single function.

### Parameters

1. Bindable: `collection` (Array, iterable, Map, Object, Set, string, or Typed Array): The collection whose elements you want to count.
2. Optional: Object argument:
    * `arrays` / `maps` / `sets` (arrays of classes/strings): Arrays of classes and/or string names of classes that should be treated as equivalent to `Array`/`Map`/`Set` (respectively).
    * `ducktype` (boolean): Whether or not to support unrecognized collection types that have a `size` or `length` property. Defaults to `false`.
    * `inObj` (boolean): Whether or not to include inherited properties if `collection` is an Object (i.e. not another recognized type). Defaults to `false`.
    * `reflectObj` (boolean): Whether or not to use reflection to include non-enumerable Object properties. Only takes effect if `collection` is an Object (i.e. not another recognized type). Defaults to `false`.

### Return Value

The number of items in the collection.

## Example

```javascript
const size = require('vsize')

size([]) // 0
size({a: 1, b: 2}) // 2
size('test') // 4
size(new Map([['key', 'value']])) // 1
```

## Related

The “k” family of modules works on keyed/indexed collections.

* [khas](https://github.com/lamansky/khas)
* [kget](https://github.com/lamansky/kget)
* [kedit](https://github.com/lamansky/kedit)
* [kset](https://github.com/lamansky/kset)
* [kinc](https://github.com/lamansky/kinc)
* [kdel](https://github.com/lamansky/kdel)

The “v” family of modules works on any collection of values.

* [vhas](https://github.com/lamansky/vhas)
* [vget](https://github.com/lamansky/vget)
* [vadd](https://github.com/lamansky/vadd)
* [vdel](https://github.com/lamansky/vdel)

---
_Source: https://npm.io/package/vsize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
