Comparing version 1.15.0 to 1.15.1
21
index.js
@@ -12,9 +12,12 @@ var ERRORS = require('./errors') | ||
var TYPES = { | ||
arrayOf: function arrayOf (type, arrayType) { | ||
arrayOf: function arrayOf (type, options) { | ||
type = compile(type) | ||
arrayType = compile(arrayType || NATIVE.Array) | ||
options = options || {} | ||
function _arrayOf (array, strict) { | ||
if (!arrayType(array)) return false | ||
if (!NATIVE.Array(array)) return false | ||
if (NATIVE.Nil(array)) return false | ||
if (options.minLength !== undefined && array.length < options.minLength) return false | ||
if (options.maxLength !== undefined && array.length > options.maxLength) return false | ||
if (options.length !== undefined && array.length !== options.length) return false | ||
@@ -29,3 +32,13 @@ return array.every(function (value, i) { | ||
} | ||
_arrayOf.toJSON = function () { return '[' + tfJSON(type) + ']' } | ||
_arrayOf.toJSON = function () { | ||
var str = '[' + tfJSON(type) + ']' | ||
if (options.length !== undefined) { | ||
str += '{' + options.length + '}' | ||
} else if (options.minLength !== undefined || options.maxLength !== undefined) { | ||
str += '{' + | ||
(options.minLength === undefined ? 0 : options.minLength) + ',' + | ||
(options.maxLength === undefined ? Infinity : options.maxLength) + '}' | ||
} | ||
return str | ||
} | ||
@@ -32,0 +45,0 @@ return _arrayOf |
{ | ||
"name": "typeforce", | ||
"version": "1.15.0", | ||
"version": "1.15.1", | ||
"description": "Another biased type checking solution for Javascript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
17385
380
0