Skip to content

Commit

Permalink
refactor(Is): add new is functions and update jsdoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Sep 20, 2021
1 parent ad40a8f commit 55635fa
Showing 1 changed file with 73 additions and 33 deletions.
106 changes: 73 additions & 33 deletions src/is/interface/is.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ import { isObject } from '../lib/is-object.func';
import { isObjectKey } from '../lib/is-object-key.func';
import { isObjectKeyIn } from '../lib/is-object-key-in.func';
import { isObjectKeys } from '../lib/is-object-keys.func';
import { isObjectKeysIn } from '../lib/is-object-keys-in.func';
import { isObjectSomeKeys } from '../lib/is-object-some-keys.func';
import { isPrimitive } from '../lib/is-primitive.func';
import { isRegExp } from '../lib/is-regexp.func';
import { isString } from '../lib/is-string.func';
import { isStringIncludes } from '../lib/is-string-includes.func';
import { isStringIncludesSome } from '../lib/is-string-includes-some.func';
import { isStringLength } from '../lib/is-string-length.func';
import { isStringObject } from '../lib/is-string-object.func';
import { isStringType } from '../lib/is-string-type.func';
Expand All @@ -38,7 +42,8 @@ import { IsNot } from '../not/interface/is-not.interface';
*/
export interface Is {
/**
* Checks if any `value` is an `Array`, `Array` instance, and `object` type.
* Checks if any value is of the type obtained from its `Object.prototype` equal to `'array'` or an `object` type. The value is also
* checked by the `isArray()` method of `Array`.
*/
array: typeof isArray;

Expand All @@ -48,53 +53,57 @@ export interface Is {
bigint: typeof isBigInt;

/**
* Checks if any `value` is a `boolean` type not instance of `Boolean` and `Object` or `object` type instance of `Boolean` and `Object`.
* Checks if any `value` is a `boolean` type, or the obtained type from its `Object.prototype` equal to `'boolean'`, or an `object`
* type and an instance of `Boolean` that is equal to `true` or `false`.
*/
boolean: typeof isBoolean;

/**
* Checks if any `value` is an `object` type and instance of `Boolean` and `Object`.
* Checks if any `value` is of the type obtained from its `Object.prototype` equal to `'boolean'` or an `object` type, and an instance of
* `Boolean` that is equal to `true` or `false`.
*/
booleanObject: typeof isBooleanObject;

/**
* Checks if any `value` is a `boolean` type not an instance of `Boolean` and `Object`, and equal to `true` or `false`.
* Checks if any `value` is a `boolean` type equal to `true` or `false`.
*/
booleanType: typeof isBooleanType;

/**
* Checks if any `value` is a `function` type, an instance of `Function` and `Object` as a generic variable type `Class` of `class`.
* Checks if any value is a `function` type or of the type obtained from its `Object.prototype` equal to `'function'` and an instance of
* `Function`. It also confirms it's a `class` by using `regexp` on the obtained string from its `Function.prototype`.
*/
class: typeof isClass;

/**
* Checks if any `value` is an `object` type instance of `Date` and `Object`.
* Checks if any `value` is of the type obtained from its `Object.prototype` equal to `'date'` or an `object` type, and an instance of
* `Date`. The `value` is checked against a valid date by using `isNaN()` function.
*/
date: typeof isDate; // From 4.2.0

/**
* Checks if the provided `value` of a generic `Type` is not an `undefined` type and is not equal to `undefined`.
* Checks if any `value` is not an `undefined` type and is not equal to `undefined`.
*/
defined: typeof isDefined;

/**
* Checks if any `value` is a `boolean` type not an instance of `Boolean` and `Object`, or is an `object` type and instance of `Boolean`
* and `Object` and equal to `false`.
* Checks if any `value` is a `boolean` type or an instance of `Boolean` by using `isBoolean()` function, that is equal to `false`.
*/
false: typeof isFalse; // From `4.2.0`

/**
* Checks if any `value` is a `function` type, an instance of `Function` and `Object`.
* Checks if any `value` is a `function` type or of the type obtained from its `Object.prototype` equal to `'function'` and an instance
* of `Function`. It also denies it's a `class` by using `regexp` on the obtained string from its `Function.prototype`.
*/
function: typeof isFunction;

/**
* Checks if any `value` is an `object` of a generic `Obj` type and an `instance` of `Constructor` type.
* Checks if any `value` is an instance of a given constructor.
*/
instance: typeof isInstance;

/**
* Checks if any `value` is one of the `string`, `number`, or `symbol`.
* Checks if any `value` is one of the `string`, `number`, or `symbol` type.
*/
key: typeof isKey;

Expand All @@ -104,79 +113,111 @@ export interface Is {
not: IsNot;

/**
* Checks if any `value` is an `object` type and equal to `null`.
* Checks if any `value` is of the type obtained from its `Object.prototype` equal to `'null'` or an `object` type that is equal to
* `null`.
*/
null: typeof isNull;

/**
* Checks if any `value` is a `number` type not an instance of `Number` and `Object` or `object` type instance of `Number` and `Object`.
* Checks if any `value` is a `number` type, or of the type obtained from its `Object.prototype` equal to `'number'` or an `object` type
* and an instance of `Number`. The value is also checked by the `isFinite()` function to determine whether it's finite and is validated
* by the `Number.isNaN()` function.
*/
number: typeof isNumber;

/**
* Checks if any `value` is a `number` type, not instance of `Object` and `Number` or `object` type and instance of `Number`
* and `Object`, in the specified range.
* Checks if any `value` is a `number` type or an instance of `Number` by using `isNumber()`, between a specified range.
*/
numberBetween: typeof isNumberBetween; // From `4.2.0`

/**
* Checks if any `value` is an `object` type and instance of `Number` and `Object`.
* Checks if any `value` is of the type obtained from its `Object.prototype` equal to `'number'`, or an `object` type and an instance of
* `Number` and is also checked by the `isFinite()` function to determine whether it's finite and is validated by the `Number.isNaN()`
* function.
*/
numberObject: typeof isNumberObject;

/**
* Checks if any `value` is a `boolean` type not an instance of `Boolean` and `Object`, and equal to `true` or `false`.
* Checks if any `value` is a `number` type and is checked by the `isFinite()` function to determine whether it's finite and is validated
* by the `Number.isNaN()` function.
*/
numberType: typeof isNumberType;

/**
* Checks if any `value` is an `object` of a generic `Obj` type and `Object` instance.
* Checks if any `value` is an `object` type or of the type obtained from its `Object.prototype` equal to `'object'`, and an instance of
* `Object`.
*/
object: typeof isObject;

/**
* Checks if any `value` is an `object` with its own specified `key` of the `PropertyKey` type.
* Checks if any `value` is an `object` by using the `isObject()` function with its key of the `PropertyKey` type.
*/
objectKey: typeof isObjectKey;

/**
* Checks if any `value` is an `Object` with the `key` of the `Key` type by using the `in` operator.
* Checks if any `value` is an `object` by using the `isObject()` function with a key of the `PropertyKey` in it(or its prototype chain)
* by using the `in` operator.
*/
objectKeyIn: typeof isObjectKeyIn;

/**
* Checks if any `value` is an `object` of a generic `Type` with some of its keys from given `keys` of the `PropertyKey` type.
* Checks if any `value` is an `object`(by using the `isObject()`) with its keys by using `hasOwnProperty()` method of `Object`.
*/
objectKeys: typeof isObjectKeys;

/**
* Checks if any `value` is the `Primitive` type from a given `type` of the `Primitives`.
* Checks if any `value` is an `object` by using the `isObject()` function with keys of the `PropertyKey` in it(or its prototype chain) by
* using the `in` operator.
*/
objectKeysIn: typeof isObjectKeysIn;

/**
* Checks if any `value` is an `object` by using the `isObject()` function with some of its keys or some groups of its keys of the
* `PropertyKey` type.
*/
objectSomeKeys: typeof isObjectSomeKeys;

/**
* Checks if any `value` is a `Primitive` type or type from a given `type` of the `Primitives`.
*/
primitive: typeof isPrimitive;

/**
* Checks if any `value` is a regular expression of a `RegExp` type, an instance of `Object` and `RegExp`.
* Checks if any `value` is a regular expression of the type obtained from its `Object.prototype` equal to `'regexp'`, or an `object`
* type, and an instance of `RegExp`.
*/
regexp: typeof isRegExp; // From 4.2.0

/**
* Checks if any `value` is a `string` type, not instance of `Object` and `String` or `object` type and instance of `String` and `Object`.
* Checks if any `value` is a `string` type by using the `isStringType()` function or an instance of `String` by using the
* `isStringObject()` function.
*/
string: typeof isString;

/**
* Checks if any `value` is a `string` type, not instance of `Object` and `String` or `object` type and instance of `String` and `Object`,
* of a length in the specified range.
* Checks if any `value` is a `string` type and it's not an instance of `Object` and `String` or it's an `object` type, and an instance
* of `String` and `Object` that includes all of the specified words.
*/
stringIncludes: typeof isStringIncludes;

/**
* Checks if any `value` is a `string` type or an instance of `String` by using `isString()` that includes some of the specified words.
*/
stringIncludesSome: typeof isStringIncludesSome;

/**
* Checks if any `value` is a `string` type or an instance of `String` by using `isString()` of `length` within the specified range.
*/
stringLength: typeof isStringLength;

/**
* Checks if any `value` is an `object` type instance of `String` and `Object`.
* Checks if any `value` is of the type obtained from its `Object.prototype` equal to `'string'` or an `object` type, and an instance of
* `String`.
*/
stringObject: typeof isStringObject;

/**
* Checks if any `value` is a `string` type not instance of `String` and `Object`.
* Checks if any `value` is a `string` type.
*/
stringType: typeof isStringType;

Expand All @@ -186,18 +227,17 @@ export interface Is {
symbol: typeof isSymbol;

/**
* Checks if any `value` is a `boolean` type not an instance of `Boolean` and `Object`, or is an `object` type and instance of `Boolean`
* and `Object` and equal to `true`.
* Checks if any `value` is a `boolean` type or an instance of `Boolean`(by using the `isBoolean()`) equal to `true`.
*/
true: typeof isTrue; // From 4.2.0

/**
* Checks if any `value` is a type of `Type` from a given `type` of the `Types`.
* Checks if any `value` is a type of given `type` of the `Types`.
*/
type: typeof isType;

/**
* Checks if any `value` is an `undefined` type and equal to `undefined`.
* Checks if any `value` is an `undefined` type.
*/
undefined: typeof isUndefined;
}

0 comments on commit 55635fa

Please sign in to comment.