Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
A type checking library where each exported function returns either true or false and does not throw. Also added tests.
is2 is a type-checking module for node.js to test values. Is does not throw exceptions. Use is2 to validate types in your node.js code. Every function in is2 returns either true of false.
After finding Enrico Marino's module is, the concise syntax amazed, but there were syntax issues that made using is difficult. This fork of is fixes those issues, but the module is no longer cross-platform. Also, added tests via mocha which can be run using 'npm test'.
To install is2, type:
$ npm install is2
var is = require('is2');
console.log('true is equal to 1===1: '+(is.equal(true, 1===1));
console.log('10 is a positive number: '+(is.positiveNumber(10));
console.log('11 is an odd number: '+(is.oddNumber(11));
Test if 'value' is a type of 'type'. Alias: a
Test if 'value' is defined. Alias: def
Test is 'value' is either null or undefined. Alias: nullOrUndef
Test if 'value' is empty. To be empty means to be an array, object or string with nothing contained.
Test if 'value' is equal to 'other'. Works for objects and arrays and will do deep comparisions, using recursion. Alias: eq
Test if 'key' in host is an object. To be hosted means host[value] is an object.
Test if 'value' is an instance of 'constructor'. Aliases: instOf, instanceof
Test if 'value' is null.
Test if 'value' is undefined. Aliases: undef, udef
Test if 'value' is an arguments object. Alias: args
Test if 'value' is an array. Alias: ary, arry
Test if 'value' is an array containing at least 1 entry. Aliases: nonEmptyArry, nonEmptyAry
Test if 'value' is an empty array(like) object. Aliases: arguents.empty, args.empty, ary.empty, arry.empty
Test if 'value' is an arraylike object (i.e. it has a length property with a valid value) Aliases: arraylike, arryLike, aryLike
Test if 'value' is a boolean. Alias: bool
Test if 'value' is false.
Test if 'value' is true.
Test if 'value' is a date.
Test if 'value' is an error object. Alias: err
Test if 'value' is a function. Alias: func
Test if 'value' is a number. Alias: num
Test if 'value' is a positive number. Alias: positiveNum, posNum
Test if 'value' is a negative number. Aliases: negNum, negativeNum
Test if 'value' is a decimal number. Aliases: decimalNumber, decNum
Test if 'value' is divisible by 'n'. Alias: divisBy
Test if 'value' is an integer. Alias: integer
Test if 'value' is a positive integer. Alias: posInt
Test if 'value' is a negative integer. Aliases: negInt, negativeInteger
Test if 'value' is greater than 'others' values. Alias: max
Test if 'value' is less than 'others' values. Alias: min
Test if 'value' is an even number.
Test if 'value' is an odd number.
Test if 'value' is greater than or equal to 'other'. Aliases: greaterOrEq, greaterOrEqual
Test if 'value' is greater than 'other'. Aliases: greaterThan
Test if 'value' is less than or equal to 'other'. Alias: lessThanOrEq, lessThanOrEqual
Test if 'value' is less than 'other'. Alias: lessThan
Test if 'value' is within 'start' and 'finish'. Alias: withIn
Test if 'value' is an object. Note: Arrays, RegExps, Date, Error, etc all return false. Alias: obj
Test if 'value' is an object with properties. Note: Arrays are objects. Alias: nonEmptyObj
Test if 'value' is an instance type objType. Aliases: objInstOf, objectinstanceof
Test if 'value' is a regular expression. Alias: regexp
Test if 'value' is a string. Alias: str
Test if 'value' is a non-empty string. Alias: nonEmptyStr
FAQs
A type checking library where each exported function returns either true or false and does not throw. Also added tests.
The npm package is2 receives a total of 1,163,196 weekly downloads. As such, is2 popularity was classified as popular.
We found that is2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.