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

is2

Package Overview
Dependencies
Maintainers
2
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 1.0.2 to 1.0.3

index.js.orig

82

index.js

@@ -336,3 +336,3 @@ /**

};
is.instOf = is.instanceOf = is.objInstOf = is.objectInstanceOf
is.instOf = is.instanceOf = is.objInstOf = is.objectInstanceOf;

@@ -1160,1 +1160,81 @@ /**

is.visaElectron = is.visaElectronCard = is.visaElectronCardNumber;
/**
* Test if the input is a valid MongoDB id.
* @param {String|Object} Either a mongodb object id or a string representation.
* @return true if the string is the correct format, false otherwise
*/
var objectid = require('objectid');
is.mongoId = is.objectId = is.objId = function(id) {
try {
return objectid.isValid(id);
} catch(err) {
return false;
}
};
/**
* Test is the first argument is structly equal to any of the subsequent args.
* @param Value to test against subsequent arguments.
* @return true if the first value matches any of subsequent values.
*/
is.matching = is.match = is.inArgs = function(val) {
if (arguments.length < 2)
return false;
var result = false;
for (var i=1; i<arguments.length; i++) {
var eq = is.equal(val, arguments[i]);
result = result || eq;
}
return result;
};
// US Address components
/**********************************
***Definitely a work in progress***
**********************************/
/**
* Test if a string contains a US street address
* @param {String} the string to search
* @return true if an address is present, false otherwise
*/
is.streetAddress = function(str) {
if (!is.str(str))
return false;
var regex = /\b\d+[\s](?:[A-Za-z0-9.-]+[\s]+)+\b(ALLEY|ALY|AVENUE|AVE|BEND|BND|BLUFFS?|BLFS?|BOULEVARD|BLVD|BRANCH|BR|CENTERS?|CTRS?|CIRCLES?|CIRS?|CLIFFS?|CLFS?|COURTS?|CTS?|COVES?|CVS?|CREEK|CRK|CRESCENT|CRES|CREST|CRST|CROSSING|XING|DRIVES?|DRS?|EXPRESSWAY|EXPY|FREEWAY|FWY|HEIGHTS|HTS|HIGHWAY|HWY|HILLS?|HLS?|LANE|LN|LOOP|MANORS?|MNRS?|MOTORWAY|MTWY|MOUNT|MT|PARKS?|PARKWAYS?|PKWY|PASS|PLACE|PL|PLAZA|PLZ|POINTS?|PTS?|RIDGES?|RDGS?|ROADS?|RDS?|ROUTE|RTE?|SHOALS?|SHLS?|SHORES?|SHRS?|SPRINGS?|SPGS?|SPURS?|STREETS?|STS?|SUMMIT|SMT|TERRACE|TER|THROUGHWAY|TRWY|TRAFFICWAY|TRFY|TRAIL|TRL|TURNPIKE|TPKE|VALLEYS?|VLYS?|WAYS?)+(?:[\.\-\s\,]?)*((APARTMENT|APT|APPT|#|NUMBER|NUM|FLOOR|FL|\s)?(\d)*)\b/ig;
return regex.test(str);
};
is.street = is.address = is.streetAddress;
/**
* Test if a string resembles a US Zip code,
* no regular expression will be perfect for this,
* as there are many numbers that aren't valid zip codes
* @param {String || Number} the string or number literal to test
* @return true if zipcode like, false otherwise
*/
is.zipCode = function(str) {
if (is.undefined(str) || !(is.string(str) || is.number(str)))
return false;
var zip = /^\d{5}(?:-\d{4})?$/;
return zip.test(str);
};
is.zip = is.zipCode;
/**
* Test if a string contains a US phone number
* @param {String} the string to search
* @return true if str contains a phone number, false otherwise.
*/
is.phoneNumber = function(str){
if (!is.string(str))
return false;
var nums = /(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\(?)(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]‌​)\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\)?)\s*(?:[.-]\s*)?)?([2-9]1[02-‌​9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})/g;
return nums.test(str);
};
is.phone = is.phoneNumber;

8

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

@@ -48,8 +48,10 @@ "license": "MIT",

"dependencies": {
"deep-is": "0.1.3"
"deep-is": "0.1.3",
"objectid": "^3.2.1"
},
"devDependencies": {
"jsdom": "0.5.0",
"mocha": "1.8.1",
"jsdom": "0.5.0"
"mongodb": "^2.1.16"
}
}

@@ -7,8 +7,2 @@ is2

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 Also, added tests via mocha which can be run using 'npm test'.
The module is once-again cross-platform.
## Installation

@@ -50,2 +44,3 @@ To install is2, type:

* is.function(val) - is.funct, is.fun
* is.mongoId - is.objectId, is.objId
* is.null(val)

@@ -65,2 +60,4 @@ * is.nullOrUndefined(val) - is.nullOrUndef

* is.instanceOf(val, constructor) - is.instOf, is.instanceof
* is.matching(val1, val2 [, val3, ...]) - is.match : true if the first arument
is strictly equal to any of the subsequent args.
* is.objectInstanceof(obj, objType) - is.instOf, is.instanceOf, is.objInstOf, is.objectInstanceOf

@@ -88,3 +85,3 @@ * is.type(val, type) - is.a

Numeric Type & State:
Numeric Type and State:

@@ -139,3 +136,9 @@ * is.positiveNumber(val) - is.pos, is.positive, is.posNum, is.positiveNum

Personal information:
* is.streetAddress(str) - is.street, is.address
* is.zipCode(str) - is.zip
* is.phoneNumber(str) - is.phone
## License

@@ -142,0 +145,0 @@ The MIT License (MIT)

Sorry, the diff of this file is too big to display

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