New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

is2

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is2 - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

lib/.vimrc

14

lib/is2.js

@@ -705,1 +705,15 @@ /**

exports.nonEmptyStr = exports.nonEmptyString;
/**
* Test if value is a valid email address.
* @param {Any} value to test if an email address.
* @return {Boolean} true if an email address, false otherwise.
*/
exports.emailAddress = function(value) {
if (!exports.nonEmptyStr(value))
return false;
return emailRegexp.test(value);
};
exports.email = exports.emailAddr = exports.emailAddress;
var emailRegexp = /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/;

2

package.json
{
"name" : "is2"
, "version" : "0.0.5"
, "version" : "0.0.6"
, "description" : "A type checking library where each exported function returns either true or false and does not throw. Also added tests."

@@ -5,0 +5,0 @@ , "tags" : [ "utilities", "JavaScript", "node.js", "validation", "type", "checking" ]

@@ -22,72 +22,54 @@ is2

### type(value, type)
### type\(value, type\)
Test if 'value' is a type of 'type'.
Alias: a
#### Params:
##### Params:
* **value** *value* to test.
* **String** *type* THe name of the type.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an arguments object, false otherwise.
### defined(value)
### defined\(value\)
Test if 'value' is defined.
Alias: def
#### Params:
##### Params:
* **Any** *value* The value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is defined, false otherwise.
### nullOrUndef(value)
### nullOrUndef\(value\)
Test is 'value' is either null or undefined.
Alias: nullOrUndef
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** True if value is null or undefined, false otherwise.
### empty(value)
### empty\(value\)
Test if 'value' is empty. To be empty means to be an array, object or string with nothing contained.
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is empty, false otherwise.
### objEquals(value, other)
### objEquals\(value, other\)
Do a deep comparision of two objects for equality. Will recurse without any limits. Meant to be
called by equal only.
#### Params:
##### Params:
* **Object** *value* The first object to compare.
* **Object** *other* The second object to compare.
#### Return:
##### Returns:
* **Boolean** true, if the objects are equivalent, false otherwise.
### equal(value, other)
### equal\(value, other\)
Test if 'value' is equal to 'other'. Works for objects and arrays and will do deep comparisions,

@@ -97,589 +79,480 @@ using recursion.

#### Params:
##### Params:
* **Any** *value* value.
* **Any** *other* value to compare with.
#### Return:
##### Returns:
* **Boolean** true if 'value' is equal to 'other', false otherwise
### NON_HOST_TYPES
JS Type definitions which cannot host values.
### hosted(value, host)
### hosted\(value, host\)
Test if 'key' in host is an object. To be hosted means host\[value\] is an object.
Test if 'key' in host is an object. To be hosted means host[value] is an object.
#### Params:
##### Params:
* **Any** *value* The value to test.
* **Any** *host* Host that may contain value.
#### Return:
##### Returns:
* **Boolean** true if 'value' is hosted by 'host', false otherwise.
### instanceOf(value)
### instanceOf\(value\)
Test if 'value' is an instance of 'constructor'.
Aliases: instOf, instanceof
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an instance of 'constructor'.
### buffer(value)
### buffer\(value\)
Test if 'value' is an instance of Buffer.
Aliases: instOf, instanceof
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an instance of 'constructor'.
### null(value)
### null\(value\)
Test if 'value' is null.
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is null, false otherwise.
### undefined(value)
### undefined\(value\)
Test if 'value' is undefined.
Aliases: undef, udef
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is undefined, false otherwise.
### arguments(value)
### arguments\(value\)
Test if 'value' is an arguments object.
Alias: args
#### Params:
##### Params:
* **Any** *value* value to test
#### Return:
##### Returns:
* **Boolean** true if 'value' is an arguments object, false otherwise
### emptyArguments(value)
### emptyArguments\(value\)
Test if 'value' is an arguments object that is empty.
Alias: args
#### Params:
##### Params:
* **Any** *value* value to test
#### Return:
##### Returns:
* **Boolean** true if 'value' is an arguments object with no args, false otherwise
### array(value)
### array\(value\)
Test if 'value' is an array.
Alias: ary, arry
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an array, false otherwise.
### nonEmptyArray(value)
### nonEmptyArray\(value\)
Test if 'value' is an array containing at least 1 entry.
Aliases: nonEmptyArry, nonEmptyAry
#### Params:
##### Params:
* **Any** *value* The value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an array with at least 1 value, false otherwise.
### nonEmptyArray(value)
### nonEmptyArray\(value\)
Test if 'value' is an array containing no entries.
Aliases: emptyArry, emptyAry
#### Params:
##### Params:
* **Any** *value* The value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an array with no elemnets.
### empty(value)
Test if 'value' is an empty array(like) object.
### empty\(value\)
Test if 'value' is an empty array\(like\) object.
Aliases: arguents.empty, args.empty, ary.empty, arry.empty
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an empty array\(like\), false otherwise.
* **Boolean** true if 'value' is an empty array(like), false otherwise.
### arrayLike(value)
Test if 'value' is an arraylike object (i.e. it has a length property with a valid value)
### arrayLike\(value\)
Test if 'value' is an arraylike object \(i.e. it has a length property with a valid value\)
Aliases: arraylike, arryLike, aryLike
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an arguments object, false otherwise.
### boolean(value)
### boolean\(value\)
Test if 'value' is a boolean.
Alias: bool
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a boolean, false otherwise.
### false(value)
### false\(value\)
Test if 'value' is false.
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is false, false otherwise
### true(value)
### true\(value\)
Test if 'value' is true.
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is true, false otherwise.
### date(value)
### date\(value\)
Test if 'value' is a date.
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a date, false otherwise.
### error(value)
### error\(value\)
Test if 'value' is an error object.
Alias: err
#### Params:
##### Params:
* **value** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an error object, false otherwise.
### function(value)
### function\(value\)
Test if 'value' is a function.
Alias: func
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a function, false otherwise.
### number(value)
### number\(value\)
Test if 'value' is a number.
Alias: num
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a number, false otherwise.
### positiveNumber(value)
### positiveNumber\(value\)
Test if 'value' is a positive number.
Alias: positiveNum, posNum
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a number, false otherwise.
### negativeNumber(value)
### negativeNumber\(value\)
Test if 'value' is a negative number.
Aliases: negNum, negativeNum
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a number, false otherwise.
### decimal(value)
### decimal\(value\)
Test if 'value' is a decimal number.
Aliases: decimalNumber, decNum
#### Params:
##### Params:
* **Any** *value* value to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a decimal number, false otherwise.
### divisibleBy(value, n)
### divisibleBy\(value, n\)
Test if 'value' is divisible by 'n'.
Alias: divisBy
#### Params:
##### Params:
* **Number** *value* value to test.
* **Number** *n* dividend.
#### Return:
##### Returns:
* **Boolean** true if 'value' is divisible by 'n', false otherwise.
### int(value)
### int\(value\)
Test if 'value' is an integer.
Alias: integer
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an integer, false otherwise.
### positiveInt(value)
### positiveInt\(value\)
Test if 'value' is a positive integer.
Alias: posInt
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a positive integer, false otherwise.
### negativeInt(value)
### negativeInt\(value\)
Test if 'value' is a negative integer.
Aliases: negInt, negativeInteger
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a negative integer, false otherwise.
### maximum(value, others)
### maximum\(value, others\)
Test if 'value' is greater than 'others' values.
Alias: max
#### Params:
##### Params:
* **Number** *value* value to test.
* **Array** *others* values to compare with.
##### Returns:
#### Return:
* **Boolean** true if 'value' is greater than 'others' values.
### minimum\(value, others\)
### minimum(value, others)
Test if 'value' is less than 'others' values.
Alias: min
##### Params:
#### Params:
* **Number** *value* value to test.
* **Array** *others* values to compare with.
#### Return:
##### Returns:
* **Boolean** true if 'value' is less than 'others' values.
### nan(value)
### nan\(value\)
is.nan
Test if `value` is not a number.
#### Params:
##### Params:
* **Mixed** *value* value to test
#### Return:
##### Returns:
* **Boolean** true if `value` is not a number, false otherwise
### even(value)
### even\(value\)
Test if 'value' is an even number.
#### Params:
##### Params:
* **Number** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an even number, false otherwise.
### odd(value)
### odd\(value\)
Test if 'value' is an odd number.
#### Params:
##### Params:
* **Number** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an odd number, false otherwise.
### ge(value, other)
### ge\(value, other\)
Test if 'value' is greater than or equal to 'other'.
Aliases: greaterOrEq, greaterOrEqual
#### Params:
##### Params:
* **Number** *value* value to test.
* **Number** *other* value to compare with.
#### Return:
##### Returns:
* **Boolean** true, if value is greater than or equal to other, false otherwise.
### gt(value, other)
### gt\(value, other\)
Test if 'value' is greater than 'other'.
Aliases: greaterThan
#### Params:
##### Params:
* **Number** *value* value to test.
* **Number** *other* value to compare with.
#### Return:
##### Returns:
* **Boolean** true, if value is greater than other, false otherwise.
### le(value, other)
### le\(value, other\)
Test if 'value' is less than or equal to 'other'.
Alias: lessThanOrEq, lessThanOrEqual
#### Params:
##### Params:
* **Number** *value* value to test
* **Number** *other* value to compare with
#### Return:
##### Returns:
* **Boolean** true, if 'value' is less than or equal to 'other', false otherwise.
### lt(value, other)
### lt\(value, other\)
Test if 'value' is less than 'other'.
Alias: lessThan
#### Params:
##### Params:
* **Number** *value* value to test
* **Number** *other* value to compare with
#### Return:
##### Returns:
* **Boolean** true, if 'value' is less than 'other', false otherwise.
### within(value, start, finish)
### within\(value, start, finish\)
Test if 'value' is within 'start' and 'finish'.
Alias: withIn
#### Params:
##### Params:
* **Number** *value* value to test.
* **Number** *start* lower bound.
* **Number** *finish* upper bound.
#### Return:
##### Returns:
* **Boolean** true if 'value' is is within 'start' and 'finish', false otherwise.
### object(value)
### object\(value\)
Test if 'value' is an object. Note: Arrays, RegExps, Date, Error, etc all return false.
Alias: obj
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an object, false otherwise.
### nonEmptyObject(value)
### nonEmptyObject\(value\)
Test if 'value' is an object with properties. Note: Arrays are objects.
Alias: nonEmptyObj
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an object, false otherwise.
### objectInstanceof(objInst, objType)
### objectInstanceof\(objInst, objType\)
Test if 'value' is an instance type objType.
Aliases: objInstOf, objectinstanceof, instOf, instanceOf
#### Params:
##### Params:
* **object** *objInst* an object to testfor type.
* **object** *objType* an object type to compare.
#### Return:
##### Returns:
* **Boolean** true if 'value' is an object, false otherwise.
### regexp(value)
### regexp\(value\)
Test if 'value' is a regular expression.
Alias: regexp
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a regexp, false otherwise.
### string(value)
### string\(value\)
Test if 'value' is a string.
Alias: str
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a string, false otherwise.
### emptyString(value)
### emptyString\(value\)
Test if 'value' is an empty string.
Alias: emptyStr
#### Params:
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is am empty string, false otherwise.
### nonEmptyString(value)
### nonEmptyString\(value\)
Test if 'value' is a non-empty string.
Alias: nonEmptyStr
#### Params:
##### Params:
* **Any** *value* to test.
##### Returns:
* **Boolean** true if 'value' is a non-empty string, false otherwise.
### emailAddress\(value\)
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 expact an '@host', so 'edmond' is false but
'edmond@stdarg' is true. Edge cases exists where this returns the wrong result.
##### Params:
* **Any** *value* to test.
#### Return:
##### Returns:
* **Boolean** true if 'value' is a valid email address and false otherwise.
* **Boolean** true if 'value' is a non-empty string, false otherwise.
## License
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.

@@ -259,3 +259,3 @@ 'use strict';

var f = function() { var a = 1; };
var f = function() { var a = 1; a++; };
assert.equal(true, is.function(f));

@@ -703,1 +703,42 @@ });

describe('is.emailAddress', function() {
it('Should return true for valid email address ', function() {
//http://isemail.info/_system/is_email/test/?all
assert.equal(false, is.email('edmond'));
assert.equal(true, is.email('edmond@stdarg'));
assert.equal(true, is.email('edmond@stdarg.com'));
assert.equal(true, is.email('edmond@127.0.0.1'));
assert.equal(false, is.email('@'));
assert.equal(false, is.email('@stdarg'));
assert.equal(false, is.email('@stdarg.com'));
assert.equal(false, is.email('@stdarg.something'));
assert.equal(true, is.email('e@stdarg.something.something'));
assert.equal(false, is.email('.e@stdarg.something'));
assert.equal(true, is.email('e.m@stdarg.com'));
assert.equal(false, is.email('e..m@stdarg.com'));
assert.equal(true, is.email('!#$%&`*+/=?^`{|}~@stdarg.com'));
//assert.equal(false, is.email('hi@edmond@stdarg.com'));
//assert.equal(false, is.email('hi\\@edmond@stdarg.com'));
//assert.equal(false, is.email('123@stdarg.com'));
assert.equal(true, is.email('edmond@123.com'));
assert.equal(true, is.email('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@123.com'));
//assert.equal(false, is.email('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklmn@stdarg.com'));
assert.equal(true, is.email('edmond@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.com'));
//assert.equal(false, is.email('edmond@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm.com'));
assert.equal(true, is.email('edmond@test-stdarg.com'));
//assert.equal(false, is.email('edmond@-stdarg.com'));
assert.equal(true, is.email('edmond@test--stdarg.com'));
assert.equal(false, is.email('edmond@.stdarg.com'));
assert.equal(true, is.email('a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v'));
assert.equal(true, is.email('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi'));
//assert.equal(false, is.email('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij'));
//assert.equal(false, is.email('"edmond"@stdarg.com'));
//assert.equal(false, is.email('""@stdarg.com'));
//assert.equal(false, is.email('"\\e"@stdarg.com'));
});
});
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