# array-type

> the array type info object.

Latest version **0.1.0** (published 2016-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install array-type
pnpm add array-type
yarn add array-type
bun add array-type
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-03-03 |
| First published | 2016-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | riceball |
| Keywords | abstract-type, array, type, class, klass |

## Links

- npm: https://www.npmjs.com/package/array-type
- Repository: https://github.com/snowyu/array-type.js
- Issues: https://github.com/snowyu/array-type.js/issues
- npm.io page: https://npm.io/package/array-type

## Dependencies (3)

- [util-ex](https://npm.io/package/util-ex.md) ^0.3.15
- [inherits-ex](https://npm.io/package/inherits-ex.md) ^1.1.4
- [abstract-type](https://npm.io/package/abstract-type.md) ^0.4.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-03-03

## README

## array-type [![npm][npm-svg]][npm]

[![Build Status][travis-svg]][travis]
[![Code Climate][codeclimate-svg]][codeclimate]
[![Test Coverage][codeclimate-test-svg]][codeclimate-test]
[![downloads][npm-download-svg]][npm]
[![license][npm-license-svg]][npm]

[npm]: https://npmjs.org/package/array-type
[npm-svg]: https://img.shields.io/npm/v/array-type.svg
[npm-download-svg]: https://img.shields.io/npm/dm/array-type.svg
[npm-license-svg]: https://img.shields.io/npm/l/array-type.svg
[travis-svg]: https://img.shields.io/travis/snowyu/array-type.js/master.svg
[travis]: http://travis-ci.org/snowyu/array-type.js
[codeclimate-svg]: https://codeclimate.com/github/snowyu/array-type.js/badges/gpa.svg
[codeclimate]: https://codeclimate.com/github/snowyu/array-type.js
[codeclimate-test-svg]: https://codeclimate.com/github/snowyu/array-type.js/badges/coverage.svg
[codeclimate-test]: https://codeclimate.com/github/snowyu/array-type.js/coverage


The array type. See the [type-info](https://github.com/snowyu/type-info.js) for type info collections.

## Usage

```js
//register the array type to the TypeInfo..
require('array-type')
var TypeInfo = require('abstract-type')
//get the array type info:
var ArrayType = TypeInfo('array')
/*
//Just load array type only:
var ArrayTypeInfo = require('array-type')
var ArrayType = ArrayTypeInfo()
 */
var LimitedArrayType = TypeInfo('array', min:1, max:3)

var arr = ArrayType.create([1,2,3])
//var arr = ArrayType.createValue([1,2,3]) //it's the same.

console.log(arr)
//<type "array": "value":[1,2,3]>
console.log(arr.isValid())
//=true
console.log(arr.toJson()))
//='[1,2,3]'
console.log(arr.toJson({withType:true})))
//='{"value":[1,2,3],"name":"array"}'
console.log(LimitedArrayType.isValid([]))
//=false
console.log(LimitedArrayType.isValid([1]))
//=true
var n = arr.clone();
n.assign('aaa')
//=TypeError: "aaa" is an invalid array
```

## API

* The ArrayType Class
  * options:
    * min: the minimum length of the array. null or undefined means unlimited.
    * max: the maximum length of the array.

See [abstract-type](https://github.com/snowyu/abstract-type.js)

## TODO

+ `of` option to limit the element's type.
  * eg, `ArrayType of: 'String'`

## License

MIT

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