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

@lvchengbin/is

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lvchengbin/is - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

dist/arguments.d.ts

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => x is any[];
declare const _default: (x: unknown) => x is any[];
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any, lower: any, upper: any, mode?: number) => boolean;
declare const _default: (x: unknown, lower: any, upper: any, mode?: number) => boolean;
export default _default;

@@ -24,17 +24,18 @@ "use strict";

}
const n = x;
if (upper < lower)
return false;
// closed interval [lower, upper]
// inclusive both lower and upper
if (mode === 0)
return x >= lower && x <= upper;
// open interval (lower, upper)
return n >= lower && n <= upper;
// exclusive both lower and upper
if (mode === 1)
return x > lower && x < upper;
// half-closed interval [lower, upper)
return n > lower && n < upper;
// inclusive lower and exclusive upper
if (mode === 2)
return x >= lower && x < upper;
// half-closed interval (lower, upper]
return n >= lower && n < upper;
// exclusive lower and inclusive upper
if (mode === 3)
return x > lower && x <= upper;
return n > lower && n <= upper;
return false;
};

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is Blob;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => x is boolean;
declare const _default: (x: unknown) => x is boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -16,2 +16,4 @@ "use strict";

exports.default = (x) => {
if (!x)
return false;
const fn = x.toString();

@@ -18,0 +20,0 @@ return function_1.default(x) && (/^\s*class\s+/.test(fn)

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is DataView;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is Date;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -15,2 +15,2 @@ "use strict";

const node_1 = __importDefault(require("./node"));
exports.default = (x) => !!((x === null || x === void 0 ? void 0 : x.nodeType) === 1 && node_1.default(x));
exports.default = (x) => { var _a; return !!(((_a = x) === null || _a === void 0 ? void 0 : _a.nodeType) === 1 && node_1.default(x)); };

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -10,3 +10,11 @@ "use strict";

******************************************************************/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (x) => /^(([^#$%&*!+-/=?^`{|}~<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i.test(x);
const string_1 = __importDefault(require("./string"));
exports.default = (x) => {
if (!string_1.default(x))
return false;
return /^(([^#$%&*!+-/=?^`{|}~<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i.test(x);
};

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is Error;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is FormData;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -15,2 +15,2 @@ "use strict";

const node_1 = __importDefault(require("./node"));
exports.default = (x) => node_1.default(x) && (x).nodeType === 11;
exports.default = (x) => node_1.default(x) && x.nodeType === 11;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => x is (...args: any[]) => any;
declare const _default: (x: unknown) => x is (...args: any[]) => any;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any, haystack?: any[]) => boolean;
declare const _default: (x: unknown, haystack?: any[]) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any, haystack?: string[]) => boolean;
declare const _default: (x: unknown, haystack?: string[]) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -53,4 +53,4 @@ /******************************************************************

declare const is: {
[key: string]: (x: any, ...args: any[]) => boolean;
[key: string]: (x: unknown, ...args: any[]) => boolean;
};
export default is;

@@ -148,1 +148,4 @@ "use strict";

exports.default = is;
/* global module:true */
module.exports = is;
module.exports.default = is;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
/**

@@ -12,0 +12,0 @@ * BNF of IPv4 address

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
/**

@@ -12,0 +12,0 @@ * BNF of IPv6:

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -10,3 +10,13 @@ "use strict";

******************************************************************/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (x) => !!(!(x % 400) || (!(x % 4) && (x % 100)));
const number_1 = __importDefault(require("./number"));
const string_1 = __importDefault(require("./string"));
exports.default = (x) => {
if (!number_1.default(x))
return false;
const n = string_1.default(x) ? parseInt(x) : x;
return !!(!(n % 400) || (!(n % 4) && (n % 100)));
};

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is Map<any, any>;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any, strict?: boolean) => x is number;
declare const _default: (x: unknown, strict?: boolean) => x is number;
export default _default;

@@ -10,3 +10,7 @@ "use strict";

******************************************************************/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const string_1 = __importDefault(require("./string"));
exports.default = (x, strict = false) => {

@@ -17,3 +21,6 @@ if (({}).toString.call(x) === '[object Number]')

return false;
return !isNaN(parseFloat(x)) && isFinite(x) && !/\.$/.test(x);
if (!string_1.default(x))
return false;
const n = parseFloat(x);
return !isNaN(n) && !isNaN(Number(x)) && isFinite(n) && !/\.$/.test(x);
};

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -15,4 +15,7 @@ "use strict";

const ipv4_1 = __importDefault(require("./ipv4"));
const string_1 = __importDefault(require("./string"));
exports.default = (x) => {
if (!string_1.default(x))
return false;
return ipv4_1.default(x) && /^10\..*/.test(x) || /^192\.168\..*/.test(x) || /^172\.(1[6-9]|2[0-9]|3[0-1])\..*/.test(x);
};

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => x is Promise<any>;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => x is string;
declare const _default: (x: unknown) => x is string;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,2 +9,2 @@ /******************************************************************

******************************************************************/
export default function (x: any): boolean;
export default function (x: unknown): boolean;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;

@@ -9,3 +9,3 @@ /******************************************************************

******************************************************************/
declare const _default: (x: any) => boolean;
declare const _default: (x: unknown) => boolean;
export default _default;
{
"name": "@lvchengbin/is",
"version": "1.0.1",
"version": "1.0.2",
"description": "Do checking...",

@@ -25,12 +25,12 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.11.1",
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/preset-typescript": "^7.10.4",
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"eslint": "^7.6.0",
"@types/node": "^14.6.2",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"eslint": "^7.7.0",
"husky": "^4.2.5",
"jest": "^26.3.0",
"typescript": "^3.9.7"
"jest": "^26.4.2",
"typescript": "^4.0.2"
},

@@ -52,6 +52,11 @@ "scripts": {

},
"engines": {
"node": ">=10.0.0"
},
"main": "dist/index.js",
"files" : [ "dist" ],
"files": [
"dist"
],
"author": "LvChengbin <lvchengbin59@gmail.com>",
"license": "MIT"
}
# Is
Checking...
A JavaScript library for checking the type of a value for browsers.
<!-- vim-markdown-toc GFM -->
* [Installing](#installing)
* [Usage](#usage)
* [Using in browsers](#using-in-browsers)
* [Method List](#method-list)
* [is.date](#isdate)
* [is.empty](#isempty)
* [is.false](#isfalse)
* [is.true](#istrue)
<!-- vim-markdown-toc -->
## Installing

@@ -11,49 +24,125 @@

## Methods
## Usage
| Method | Desc |
| :----- | :--- |
| is.arguments | |
| is.array | |
| is.arrayBuffer | |
| is.arrayBufferView | |
| is.arrowFunction ||
| is.asyncFunction ||
| is.between ||
| is.blob ||
| is.boolean ||
| is.class ||
| is.darkMode ||
| is.dataview ||
| is.date ||
| is.elementNode ||
| is.email ||
| is.empty ||
| is.error ||
| is.formdata ||
| is.fragmentNode ||
| is.function ||
| is.generalizedFalse ||
| is.generalizedTrue ||
| is.generator ||
| is.integer ||
| is.ip ||
| is.ipv4 ||
| is.ipv6 ||
| is.iterable ||
| is.leapYear ||
| is.map ||
| is.node ||
| is.number ||
| is.object ||
| is.oneDimensionalArray ||
| is.plainObject ||
| is.privateIPv4 ||
| is.promise ||
| is.regexp ||
| is.set ||
| is.string ||
| is.textNode ||
| is.undefined ||
| is.url ||
| is.window ||
Generally, when we are using some toolkit such as rollup, we don't want to compile a huge library into our project, therefore, to import the files you really need.
```js
import isFunction from '@lvchengbin/is/src/function';
import array from '@lvchengbin/is/src/array';
isFunction( async () => {} );
isArray( [] );
```
If you want to invoke the whole package:
```js
import is from '@lvchengbin/is';
is.function( () => {} );
is.array( [] );
```
## Using in browsers
If you want to invoke this package to browsers with `<script>` tag or something like that, use [is.js](https://raw.githubusercontent.com/LvChengbin/is/master/dist/is.js). For old browsers which are not supporting ES5 syntax, use [is.bc.js](https://raw.githubusercontent.com/LvChengbin/is/master/dist/is.bc.js).
## Method List
| Method | Importing |
|:--|:--|
| is.arguments | import isArguments from '@lvchengbin/is/src/arguments' |
| is.array | import isArray from '@lvchengbin/is/src/array' |
| is.arrowFunction | import isArrowFunction from '@lvchengbin/is/src/arrow-function' |
| is.asyncFunction | import isAsyncFunction from '@lvchengbin/is/src/async-function' |
| is.between | import isBetween from '@lvchengbin/is/src/between' |
| is.boolean | import isBoolean from '@lvchengbin/is/src/boolean' |
| is.class | import isClass from '@lvchengbin/is/src/class' |
| is.date | import isDate from '@lvchengbin/is/src/date' |
| is.elementNode | import isElementNode from '@lvchengbin/is/src/element-node' |
| is.email | import isEmail from '@lvchengbin/is/src/email' |
| is.empty | import isEmpty from '@lvchengbin/is/src/empty' |
| is.error | import isError from '@lvchengbin/is/src/error' |
| is.false | import isFalse from '@lvchengbin/is/src/false' |
| is.fragmentNode | import isFragmentNode from '@lvchengbin/is/src/fragment-node' |
| is.function | import isFunction from '@lvchengbin/is/src/function' |
| is.generator | import isGenerator from '@lvchengbin/is/src/generator' |
| is.integer | import isInteger from '@lvchengbin/is/src/integer' |
| is.ip | import isIP from '@lvchengbin/is/src/ip' |
| is.ipv4 | import isIPv4 from '@lvchengbin/is/src/ipv4' |
| is.ipv6 | import isIPv6 from '@lvchengbin/is/src/ipv6' |
| is.iterable | import isIterable from '@lvchengbin/is/src/iterable' |
| is.leapYear | import isLeapYear from '@lvchengbin/is/src/leap-year' |
| is.map | import isMap from '@lvchengbin/is/src/map' |
| is.node | import isNode from '@lvchengbin/is/src/node' |
| is.number | import isNumber from '@lvchengbin/is/src/number' |
| is.object | import isObject from '@lvchengbin/is/src/object' |
| is.oneDimensionalArray | import isOneDimensionalArray from '@lvchengbin/is/src/one-dimensional-array' |
| is.plainObject | import isPlainObject from '@lvchengbin/is/src/plain-object' |
| is.promise | import isPromise from '@lvchengbin/is/src/promise' |
| is.regexp | import isRegexp from '@lvchengbin/is/src/regexp' |
| is.set | import isSet from '@lvchengbin/is/src/set' |
| is.string | import isString from '@lvchengbin/is/src/string' |
| is.true | import isTrue from '@lvchengbin/is/src/true' |
| is.undefined | import isUndefined from '@lvchengbin/is/src/undefined' |
| is.url | import isUrl from '@lvchengbin/is/src/url' |
| is.textNode | import isTextNode from '@lvchengbin/is/src/text-node' |
| is.window | import isWindow from '@lvchengbin/is/src/window' |
### is.between
For checking if a number/letter is in an interval
```js
import isBetween from '@lvchengbin/is/src/between';
isBetween( 0, -1, 1 ); // return true
```
### is.date
For checking if an object is a `Date` instance.
```js
import isDate from '@lvchengbin/is/src/date';
isDate( new Date ); // return true
```
### is.empty
an empty value could be am empty object(`{}`), an empty string, an empty array(`[]`), a number `0` or a `false` |
For checking if a value is empty, and empty values include empty object ({}), empty string (''), empty array ([]), number 0, false.
```js
import isEmpty from '@lvchengbin/is/src/empty';
isEmpty( '' ); // return true
isEmpty( [] ); // return true
isEmpty( {} ); // return true
isEmpty( 0 ); // return true
isEmpty( false ); // return true
```
### is.false
For checking if a value is `false`, if the second argument is `true` (by default), the function will check a generalized `false`, it means that the following strings all mean `false`: "false", "no", "0", "", "nay", "n", "disagree".
```js
import isFalse from '@lvchengbin/is/src/false';
isFalse( false ); // returns true
isFalse( 'false' ); // returns true
isFalse( 'false', false ); // returns false
```
### is.true
For checking if a value is `true`, if the second argument is `true` (by default), the function will check a generalized `true`, it means that the following strings all mean `true`: "true", "true", "yes", "ok", "1", "yea", "yep", "y", "agree".
```js
import isTrue from '@lvchengbin/is/src/true';
isTrue( true ); // returns true
isTrue( 'true' ); // returns true
isTrue( 'true', false ); // returns false
```
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