Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basic-utils

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-utils - npm Package Compare versions

Comparing version 1.5.2 to 1.5.4

58

lib/types.js
'use strict';
const internals = {};

@@ -96,36 +95,69 @@

exports.isIp = (input) => {
exports.isIp = (value) => {
if (!exports.isString(input)) {
if (!exports.isString(value)) {
return false;
}
return internals.ipv4.test(input) || internals.ipv6.test(input);
return internals.ipv4.test(value) || internals.ipv6.test(value);
};
exports.isIp6 = (input) => {
exports.isIp6 = (value) => {
if (!exports.isString(input)) {
if (!exports.isString(value)) {
return false;
}
return internals.ipv6.test(input);
return internals.ipv6.test(value);
};
exports.isIp4 = (input) => {
exports.isIp4 = (value) => {
if (!exports.isString(input)) {
if (!exports.isString(value)) {
return false;
}
return internals.ipv4.test(input);
return internals.ipv4.test(value);
};
exports.isMac = (input) => {
exports.isMac = (value) => {
if (!exports.isString(input)) {
if (!exports.isString(value)) {
return false;
}
return internals.MacAddress.test(input);
return internals.MacAddress.test(value);
};
exports.isInt8 = (value) => {
// -128 to 127
return Number.isInteger(value) ? value >= -128 && value <= 127 : false;
};
exports.isUint8 = (value) => {
// 0 to 255
return Number.isInteger(value) ? value >= 0 && value <= 255 : false;
};
exports.isInt16 = (value) => {
// -32,768 to 32,767
return Number.isInteger(value) ? value >= -32768 && value <= 32767 : false;
};
exports.isUint16 = (value) => {
// 0 to 65,535
return Number.isInteger(value) ? value >= 0 && value <= 65535 : false;
};
exports.isInt32 = (value) => {
// -2,147,483,648 to 2,147,483,647
return Number.isInteger(value) ? value >= -2147483648 && value <= 2147483647 : false;
};
exports.isUint32 = (value) => {
// 0 to 4,294,967,295
return Number.isInteger(value) ? value >= 0 && value <= 4294967295 : false;
};
{
"name": "basic-utils",
"version": "1.5.2",
"version": "1.5.4",
"description": "basic js utils",

@@ -10,3 +10,4 @@ "main": "lib/index.js",

"scripts": {
"test": "lab -a code -v -t 100 -L"
"test": "lab -a code -v -t 100 -L",
"coveralls": "lab -r lcov | coveralls"
},

@@ -20,4 +21,5 @@ "repository": {

"devDependencies": {
"code": "^2.3.0",
"lab": "^10.5.1"
"code": "^3.0.1",
"coveralls": "^2.11.11",
"lab": "^10.9.0"
},

@@ -27,4 +29,4 @@ "dependencies": {

"mkdirp": "^0.5.1",
"rimraf": "^2.5.2"
"rimraf": "^2.5.4"
}
}

@@ -1,2 +0,4 @@

# basic-utils [![build status](https://travis-ci.org/simon-p-r/basic-utils.svg?branch=master)](https://travis-ci.org/simon-p-r/basic-utils)
# basic-utils
[![build status](https://travis-ci.org/simon-p-r/basic-utils.svg?branch=master)](https://travis-ci.org/simon-p-r/basic-utils)
[![Coverage Status](https://coveralls.io/repos/github/simon-p-r/basic-utils/badge.svg?branch=master)](https://coveralls.io/github/simon-p-r/basic-utils?branch=master)

@@ -73,2 +75,26 @@ Basic JS utils module

###### isInt8
- Returns boolean
###### isUint8
- Returns boolean
###### isInt16
- Returns boolean
###### isUint16
- Returns boolean
###### isInt32
- Returns boolean
###### isUint32
- Returns boolean
#### Utils

@@ -75,0 +101,0 @@

@@ -50,2 +50,3 @@ 'use strict';

undefined,
{},
[],

@@ -261,2 +262,144 @@ function () {},

'rebecca.blackfriday'
],
int8: [
-128,
-56,
0,
54,
127
],
notInt8: [
'some-example.construction',
null,
undefined,
{},
null,
NaN,
Infinity,
-129,
128
],
uInt8: [
0,
255,
103,
10.00,
34,
11,
67
],
notUint8: [
'some-example.construction',
NaN,
Infinity,
-10,
256,
null,
undefined,
{},
[]
],
int16: [
0,
255,
103,
10.00,
34,
11,
67,
32767,
-32768
],
notInt16: [
'some-example.construction',
NaN,
Infinity,
-32769,
32768,
null,
undefined,
{},
[]
],
uInt16: [
0,
255,
103,
10.00,
34,
11,
67,
32767,
65535
],
notUint16: [
'some-example.construction',
NaN,
Infinity,
-32769,
65536,
null,
undefined,
{},
[]
],
int32: [
0,
255,
103,
10.00,
34,
11,
67,
32767,
-32768,
-2147483648,
2147483647
],
notInt32: [
'some-example.construction',
NaN,
Infinity,
-2147483649,
2147483648,
null,
undefined,
{},
[]
],
uInt32: [
0,
255,
103,
10.00,
34,
11,
67,
32767,
65535,
4294967295
],
notUint32: [
'some-example.construction',
NaN,
Infinity,
-32769,
4294967296,
null,
undefined,
{},
[]
]

@@ -263,0 +406,0 @@

@@ -39,3 +39,2 @@ 'use strict';

expect(Utils.isNan(NaN)).to.be.true();
done();

@@ -251,2 +250,21 @@

it('should test isMac', (done) => {
Types.notMac.forEach((type) => {
expect(Utils.isMac(type)).to.be.false();
});
Types.mac.forEach((type) => {
expect(Utils.isMac(type)).to.be.true();
});
expect(Utils.isMac()).to.be.false();
done();
});
it('should test isFQDN', (done) => {

@@ -270,12 +288,12 @@

it('should test isMac', (done) => {
it('should test isInt8', (done) => {
Types.mac.forEach((m) => {
Types.int8.forEach((m) => {
expect(Utils.isMac(m)).to.be.true();
expect(Utils.isInt8(m)).to.be.true();
});
Types.notMac.forEach((m) => {
Types.notInt8.forEach((m) => {
expect(Utils.isMac(m)).to.be.false();
expect(Utils.isInt8(m)).to.be.false();
});

@@ -287,3 +305,86 @@

it('should test isUint8', (done) => {
Types.uInt8.forEach((m) => {
expect(Utils.isUint8(m)).to.be.true();
});
Types.notUint8.forEach((m) => {
expect(Utils.isUint8(m)).to.be.false();
});
done();
});
it('should test isInt16', (done) => {
Types.int16.forEach((m) => {
expect(Utils.isInt16(m)).to.be.true();
});
Types.notInt16.forEach((m) => {
expect(Utils.isInt16(m)).to.be.false();
});
done();
});
it('should test isUint16', (done) => {
Types.uInt16.forEach((m) => {
expect(Utils.isUint16(m)).to.be.true();
});
Types.notUint16.forEach((m) => {
expect(Utils.isUint16(m)).to.be.false();
});
done();
});
it('should test isInt32', (done) => {
Types.int32.forEach((m) => {
expect(Utils.isInt32(m)).to.be.true();
});
Types.notInt32.forEach((m) => {
expect(Utils.isInt32(m)).to.be.false();
});
done();
});
it('should test isUint32', (done) => {
Types.uInt32.forEach((m) => {
expect(Utils.isUint32(m)).to.be.true();
});
Types.notUint32.forEach((m) => {
expect(Utils.isUint32(m)).to.be.false();
});
done();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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