# to-length

> Converts value to an integer suitable for use as the length of an array-like object.

Latest version **1.0.1** (published 2016-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-length
pnpm add to-length
yarn add to-length
bun add to-length
```

## 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.1 |
| Published | 2016-04-15 |
| First published | 2016-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bubkoo |
| Maintainers | bubkoo |
| Keywords | to, parse, convert, converter, parser, type, length, array, length-like, array-like, number, int, integer |

## Links

- npm: https://www.npmjs.com/package/to-length
- Repository: https://github.com/gearcase/to-length
- Homepage: https://github.com/gearcase/to-length#readme
- Issues: https://github.com/gearcase/to-length/issues
- npm.io page: https://npm.io/package/to-length

## Dependencies (1)

- [to-integer](https://npm.io/package/to-integer.md) ^1.0.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-04-15
- 1.0.0 — 2016-04-13
- 0.0.0 — 2016-04-12

## README

# to-length

> Converts value to an integer suitable for use as the length of an array-like object. 


[![MIT License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat-square)](https://github.com/gearcase/to-length/blob/master/LICENSE)

[![build:?](https://img.shields.io/travis/gearcase/to-length/master.svg?style=flat-square)](https://travis-ci.org/gearcase/to-length)
[![coverage:?](https://img.shields.io/coveralls/gearcase/to-length/master.svg?style=flat-square)](https://coveralls.io/github/gearcase/to-length)


## Install

```
$ npm install --save to-length 
```

## Usage

> For more use-cases see the [tests](https://github.com/gearcase/to-length/blob/master/test/spec/index.js)

```js
var toLength = require('to-length');

toLength(3);                // => 3
toLength('3');              // => 3
toLength('abc');            // => 0
toLength(-2);               // => 0
toLength();                 // => 0
toLength(null);             // => 0
toLength(Number.MIN_VALUE); // => 0
toLength(Number.MAX_VALUE); // => 4294967295
toLength(Infinity);         // => 4294967295

// boolean
toLength(true);  // => 1
toLength(false); // => 0
```


## Related

- [is-length](https://github.com/gearcase/is-length) - Checks if the given value is a valid array-like length.
- [is-index](https://github.com/gearcase/is-index) - Checks if the given value is a valid array-like index.
- [drop-left](https://github.com/gearcase/drop-left) - Creates a slice of array with n elements dropped from the beginning.
- [drop-right](https://github.com/gearcase/drop-right) - Creates a slice of array with n elements dropped from the end.
- [pick-item](https://github.com/mock-end/pick-item) - Randomly sampling a item from an array.
- [pick-items](https://github.com/mock-end/pick-items) - Randomly sampling some items from an array. 
- [shuffle-arr](https://github.com/mock-end/shuffle-arr) - Randomize the order of the elements in an array or array-like object. 
- [is-array-like](https://github.com/gearcase/is-array-like) - Checks if the given value is an array or array-like object.



## Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please [create an issue](https://github.com/gearcase/to-length/issues/new).

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