Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-type

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-type

the array type info object.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

array-type npm

Build Status Code Climate Test Coverage downloads license

The array type. See the type-info for type info collections.

Usage

//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

TODO

  • of option to limit the element's type.
    • eg, ArrayType of: 'String'

License

MIT

Keywords

FAQs

Package last updated on 03 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc