get-array-types

0.1.3 • Public • Published

Array Types

Get a beautiful string representation of types inside of an Array.

Inspiration

To be completely fair, none. I needed a tiny, zero dependency package for a project that would do this, so I decided to create one.

Installation

Simply run

npm install --save get-array-types

Usage

const ArrayTypes = require('get-array-types')

console.log(ArrayTypes([1, 2, 3, 'Hello', 'World']).toString())
//=> Array<number|string>

console.log(ArrayTypes([1, 'Hello', 2, 'World']).elementTypes())
//=> ['number', 'string']

console.log(ArrayTypes([1, 2, 3]).isOfSingleType())
//=> true

console.log(ArrayTypes([1, 2, 'Oops.']).isOfSingleType())
//=> false

get-array-types also provides a useful utility function, isArray.

Use it as follows:

const isArray = require('get-array-types').isArray

console.log(isArray('Hello World.'))
//=> false

console.log(isArray([1, 2, 3]))
//=> true

License

  • MIT

Happy Javascripting! 〰️

Readme

Keywords

Package Sidebar

Install

npm i get-array-types

Weekly Downloads

3

Version

0.1.3

License

MIT

Unpacked Size

10.2 kB

Total Files

7

Last publish

Collaborators

  • molnarmark