Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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 and every function only returns true or false. 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.
Do a deep comparision of two objects for equality. Will recurse without any limits. Meant to be called by equal only.
Test if 'value' is equal to 'other'. Works for objects and arrays and will do deep comparisions, using recursion. Alias: eq
JS Type definitions which cannot host values.
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 an instance of Buffer. 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 arguments object that is empty. 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 array containing no entries. Aliases: emptyArry, emptyAry
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
Number value value to test.
Array others values to compare with.
Test if 'value' is less than 'others' values. Alias: min
is.nan
Test if value
is not a number.
value
is not a number, false otherwiseTest 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, instOf, instanceOf
Test if 'value' is a regular expression. Alias: regexp
Test if 'value' is a string. Alias: str
Test if 'value' is an empty string. Alias: emptyStr
Test if 'value' is a non-empty string. Alias: nonEmptyStr
Test if value is a valid email address. We're testing only the email address not the user name with an email address, edmond@stdarg.com and not "Edmond Meinfelder" edmond@stdarg.com. The email address does not need a fully qualified host, but does expect an '@host', so 'edmond' is false but 'edmond@stdarg' is true. Aliases: email, emailAddr
Test if a value is a valid IPv4 numeric address. Non-routable IPv4 address are still valid addresses. This function expects 4 octets separated by '.' with valid values of 0-255 inclusive. Aliases: ipv4, ipv4Addr
Test if a value is a valid IPv6 numeric address. Aliases: ipv6, ipv6Addr
Test if a value is a valid IPv6 or IPv4 numeric address. Aliases: ip, ipAddr
Test if a value is a valid DNS address. Aliases: dns, dnsAddr
Test if a value is a valid IPv4, ipv6 or DNS address. Aliases: hostIp, hostAddr
The MIT License (MIT)
Copyright (c) 2013 Edmond Meinfelder
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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,015,709 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.