diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3a183d6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,45 @@
+# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
+
+# Compiled output
+/dist
+/tmp
+/out-tsc
+/bazel-out
+
+# Node
+/node_modules
+npm-debug.log
+yarn-error.log
+
+# IDEs and editors
+.idea/
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# Visual Studio Code
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+.history/*
+
+# Miscellaneous
+/.angular/cache
+.sass-cache/
+/connect.lock
+/coverage
+/libpeerconnection.log
+testem.log
+/typings
+
+# System files
+.DS_Store
+Thumbs.db
+
+*.ignore*
+temp
\ No newline at end of file
diff --git a/README.md b/README.md
index aeaa4cb..09c2707 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,300 @@
-# guard
-Type guards for typescript.
+
+
+
+
+## typescript-package/guard
+
+Type-safe guards for guarding the value types in TypeScript.
+
+
+[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge]
+[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]
+[![GitHub license][typescript-package-badge-license]][typescript-package-license]
+
+
+
+## Table of contents
+
+* [Installation](#installation)
+* [Api](#api)
+* [Benefits](#benefits)
+* [Type](#type)
+ * [Enforce](#enforce)
+ * [Indicate](#indicate)
+ * [Check](#check)
+ * [Guard](#guard)
+ * [Narrow](#narrow)
+ * [Summary](#summary)
+* [Git](#git)
+ * [Commit](#commit)
+ * [Versioning](#versioning)
+* [License](#license)
+
+## Installation
+
+```bash
+npm install @typescript-package/guard
+```
+
+## Api
+
+```typescript
+import {
+ // `guard` object.
+ guard,
+
+ // Prefixed `guard` functions.
+ guardArray,
+ guardBigInt,
+ guardBoolean,
+ guardClass,
+ guardDate,
+ guardDefined,
+ guardFalse,
+ guardFunction,
+ guardInstance,
+ guardKey,
+ guardNull,
+ guardNumber,
+ guardNumberBetween,
+ guardObject,
+ guardObjectKey,
+ guardObjectKeyIn,
+ guardObjectKeys,
+ guardObjectKeysIn,
+ guardObjectSomeKeys,
+ guardPrimitive,
+ guardRegExp,
+ guardString,
+ guardStringIncludes,
+ guardStringIncludesSome,
+ guardStringLength,
+ guardStringLengthBetween,
+ guardSymbol,
+ guardTrue,
+ guardType,
+ guardUndefined
+} from '@typescript-package/guard';
+```
+
+## Benefits
+
+Benefits of properly using the guards.
+
+1. Development, compile, and runtime **validation**.
+ * Development-time **validation** ensures the developer can only provide a specific type through the static typing in the IDE.
+ * Compile-time **validation** performs static analysis during compilation, ensuring no type violations are present in the code.
+ * Runtime **validation** confirms the type of a value at runtime, useful when working with data from external sources (e.g., APIs, user inputs).
+
+2. Type-safe code.
+ * **Validates** external or dynamic data at runtime.
+ * **Ensures** developers write type-safe code.
+
+3. Error **reduction** and **prevention**.
+ * **Error reduction** by combining static analysis and runtime checks.
+ * **Error prevention** by combining runtime validation with compile-time type checks reducing the risk of runtime errors due to unexpected types.
+
+4. **Enhanced code clarity** by reducing ambiguity in data types.
+
+5. **Enhanced application reliability** by ensuring unvalidated data does not cause severe issues.
+
+6. **Type safety layer** by ensuring the handling of unexpected or invalid data.
+
+## Type
+
+### Enforce
+
+A type enforce uses static typing to ensure only allowed types can be passed, and uses TypeScript's compile-time static analysis to enforce correctness.
+
+**Role**: A development and compile-time type restrictor and enforcer.
+**Scope**: Development and compile-time.
+**Purpose**:
+
+* Development and compile-time type **restriction** and **enforcement**.
+* **Enforces** type restrictions during development (via IDE feedback) and compile-time.
+* **Ensures** that only values of the specified type can be used before runtime.
+* **Disallows** invalid types at development and compile-time, but doesn't perform runtime checks, that is performed in the type checking.
+
+Enforce | Restrict | Check |
+------- | -------- | ----- |
+v | v | x |
+
+Example:
+
+```typescript
+const acceptNumber = (
+ value: number // type enforce/restrict
+): void => {
+ console.log(value);
+};
+
+acceptNumber(42); // v Allowed
+acceptNumber("42"); // x Development and compile-time error
+```
+
+### Indicate
+
+Indicates as an expression `value is type` the value is of the specified type resulting in a `boolean` type.
+
+Example:
+
+```typescript
+const isNumber = (
+ value: unknown
+): value is number // type indicate
+=> {
+ return typeof value === "number"; // type check
+} // type check
+```
+
+### Check
+
+Operate only at runtime, allowing validation of dynamically-typed or unknown values.
+
+**Role**: Runtime checker.
+**Scope**: Runtime only.
+**Purpose**:
+
+* **Checks** whether a given value is of a specific type during execution.
+* Used to create the type narrow.
+
+Enforce | Restrict | Check |
+------- | -------- | ----- |
+x | x | v |
+
+### Guard
+
+Combine development, and compile-time restriction with runtime validation, ensures the value type matches the expected type on any time, ensuring stricter enforcement of types.
+
+**Role**: A development, compile, and run-time type restrictor and enforcer.
+**Scope**: Development, compile, and run-time.
+**Purpose**:
+
+* **Ensures** the developer can only provide a specific type through the static typing.
+* **Enforces** type restrictions during development (via IDE feedback) and compile-time.
+* **Checks** whether a given value is of a specific type during execution.
+
+Enforce | Restrict | Check |
+------- | -------- | ----- |
+v | v | v |
+
+Example:
+
+```typescript
+const guardNumber = (
+ value: number // type enforce
+): value is number // type indicator
+=> {
+ return typeof value === "number"; // type check
+} // overall type guard
+```
+
+### Narrow
+
+It's a type-guard that ensures the narrowed type of a value matches the expected type on runtime.
+
+**Role**: A development, compile, and run-time type narrower.
+**Scope**: Development, compile-time, and runtime.
+**Purpose**:
+
+* Compile-time **restriction** and **enforcement**.
+* **Reduces** or **refines** the possible types of a value within a specific scope.
+* **Enables** precise typing based on context, such as conditional checks or type guards, affecting behavior at development, compile, and runtime.
+
+Enforce | Restrict | Narrow |
+------- | -------- | ------ |
+v | v | v |
+
+Example:
+
+```typescript
+const processValue = (
+ value: string | number // type enforce
+): void => {
+ if (typeof value === "string") {
+ console.log(value.toUpperCase()); // Type narrowed to 'string'
+ } else {
+ console.log(value.toFixed(2)); // Type narrowed to 'number'
+ }
+}; // type narrow
+
+processValue(42); // v Logs: 42.00
+processValue("hello"); // v Logs: HELLO
+```
+
+> It looks at these special checks (called type guards) and assignments, and the process of refining types to more specific types than declared is called narrowing. ["Typescript"](https://www.typescriptlang.org/docs/handbook/2/narrowing.html)
+
+### Summary
+
+Time scope.
+
+Feature | Development-time | Compile-time | Runtime |
+-------- | ---------------- | ------------ | ------- |
+Enforce | v | v | x |
+Indicate | v | x | x |
+Check | x | x | v |
+Guard | v | v | v |
+Narrow | v | v | v |
+
+## GIT
+
+### Commit
+
+* [AngularJS Git Commit Message Conventions][git-commit-angular]
+* [Karma Git Commit Msg][git-commit-karma]
+* [Conventional Commits][git-commit-conventional]
+
+### Versioning
+
+[Semantic Versioning 2.0.0][git-semver]
+
+**Given a version number MAJOR.MINOR.PATCH, increment the:**
+
+* MAJOR version when you make incompatible API changes,
+* MINOR version when you add functionality in a backwards-compatible manner, and
+* PATCH version when you make backwards-compatible bug fixes.
+
+Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
+
+**FAQ**
+How should I deal with revisions in the 0.y.z initial development phase?
+
+> The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
+
+How do I know when to release 1.0.0?
+
+> If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.
+
+## License
+
+MIT © typescript-package ([license][typescript-package-license])
+
+
+
+ [typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/guard
+ [isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/guard
+ [typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/guard
+ [typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/guard
+
+ [typescript-package-issues]: https://github.com/typescript-package/guard/issues
+ [typescript-package-forks]: https://github.com/typescript-package/guard/network
+ [typescript-package-license]: https://github.com/typescript-package/guard/blob/master/LICENSE
+ [typescript-package-stars]: https://github.com/typescript-package/guard/stargazers
+
+
+
+
+ [typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fguard.svg
+ [typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fguard
+
+
+[git-semver]: http://semver.org/
+
+
+[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153
+[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html
+[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/
diff --git a/ng-package.json b/ng-package.json
new file mode 100644
index 0000000..73414a4
--- /dev/null
+++ b/ng-package.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
+ "dest": "../../dist/guard",
+ "lib": {
+ "entryFile": "src/public-api.ts"
+ },
+ "keepLifecycleScripts": true
+}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..6f5cfe9
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,249 @@
+{
+ "name": "@testing-package/guard",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "@testing-package/guard",
+ "version": "1.0.0",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
+ }
+ ],
+ "license": "MIT",
+ "devDependencies": {
+ "@angular-package/testing": "^2.0.0-rc"
+ },
+ "peerDependencies": {
+ "@typescript-package/core": "^1.0.0",
+ "@typescript-package/is": "^1.0.0",
+ "@typescript-package/type": "^1.1.0"
+ }
+ },
+ "node_modules/@angular-package/testing": {
+ "version": "2.0.0-rc",
+ "resolved": "https://registry.npmjs.org/@angular-package/testing/-/testing-2.0.0-rc.tgz",
+ "integrity": "sha512-DjlOD0gnLlqT8b4Qqr5FlPJWnl1NsO0823fH9B+e+rDxoJZa6Ys2cGg8716ZRBrSVWdBeuVxrjDhMJpYX5GVDw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "peerDependencies": {
+ "@angular-package/type": "^5.0.0-rc.0",
+ "jasmine": "^3.9.0"
+ }
+ },
+ "node_modules/@angular-package/type": {
+ "version": "5.0.0-rc.0",
+ "resolved": "https://registry.npmjs.org/@angular-package/type/-/type-5.0.0-rc.0.tgz",
+ "integrity": "sha512-NR3ODKJTmmdEqCz7fn6YDO68p9DK/SNWGvCV8pUqQUSFHlbrc0RDaqqF0liIi1iJcRZhbF2UnhWIIOp/iamtsg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "dependencies": {
+ "tslib": "^2.3.0"
+ }
+ },
+ "node_modules/@typescript-package/core": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-package/core/-/core-1.0.0.tgz",
+ "integrity": "sha512-HW+g5qCKbqDtoxCa+igceaZu2wWkw/YMw28VIXSz0hs7KUURHYtkAcuIG14VkOzaYgbgd1ZRBh4LzoVIp/DWVw==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
+ }
+ ],
+ "license": "MIT",
+ "peer": true
+ },
+ "node_modules/@typescript-package/is": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-package/is/-/is-1.0.0.tgz",
+ "integrity": "sha512-t2abF/A91Jy2OpYJfd6xwtCoHDZrGyISxEa0A4Ab/ADGUmhZj60hdL6Fw9xPOD16c/PBz0+F4Uf9D9vj5UGmFw==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
+ }
+ ],
+ "license": "MIT",
+ "peer": true,
+ "peerDependencies": {
+ "@typescript-package/core": "^1.0.0",
+ "@typescript-package/type": "^1.0.0"
+ }
+ },
+ "node_modules/@typescript-package/type": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@typescript-package/type/-/type-1.1.0.tgz",
+ "integrity": "sha512-vQQD3LqgXDPrm/fbfYOA/JcgfrSf47BkPhutWf+aKnEcQlXlSFnjprlR5Z4WCjLzgCkj+ba2duns084LsyNmcQ==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
+ }
+ ],
+ "license": "MIT",
+ "peer": true
+ },
+ "node_modules/balanced-match": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true
+ },
+ "node_modules/brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "node_modules/concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true
+ },
+ "node_modules/fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
+ "dev": true,
+ "license": "ISC",
+ "peer": true
+ },
+ "node_modules/glob": {
+ "version": "7.2.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
+ "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
+ "deprecated": "Glob versions prior to v9 are no longer supported",
+ "dev": true,
+ "license": "ISC",
+ "peer": true,
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.1.1",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
+ "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
+ "dev": true,
+ "license": "ISC",
+ "peer": true,
+ "dependencies": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "dev": true,
+ "license": "ISC",
+ "peer": true
+ },
+ "node_modules/jasmine": {
+ "version": "3.99.0",
+ "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.99.0.tgz",
+ "integrity": "sha512-YIThBuHzaIIcjxeuLmPD40SjxkEcc8i//sGMDKCgkRMVgIwRJf5qyExtlJpQeh7pkeoBSOe6lQEdg+/9uKg9mw==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "dependencies": {
+ "glob": "^7.1.6",
+ "jasmine-core": "~3.99.0"
+ },
+ "bin": {
+ "jasmine": "bin/jasmine.js"
+ }
+ },
+ "node_modules/jasmine-core": {
+ "version": "3.99.1",
+ "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.99.1.tgz",
+ "integrity": "sha512-Hu1dmuoGcZ7AfyynN3LsfruwMbxMALMka+YtZeGoLuDEySVmVAPaonkNoBRIw/ectu8b9tVQCJNgp4a4knp+tg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true
+ },
+ "node_modules/minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "license": "ISC",
+ "peer": true,
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
+ "node_modules/once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
+ "dev": true,
+ "license": "ISC",
+ "peer": true,
+ "dependencies": {
+ "wrappy": "1"
+ }
+ },
+ "node_modules/path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "dev": true,
+ "license": "0BSD"
+ },
+ "node_modules/wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
+ "dev": true,
+ "license": "ISC",
+ "peer": true
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e475dff
--- /dev/null
+++ b/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "@testing-package/guard",
+ "version": "1.0.0",
+ "author": "wwwdev.io ",
+ "description": "Type-safe guards for guarding the value types in TypeScript.",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org"
+ },
+ "devDependencies": {
+ "@angular-package/testing": "^2.0.0-rc"
+ },
+ "peerDependencies": {
+ "@typescript-package/core": "^1.0.0",
+ "@typescript-package/is": "^1.0.0",
+ "@typescript-package/type": "^1.1.0"
+ },
+ "scripts": {
+ "prepublishOnly": "npm run pkg && npm run clean",
+ "pkg": "npm pkg delete dependencies",
+ "clean": "npm pkg delete scripts"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/typescript-package/guard.git"
+ },
+ "bugs": {
+ "url": "https://github.com/typescript-package/guard/issues"
+ },
+ "keywords": [
+ "@typescript-package",
+ "@typescript-package/guard"
+ ],
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
+ }
+ ],
+ "sideEffects": false
+}
diff --git a/src/execute-tests.ts b/src/execute-tests.ts
new file mode 100644
index 0000000..589af52
--- /dev/null
+++ b/src/execute-tests.ts
@@ -0,0 +1,130 @@
+export const tests = {
+ /**
+ * Switches for the `are` prefixed functions.
+ */
+ are: {
+ bigint: { describe: true, it: true },
+ boolean: { describe: true, it: true },
+ date: { describe: true, it: true },
+ defined: { describe: true, it: true },
+ false: { describe: true, it: true },
+ null: { describe: true, it: true },
+ number: { describe: true, it: true },
+ regexp: { describe: true, it: true },
+ string: { describe: true, it: true },
+ symbol: { describe: true, it: true },
+ true: { describe: true, it: true },
+ undefined: { describe: true, it: true },
+ },
+ object: {
+ guard: { describe: true, it: true },
+ is: { describe: true, it: true },
+ isNot: { describe: true, it: true },
+ },
+
+ /**
+ * Switches for the experimental.
+ */
+ experimental: {
+ bigint: { describe: true, it: true },
+ boolean: { describe: true, it: true },
+ number: { describe: true, it: true },
+ string: { describe: true, it: true },
+ symbol: { describe: true, it: true },
+ },
+
+ /**
+ * Switches for the `guard` prefixed functions.
+ */
+ guard: {
+ array: { describe: true, it: true },
+ bigint: { describe: true, it: true },
+ boolean: { describe: true, it: true },
+ class: { describe: true, it: true },
+ date: { describe: true, it: true },
+ defined: { describe: true, it: true },
+ false: { describe: true, it: true },
+ function: { describe: true, it: true },
+ instance: { describe: true, it: true },
+ key: { describe: true, it: true },
+ null: { describe: true, it: true },
+ number: { describe: true, it: true },
+ numberBetween: { describe: true, it: true },
+ object: { describe: true, it: true },
+ objectKey: { describe: true, it: true },
+ objectKeyIn: { describe: true, it: true },
+ objectKeys: { describe: true, it: true },
+ objectKeysIn: { describe: true, it: true },
+ objectSomeKeys: { describe: true, it: true },
+ primitive: { describe: true, it: true },
+ regexp: { describe: true, it: true },
+ string: { describe: true, it: true },
+ stringIncludes: { describe: true, it: true },
+ stringIncludesSome: { describe: true, it: true },
+ stringLength: { describe: true, it: true },
+ stringLengthBetween: { describe: true, it: true },
+ symbol: { describe: true, it: true },
+ true: { describe: true, it: true },
+ type: { describe: true, it: true },
+ undefined: { describe: true, it: true },
+ },
+
+ /**
+ * Switches for the `is` prefixed functions.
+ */
+ is: {
+ array: { describe: true, it: true },
+ bigint: { describe: true, it: true },
+ boolean: { describe: true, it: true },
+ booleanObject: { describe: true, it: true },
+ booleanType: { describe: true, it: true },
+ class: { describe: true, it: true },
+ date: { describe: true, it: true },
+ defined: { describe: true, it: true },
+ false: { describe: true, it: true },
+ function: { describe: true, it: true },
+ instance: { describe: true, it: true },
+ key: { describe: true, it: true },
+ not: {
+ boolean: { describe: true, it: true },
+ defined: { describe: true, it: true },
+ function: { describe: true, it: true },
+ null: { describe: true, it: true },
+ number: { describe: true, it: true },
+ string: { describe: true, it: true },
+ undefined: { describe: true, it: true },
+ },
+ null: { describe: true, it: true },
+ number: { describe: true, it: true },
+ numberBetween: { describe: true, it: true },
+ numberObject: { describe: true, it: true },
+ numberType: { describe: true, it: true },
+ object: { describe: true, it: true },
+ objectKey: { describe: true, it: true },
+ objectKeyIn: { describe: true, it: true },
+ objectKeys: { describe: true, it: true },
+ objectKeysIn: { describe: true, it: true },
+ objectSomeKeys: { describe: true, it: true },
+ param: { describe: true, it: true },
+ primitive: { describe: true, it: true },
+ regexp: { describe: true, it: true },
+ string: { describe: true, it: true },
+ stringIncludes: { describe: true, it: true },
+ stringIncludesSome: { describe: true, it: true },
+ stringLength: { describe: true, it: true },
+ stringLengthBetween: { describe: true, it: true },
+ stringObject: { describe: true, it: true },
+ stringType: { describe: true, it: true },
+ symbol: { describe: true, it: true },
+ true: { describe: true, it: true },
+ type: { describe: true, it: true },
+ undefined: { describe: true, it: true }
+ },
+
+ /**
+ * Switches for the recognize.
+ */
+ recognize: {
+ recognizeValue: { describe: true, it: true }
+ },
+};
diff --git a/src/interface/guard.interface.ts b/src/interface/guard.interface.ts
new file mode 100644
index 0000000..42abff9
--- /dev/null
+++ b/src/interface/guard.interface.ts
@@ -0,0 +1,156 @@
+// Function.
+import {
+ guardArray,
+ guardBigInt,
+ guardBoolean,
+ guardClass,
+ guardDate,
+ guardDefined,
+ guardFalse,
+ guardFunction,
+ guardInstance,
+ guardKey,
+ guardNull,
+ guardNumber,
+ guardNumberBetween,
+ guardObject,
+ guardObjectKey,
+ guardObjectKeyIn,
+ guardObjectKeys,
+ guardObjectKeysIn,
+ guardObjectSomeKeys,
+ guardPrimitive,
+ guardRegExp,
+ guardString,
+ guardStringIncludes,
+ guardStringIncludesSome,
+ guardStringLength,
+ guardStringLengthBetween,
+ guardSymbol,
+ guardTrue,
+ guardType,
+ guardUndefined
+} from '../lib';
+// Export: Interface.
+export interface Guard {
+ /**
+ * Guards the value to be an `array` of a generic type variable `Type`.
+ */
+ array: typeof guardArray;
+ /**
+ * Guards the value to be a `bigint`.
+ */
+ bigint: typeof guardBigInt;
+ /**
+ * Guards the value to be `boolean` of any type.
+ */
+ boolean: typeof guardBoolean;
+ /**
+ * Guards the value to be a `class` of generic type variable `Class`.
+ */
+ class: typeof guardClass;
+ /**
+ * Guards the value to be a date.
+ */
+ date: typeof guardDate;
+ /**
+ * Guards the value to be defined, not `undefined`.
+ */
+ defined: typeof guardDefined;
+ /**
+ * Guards the provided value to be `false`.
+ */
+ false: typeof guardFalse;
+ /**
+ * Guards the value to be a `Function`.
+ */
+ function: typeof guardFunction;
+ /**
+ * Guards the value to be an instance of the given `constructor`.
+ */
+ instance: typeof guardInstance;
+ /**
+ * Guards the value to be one of `string`, `number`, or `symbol` type.
+ */
+ key: typeof guardKey;
+ /**
+ * Guards the value to be `null`.
+ */
+ null: typeof guardNull;
+ /**
+ * Guards the value to be a `number` of any type.
+ */
+ number: typeof guardNumber;
+ /**
+ * Guards the value to be `number` between the specified range.
+ */
+ numberBetween: typeof guardNumberBetween;
+ /**
+ * Guards the value to be an `object` of a generic type variable `Obj`.
+ */
+ object: typeof guardObject;
+ /**
+ * Guards the value to be an `object` of generic type variable `Obj` that contains the given `key`.
+ */
+ objectKey: typeof guardObjectKey;
+ /**
+ * Guards the value to be an `object` of a generic type variable `Obj` that contains(or its prototype chain) the given `key`.
+ */
+ objectKeyIn: typeof guardObjectKeyIn;
+ /**
+ * Guards the value to be an `object` of a generic type variable `Obj` with its specified `keys`.
+ */
+ objectKeys: typeof guardObjectKeys;
+ /**
+ * Guards the value to be an `object` of a generic type variable `Obj` with specified keys in it(or its prototype chain).
+ */
+ objectKeysIn: typeof guardObjectKeysIn;
+ /**
+ * Guards the value to be an `object` of a generic type variable `Obj` with its specified `keys`.
+ */
+ objectSomeKeys: typeof guardObjectSomeKeys;
+ /**
+ * Guards the value to be the `Primitive` type or the given `type` of the `Primitives`.
+ */
+ primitive: typeof guardPrimitive;
+ /**
+ * Guards the value to be a `RegExp`.
+ */
+ regexp: typeof guardRegExp;
+ /**
+ * Guards the value to be `string` of any type.
+ */
+ string: typeof guardString;
+ /**
+ * Guards the value to be a `string` type or an instance of `String` that includes all of the specified words/sentences.
+ */
+ stringIncludes: typeof guardStringIncludes;
+ /**
+ * Guards the value to be a `string` type or an instance of `String` that includes some of the specified words/sentences.
+ */
+ stringIncludesSome: typeof guardStringIncludesSome;
+ /**
+ * Guards the value to be `string` type or `String` instance of a specified length.
+ */
+ stringLength: typeof guardStringLength;
+ /**
+ * Guards the value to be `string` or `String` instance of a length between the specified range.
+ */
+ stringLengthBetween: typeof guardStringLengthBetween;
+ /**
+ * Guards the value to be a `symbol`.
+ */
+ symbol: typeof guardSymbol;
+ /**
+ * Guards the value to be `true`.
+ */
+ true: typeof guardTrue;
+ /**
+ * Guards the value to be a type from a given `type`.
+ */
+ type: typeof guardType;
+ /**
+ * Guards the value to be `undefined`.
+ */
+ undefined: typeof guardUndefined;
+}
diff --git a/src/interface/index.ts b/src/interface/index.ts
new file mode 100644
index 0000000..2265c78
--- /dev/null
+++ b/src/interface/index.ts
@@ -0,0 +1 @@
+export type { Guard } from './guard.interface';
\ No newline at end of file
diff --git a/src/lib/guard-array.func.ts b/src/lib/guard-array.func.ts
new file mode 100644
index 0000000..f135846
--- /dev/null
+++ b/src/lib/guard-array.func.ts
@@ -0,0 +1,18 @@
+// Function.
+import { isArray } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `array` of a generic type variable `Type`.
+ * @template Type
+ * @template {object} [Payload=object]
+ * @param {Array} value An `array` of generic type variable `Type` to guard.
+ * @param {?ResultCallback, Payload>} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Array} The return `value` is a `boolean` indicating whether the `value` is an `array` of a generic type variable `Type`.
+ */
+export const guardArray = (
+ value: Array,
+ callback?: ResultCallback, Payload>,
+ payload?: Payload
+): value is Array => isArray(value, callback, payload);
diff --git a/src/lib/guard-big-int.func.ts b/src/lib/guard-big-int.func.ts
new file mode 100644
index 0000000..cd6c5fa
--- /dev/null
+++ b/src/lib/guard-big-int.func.ts
@@ -0,0 +1,21 @@
+// Function.
+import { isBigInt } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `bigint`.
+ * @template {bigint} BigInt
+ * @template {object} [Payload=object]
+ * @param {BigInt} value A `bigint` type value to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is BigInt} The return `value` is a `boolean` indicating whether the `value` is a `bigint`.
+ */
+export const guardBigInt = <
+ BigInt extends bigint,
+ Payload extends object = object
+>(
+ value: BigInt,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is BigInt => isBigInt(value, callback, payload);
diff --git a/src/lib/guard-boolean.func.ts b/src/lib/guard-boolean.func.ts
new file mode 100644
index 0000000..383dcb5
--- /dev/null
+++ b/src/lib/guard-boolean.func.ts
@@ -0,0 +1,21 @@
+// Function.
+import { isBoolean } from '@typescript-package/is';
+// Type.
+import { AnyBoolean, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `boolean` of any type.
+ * @template {AnyBoolean} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of generic type variable `Type` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the `value` is a `boolean` type or an instance of `Boolean`.
+ */
+export const guardBoolean = <
+ Type extends AnyBoolean,
+ Payload extends object = object
+>(
+ value: Type,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isBoolean(value, callback, payload);
diff --git a/src/lib/guard-class.func.ts b/src/lib/guard-class.func.ts
new file mode 100644
index 0000000..c0aeb58
--- /dev/null
+++ b/src/lib/guard-class.func.ts
@@ -0,0 +1,21 @@
+// Function.
+import { isClass } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `class` of generic type variable `Class`.
+ * @template {Function} Class
+ * @template {object} [Payload=object]
+ * @param {Class} value The `class` of a generic type variable `Class` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Class} The return value is a `boolean` indicating whether the provided `value` is a `class` of a generic type variable `Class`.
+ */
+export const guardClass = <
+ Class extends Function,
+ Payload extends object = object
+>(
+ value: Class,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Class => isClass(value, callback, payload);
diff --git a/src/lib/guard-date.func.ts b/src/lib/guard-date.func.ts
new file mode 100644
index 0000000..7369a35
--- /dev/null
+++ b/src/lib/guard-date.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isDate } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a date.
+ * @template {object} Payload
+ * @param {Date} value The value of `Date` type to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Date} The return value is a `boolean` indicating whether the value is a date.
+ */
+export const guardDate = (
+ value: Date,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Date => isDate(value, callback, payload);
diff --git a/src/lib/guard-defined.func.ts b/src/lib/guard-defined.func.ts
new file mode 100644
index 0000000..47fa975
--- /dev/null
+++ b/src/lib/guard-defined.func.ts
@@ -0,0 +1,18 @@
+// Function.
+import { isDefined } from '@typescript-package/is';
+// Type.
+import { Defined, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be defined, not `undefined`.
+ * @template Type
+ * @template {object} [Payload=object]
+ * @param {Defined} value The value of generic type `Defined`, never undefined type captured from itself to guard against `undefined`.
+ * @param {?ResultCallback, Payload>} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Defined} The return value is a `boolean` indicating whether the `value` is defined.
+ */
+export const guardDefined = (
+ value: Defined,
+ callback?: ResultCallback, Payload>,
+ payload?: Payload
+): value is Defined => isDefined(value, callback, payload);
diff --git a/src/lib/guard-false.func.ts b/src/lib/guard-false.func.ts
new file mode 100644
index 0000000..a3049ba
--- /dev/null
+++ b/src/lib/guard-false.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isFalse } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the provided value to be `false`.
+ * @template {object} Payload
+ * @param {false} value The value of `false` type to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is false} The return value is a `boolean` indicating whether the `value` is a `boolean` type or an instance of `Boolean` equal to `false`.
+ */
+export const guardFalse = (
+ value: false,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is false => isFalse(value, callback, payload);
diff --git a/src/lib/guard-function.func.ts b/src/lib/guard-function.func.ts
new file mode 100644
index 0000000..b3345f8
--- /dev/null
+++ b/src/lib/guard-function.func.ts
@@ -0,0 +1,18 @@
+// Function.
+import { isFunction } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `Function`.
+ * @template {Function} Type
+ * @template {object} Payload
+ * @param {Type} value The `function` of a generic type variable `Type` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the `value` is a `Function`.
+ */
+export const guardFunction = (
+ value: Type,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isFunction(value, callback, payload);
diff --git a/src/lib/guard-instance.func.ts b/src/lib/guard-instance.func.ts
new file mode 100644
index 0000000..a1a0547
--- /dev/null
+++ b/src/lib/guard-instance.func.ts
@@ -0,0 +1,23 @@
+// Function.
+import { isInstance } from '@typescript-package/is';
+// Type.
+import { Constructor, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an instance of the given `constructor`.
+ * @template {object} Obj
+ * @template {object} [Payload=object]
+ * @param {Obj} value An `object` of a generic type variable `Obj` to guard and be compared with an instance of a given `constructor`.
+ * @param {Constructor} constructor A `class` or `function` that specifies the type of the `constructor`.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the `value` is an instance of a given `constructor`.
+ */
+export const guardInstance = <
+ Obj extends object,
+ Payload extends object = object
+>(
+ value: Obj,
+ constructor: Constructor,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isInstance(value, constructor, callback, payload);
diff --git a/src/lib/guard-key.func.ts b/src/lib/guard-key.func.ts
new file mode 100644
index 0000000..030ee8e
--- /dev/null
+++ b/src/lib/guard-key.func.ts
@@ -0,0 +1,18 @@
+// Function.
+import { isKey } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be one of `string`, `number`, or `symbol` type.
+ * @template {PropertyKey} Key
+ * @template {object} Payload
+ * @param {Key} value The value of generic type variable `Key` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Key} The return value is a `boolean` indicating whether the `value` is a `string`, `number`, or `symbol`.
+ */
+export const guardKey = (
+ value: Key,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Key => isKey(value, callback, payload);
diff --git a/src/lib/guard-null.func.ts b/src/lib/guard-null.func.ts
new file mode 100644
index 0000000..7ca7838
--- /dev/null
+++ b/src/lib/guard-null.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isNull } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `null`.
+ * @template {object} Payload
+ * @param {null} value The value of `null` type to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is null} The returned value is a `boolean` indicating whether the `value` is `null`.
+ */
+export const guardNull = (
+ value: null,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is null => isNull(value, callback, payload);
diff --git a/src/lib/guard-number-between.func.ts b/src/lib/guard-number-between.func.ts
new file mode 100644
index 0000000..9e7c8ae
--- /dev/null
+++ b/src/lib/guard-number-between.func.ts
@@ -0,0 +1,31 @@
+// Function.
+import { isNumberBetween } from '@typescript-package/is';
+// Type.
+import { AnyNumber, NumberBetween, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `number` type or instance of `Number` between the specified range.
+ * @template {AnyNumber} Type
+ * @template {number} Min
+ * @template {number} Max
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` to guard.
+ * @param {Min} min The **minimum** range of generic type variable `Min` for a given `value`.
+ * @param {Max} max The **maximum** range of generic type variable `Max` for a given `value`.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is NumberBetween} The return value is a `boolean` indicating whether the `value` is a `number` type or an instance of `Number` between the
+ * specified range.
+ */
+export const guardNumberBetween = <
+ Type extends AnyNumber,
+ Min extends number,
+ Max extends number,
+ Payload extends object = object
+>(
+ value: Type,
+ min: Min,
+ max: Max,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is NumberBetween =>
+ isNumberBetween(value, min, max, callback, payload);
diff --git a/src/lib/guard-number.func.ts b/src/lib/guard-number.func.ts
new file mode 100644
index 0000000..d646fc0
--- /dev/null
+++ b/src/lib/guard-number.func.ts
@@ -0,0 +1,21 @@
+// Function.
+import { isNumber } from '@typescript-package/is';
+// Type.
+import { AnyNumber, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `number` of any type.
+ * @template {AnyNumber} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of generic type variable `Type` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the `value` is a `number` type or an instance of `Number`.
+ */
+export const guardNumber = <
+ Type extends AnyNumber,
+ Payload extends object = object
+>(
+ value: Type,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isNumber(value, callback, payload);
diff --git a/src/lib/guard-object-key-in.func.ts b/src/lib/guard-object-key-in.func.ts
new file mode 100644
index 0000000..07250c1
--- /dev/null
+++ b/src/lib/guard-object-key-in.func.ts
@@ -0,0 +1,27 @@
+// Function.
+import { isObjectKeyIn } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the `value` to be an `object` of a generic type variable `Obj` that contains(or its prototype chain) the given `key`.
+ * @template {object} Obj
+ * @template {keyof Obj} Key
+ * @template {object} [Payload=object]
+ * @param {Obj} value An `object` of a generic type variable `Obj`, by default of the type captured from itself that contains(or its prototype
+ * chain) the given `key`.
+ * @param {Key} key A key of generic type variable `Key` as the property name that the given `value` contains(or its prototype chain).
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the `value` is an `object` that contains(or its prototype chain) the given
+ * `key`.
+ */
+export const guardObjectKeyIn = <
+ Obj extends object,
+ Key extends keyof Obj,
+ Payload extends object = object
+>(
+ value: Obj,
+ key: Key,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObjectKeyIn(value, key, callback, payload as any);
diff --git a/src/lib/guard-object-key.func.ts b/src/lib/guard-object-key.func.ts
new file mode 100644
index 0000000..8e9acaa
--- /dev/null
+++ b/src/lib/guard-object-key.func.ts
@@ -0,0 +1,27 @@
+// Function.
+import { isObjectKey } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `object` of generic type variable `Obj` that contains the given `key`.
+ * @template {object} Obj
+ * @template {keyof Obj} Key
+ * @template {object} [Payload=object]
+ * @param {Obj} value An `object` of a generic type variable `Obj`, by default of the type captured from itself that contains the given `key` to
+ * guard.
+ * @param {Key} key A key of generic type variable `Key` as the property name that the given `value` contains.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the `value` is an `object` of generic type variable `Obj` that contains the
+ * given `key`.
+ */
+export const guardObjectKey = <
+ Obj extends object,
+ Key extends keyof Obj,
+ Payload extends object = object
+>(
+ value: Obj,
+ key: Key,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObjectKey(value, key, callback, payload as any);
diff --git a/src/lib/guard-object-keys-in.func.ts b/src/lib/guard-object-keys-in.func.ts
new file mode 100644
index 0000000..b18a916
--- /dev/null
+++ b/src/lib/guard-object-keys-in.func.ts
@@ -0,0 +1,27 @@
+// Function.
+import { isObjectKeysIn } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `object` of a generic type variable `Obj` with specified keys in it(or its prototype chain).
+ * @template {object} Obj
+ * @template {keyof Obj} Key
+ * @template {object} [Payload=object]
+ * @param {Obj} value An object of a generic type variable `Obj`, by default of the type captured from itself that contains(or its prototype
+ * chain) the given `keys` to guard.
+ * @param {Key[]} keys An `Array` of property keys to check whether the given `value` contains(or its prototype chain).
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the `value` is an `object` with specified `keys` in it(or its prototype
+ * chain).
+ */
+export const guardObjectKeysIn = <
+ Obj extends object,
+ Key extends keyof Obj,
+ Payload extends object = object
+>(
+ value: Obj,
+ keys: Key[],
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObjectKeysIn(value, keys, callback, payload as any);
diff --git a/src/lib/guard-object-keys.func.ts b/src/lib/guard-object-keys.func.ts
new file mode 100644
index 0000000..ea214a0
--- /dev/null
+++ b/src/lib/guard-object-keys.func.ts
@@ -0,0 +1,26 @@
+// Function.
+import { isObjectKeys } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `object` of a generic type variable `Obj` with its specified `keys`.
+ * @template {object} Obj
+ * @template {keyof Obj} Key
+ * @template {object} [Payload=object]
+ * @param {Obj} value An object of a generic type variable `Obj`, by default of the type captured from itself that contains the given `keys` to
+ * guard.
+ * @param {Key[]} keys An `Array` of property keys to check whether the given `value` contains.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the `value` is an `object` with its specified `keys`.
+ */
+export const guardObjectKeys = <
+ Obj extends object,
+ Key extends keyof Obj,
+ Payload extends object = object
+>(
+ value: Obj,
+ keys: Key[],
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObjectKeys(value, keys, callback, payload as any);
diff --git a/src/lib/guard-object-some-keys.func.ts b/src/lib/guard-object-some-keys.func.ts
new file mode 100644
index 0000000..3ccfa66
--- /dev/null
+++ b/src/lib/guard-object-some-keys.func.ts
@@ -0,0 +1,26 @@
+// Function.
+import { isObjectSomeKeys } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `object` of a generic type variable `Obj` with some of its `keys` or some groups of its `keys`.
+ * @template {object} Obj
+ * @template {object} [Payload=object]
+ * @param {Obj} value An object of a generic type variable `Obj`, by default of the type captured from itself that contains some or some of the
+ * groups of the given `keys`, to guard.
+ * @param {(keyof Obj | Array)[]} keys An `Array` of property names or a two-dimensional array of property names to check if the given `value` contains some of
+ * them.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the provided `value` is an `object` with some or some groups of the given
+ * `keys`.
+ */
+export const guardObjectSomeKeys = <
+ Obj extends object,
+ Payload extends object = object
+>(
+ value: Obj,
+ keys: (keyof Obj | Array)[],
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObjectSomeKeys(value, keys, callback, payload as any);
diff --git a/src/lib/guard-object.func.ts b/src/lib/guard-object.func.ts
new file mode 100644
index 0000000..5ab294b
--- /dev/null
+++ b/src/lib/guard-object.func.ts
@@ -0,0 +1,21 @@
+// Function.
+import { isObject } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be an `object` of a generic type variable `Obj`.
+ * @template {object} Obj
+ * @template {object} [Payload=object]
+ * @param {Obj} value An `object` of a generic type variable `Obj`, by default of the type captured from itself to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Obj} The return value is a `boolean` indicating whether the provided `value` is an `object` of a generic type variable `Obj`.
+ */
+export const guardObject = <
+ Obj extends object,
+ Payload extends object = object
+>(
+ value: Obj,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Obj => isObject(value, callback, payload);
diff --git a/src/lib/guard-primitive.func.ts b/src/lib/guard-primitive.func.ts
new file mode 100644
index 0000000..7da155b
--- /dev/null
+++ b/src/lib/guard-primitive.func.ts
@@ -0,0 +1,24 @@
+// Function.
+import { isPrimitive } from '@typescript-package/is';
+// Type.
+import { ResultCallback, Primitive, PrimitiveNames } from '@typescript-package/type';
+/**
+ * @description Guards the value to be the `Primitive` type or the given `type` of the `Primitives`.
+ * @template {Primitive} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by the `Primitive`, by default of the type captured from itself to
+ * guard.
+ * @param {?PrimitiveNames} [type] An optional specific type of `Primitives` to check the given value.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the `value` is the `Primitive` type or the given `type`.
+ */
+export const guardPrimitive = <
+ Type extends Primitive,
+ Payload extends object = object
+>(
+ value: Type,
+ type?: PrimitiveNames,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isPrimitive(value, type, callback, payload);
diff --git a/src/lib/guard-regexp.func.ts b/src/lib/guard-regexp.func.ts
new file mode 100644
index 0000000..bf14962
--- /dev/null
+++ b/src/lib/guard-regexp.func.ts
@@ -0,0 +1,18 @@
+// Function.
+import { isRegExp } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `RegExp`.
+ * @template {RegExp} Type
+ * @template {object} Payload
+ * @param {Type} value Regular expression of generic type variable `Type` constrained by `RegExp` to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return `value` is a `boolean` indicating whether the `value` is a `RegExp`.
+ */
+export const guardRegExp = (
+ value: Type,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isRegExp(value, callback, payload);
diff --git a/src/lib/guard-string-includes-some.func.ts b/src/lib/guard-string-includes-some.func.ts
new file mode 100644
index 0000000..882e516
--- /dev/null
+++ b/src/lib/guard-string-includes-some.func.ts
@@ -0,0 +1,32 @@
+// Function.
+import { isStringIncludesSome } from '@typescript-package/is';
+import { resultCallback } from '@typescript-package/core';
+// Type.
+import { AnyString, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `string` type or an instance of `String` that includes some of the specified words/sentences.
+ * @template {AnyString} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by the `AnyString`, by default of the type captured from itself to
+ * check against the `string` that contains some of the words/sentences from a given `includes`.
+ * @param {string[]} includes An `Array` of `string` as words/sentences to be case-sensitive searched for within the given `value`.
+ * @param {ResultCallback<
+ * Type,
+ * { includes: typeof includes } & Payload
+ * >} [callback=resultCallback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the provided `value` is a `string` type or an instance of `String` that
+ * includes all of the specified words/sentences.
+ */
+export const guardStringIncludesSome = <
+ Type extends AnyString,
+ Payload extends object = object
+>(
+ value: Type,
+ includes: string[],
+ callback: ResultCallback<
+ Type,
+ { includes: typeof includes } & Payload
+ > = resultCallback,
+ payload?: Payload
+): value is Type => isStringIncludesSome(value, includes, callback, payload);
diff --git a/src/lib/guard-string-includes.func.ts b/src/lib/guard-string-includes.func.ts
new file mode 100644
index 0000000..1b20dcd
--- /dev/null
+++ b/src/lib/guard-string-includes.func.ts
@@ -0,0 +1,32 @@
+// Function.
+import { isStringIncludes } from '@typescript-package/is';
+import { resultCallback } from '@typescript-package/core';
+// Type.
+import { AnyString, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `string` type or an instance of `String` that includes the specified words/sentences.
+ * @template {AnyString} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by the `AnyString`, by default of the type captured from itself to
+ * check against the `string` that contains words/sentences from a given `includes`.
+ * @param {string[]} includes An `Array` of `string` as words/sentences to be case-sensitive searched for within the given `value`.
+ * @param {ResultCallback<
+ * Type,
+ * { includes: typeof includes } & Payload
+ * >} [callback=resultCallback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the provided `value` is a `string` type or an instance of `String` that
+ * includes the specified words/sentences.
+ */
+export const guardStringIncludes = <
+ Type extends AnyString,
+ Payload extends object = object
+>(
+ value: Type,
+ includes: string[],
+ callback: ResultCallback<
+ Type,
+ { includes: typeof includes } & Payload
+ > = resultCallback,
+ payload?: Payload
+): value is Type => isStringIncludes(value, includes, callback, payload);
diff --git a/src/lib/guard-string-length-between.func.ts b/src/lib/guard-string-length-between.func.ts
new file mode 100644
index 0000000..3e2fa9c
--- /dev/null
+++ b/src/lib/guard-string-length-between.func.ts
@@ -0,0 +1,32 @@
+// Function.
+import { isStringLengthBetween } from '@typescript-package/is';
+// Type.
+import { AnyString, ResultCallback, StringOfLength } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `string` or `String` instance of a length between the specified range.
+ * @template {AnyString} Type
+ * @template {number} Min
+ * @template {number} Max
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by `AnyString`, by default of the type captured from itself to
+ * guard.
+ * @param {Min} min The **minimum** length of generic type variable `Min` of a given `value`.
+ * @param {Max} max The **maximum** length of generic type variable `Max` of a given `value`.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is StringOfLength} The return value is a `boolean` indicating whether the `value` is a `string` type or an instance of `String` of a length between
+ * the specified range.
+ */
+export const guardStringLengthBetween = <
+ Type extends AnyString,
+ Min extends number,
+ Max extends number,
+ Payload extends object = object
+>(
+ value: Type,
+ min: Min,
+ max: Max,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is StringOfLength =>
+ isStringLengthBetween(value, min, max, callback, payload);
diff --git a/src/lib/guard-string-length.func.ts b/src/lib/guard-string-length.func.ts
new file mode 100644
index 0000000..7498e22
--- /dev/null
+++ b/src/lib/guard-string-length.func.ts
@@ -0,0 +1,29 @@
+// Function.
+import { isStringLength } from '@typescript-package/is';
+// Type.
+import { AnyString, ResultCallback, StringOfLength } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `string` type or `String` instance of a specified length.
+ * @template {AnyString} Type
+ * @template {number} Length
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by `AnyString`, by default of the type captured from itself to
+ * guard.
+ * @param {Length} length The **length** of generic type variable `Length` of a given `value`.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is StringOfLength} The return value is a `boolean` indicating whether the `value` is a `string` type or an instance of `String` of a specified
+ * `length`.
+ */
+export const guardStringLength = <
+ Type extends AnyString,
+ Length extends number,
+ Payload extends object = object
+>(
+ value: Type,
+ length: Length,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is StringOfLength =>
+ isStringLength(value, length, callback, payload);
+
diff --git a/src/lib/guard-string.func.ts b/src/lib/guard-string.func.ts
new file mode 100644
index 0000000..4b19c7a
--- /dev/null
+++ b/src/lib/guard-string.func.ts
@@ -0,0 +1,22 @@
+// Function.
+import { isString } from '@typescript-package/is';
+// Type.
+import { AnyString, ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `string` of any type.
+ * @template {AnyString} Type
+ * @template {object} [Payload=object]
+ * @param {Type} value The value of a generic type variable `Type` constrained by the `AnyString`, by default of the type captured from itself to
+ * guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is Type} The return value is a `boolean` indicating whether the `value` is a `string` type or an instance of `String`.
+ */
+export const guardString = <
+ Type extends AnyString,
+ Payload extends object = object
+>(
+ value: Type,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is Type => isString(value, callback, payload);
diff --git a/src/lib/guard-symbol.func.ts b/src/lib/guard-symbol.func.ts
new file mode 100644
index 0000000..7d8d0ed
--- /dev/null
+++ b/src/lib/guard-symbol.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isSymbol } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a `symbol`.
+ * @template {object} Payload
+ * @param {symbol} value A `symbol` type value to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is symbol} The return value is a `boolean` indicating whether the `value` is a `symbol`.
+ */
+export const guardSymbol = (
+ value: symbol,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is symbol => isSymbol(value, callback, payload);
diff --git a/src/lib/guard-true.func.ts b/src/lib/guard-true.func.ts
new file mode 100644
index 0000000..dce9250
--- /dev/null
+++ b/src/lib/guard-true.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isTrue } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `true`.
+ * @template {object} Payload
+ * @param {true} value The value of `true` type to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is true} The return value is a `boolean` indicating whether the `value` is a `boolean` type or an instance of `Boolean` equal to `true`.
+ */
+export const guardTrue = (
+ value: true,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is true => isTrue(value, callback, payload);
diff --git a/src/lib/guard-type.func.ts b/src/lib/guard-type.func.ts
new file mode 100644
index 0000000..39675ab
--- /dev/null
+++ b/src/lib/guard-type.func.ts
@@ -0,0 +1,20 @@
+// Function.
+import { isType } from '@typescript-package/is';
+// Type.
+import { ResultCallback, Type, TypeNames } from '@typescript-package/type';
+/**
+ * @description Guards the value to be a type of given `type`.
+ * @template {Type} T
+ * @template {object} [Payload=object]
+ * @param {T} value The value of a generic type variable `T` constrained by the `Type`, by default of the type captured from itself, to guard.
+ * @param {TypeNames} type The value of `string` or `Constructor` type of the `Types` indicates against which type a given `value` is checked.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is T} The return value is a `boolean` indicating whether the `value` is a type from a given `type`.
+ */
+export const guardType = (
+ value: T,
+ type: TypeNames,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is T => isType(value, type, callback, payload);
diff --git a/src/lib/guard-undefined.func.ts b/src/lib/guard-undefined.func.ts
new file mode 100644
index 0000000..889758e
--- /dev/null
+++ b/src/lib/guard-undefined.func.ts
@@ -0,0 +1,17 @@
+// Function.
+import { isUndefined } from '@typescript-package/is';
+// Type.
+import { ResultCallback } from '@typescript-package/type';
+/**
+ * @description Guards the value to be `undefined`.
+ * @template {object} Payload
+ * @param {undefined} value The value of an `undefined` type to guard.
+ * @param {?ResultCallback} [callback] An optional `ResultCallback` function to handle the result before returns.
+ * @param {?Payload} [payload] Optional `object` of generic type variable `Payload` is assigned to the `payload` of the provided `callback` function.
+ * @returns {value is undefined} The return value is a `boolean` indicating whether the `value` is `undefined`.
+ */
+export const guardUndefined = (
+ value: undefined,
+ callback?: ResultCallback,
+ payload?: Payload
+): value is undefined => isUndefined(value, callback, payload);
diff --git a/src/lib/guard.object.ts b/src/lib/guard.object.ts
new file mode 100644
index 0000000..1b0cf73
--- /dev/null
+++ b/src/lib/guard.object.ts
@@ -0,0 +1,68 @@
+// Function.
+import {
+ guardArray,
+ guardBigInt,
+ guardBoolean,
+ guardClass,
+ guardDate,
+ guardDefined,
+ guardFalse,
+ guardFunction,
+ guardInstance,
+ guardKey,
+ guardNull,
+ guardNumber,
+ guardNumberBetween,
+ guardObject,
+ guardObjectKey,
+ guardObjectKeyIn,
+ guardObjectKeys,
+ guardObjectKeysIn,
+ guardObjectSomeKeys,
+ guardPrimitive,
+ guardRegExp,
+ guardString,
+ guardStringIncludes,
+ guardStringIncludesSome,
+ guardStringLength,
+ guardStringLengthBetween,
+ guardSymbol,
+ guardTrue,
+ guardType,
+ guardUndefined
+} from './index';
+// Interface.
+import { Guard } from '../interface';
+// `guardIs`.
+export const guard: Guard = Object.freeze({
+ array: guardArray,
+ bigint: guardBigInt,
+ boolean: guardBoolean,
+ class: guardClass,
+ date: guardDate,
+ defined: guardDefined,
+ false: guardFalse,
+ function: guardFunction,
+ instance: guardInstance,
+ key: guardKey,
+ null: guardNull,
+ number: guardNumber,
+ numberBetween: guardNumberBetween,
+ object: guardObject,
+ objectKey: guardObjectKey,
+ objectKeyIn: guardObjectKeyIn,
+ objectKeys: guardObjectKeys,
+ objectKeysIn: guardObjectKeysIn,
+ objectSomeKeys: guardObjectSomeKeys,
+ primitive: guardPrimitive,
+ regexp: guardRegExp,
+ string: guardString,
+ stringIncludes: guardStringIncludes,
+ stringIncludesSome: guardStringIncludesSome,
+ stringLength: guardStringLength,
+ stringLengthBetween: guardStringLengthBetween,
+ symbol: guardSymbol,
+ true: guardTrue,
+ type: guardType,
+ undefined: guardUndefined
+});
diff --git a/src/lib/index.ts b/src/lib/index.ts
new file mode 100644
index 0000000..bca06b8
--- /dev/null
+++ b/src/lib/index.ts
@@ -0,0 +1,33 @@
+// `guard` object.
+export { guard } from './guard.object';
+// `guard` prefixed functions.
+export { guardArray } from './guard-array.func';
+export { guardBigInt } from './guard-big-int.func';
+export { guardBoolean } from './guard-boolean.func';
+export { guardClass } from './guard-class.func';
+export { guardDate } from './guard-date.func';
+export { guardDefined } from './guard-defined.func';
+export { guardFalse } from './guard-false.func';
+export { guardFunction } from './guard-function.func';
+export { guardInstance } from './guard-instance.func';
+export { guardKey } from './guard-key.func';
+export { guardNull } from './guard-null.func';
+export { guardNumber } from './guard-number.func';
+export { guardNumberBetween } from './guard-number-between.func';
+export { guardObject } from './guard-object.func';
+export { guardObjectKey } from './guard-object-key.func';
+export { guardObjectKeyIn } from './guard-object-key-in.func';
+export { guardObjectKeys } from './guard-object-keys.func';
+export { guardObjectKeysIn } from './guard-object-keys-in.func';
+export { guardObjectSomeKeys } from './guard-object-some-keys.func';
+export { guardPrimitive } from './guard-primitive.func';
+export { guardRegExp } from './guard-regexp.func';
+export { guardString } from './guard-string.func';
+export { guardStringIncludes } from './guard-string-includes.func';
+export { guardStringIncludesSome } from './guard-string-includes-some.func';
+export { guardStringLength } from './guard-string-length.func';
+export { guardStringLengthBetween } from './guard-string-length-between.func';
+export { guardSymbol } from './guard-symbol.func';
+export { guardTrue } from './guard-true.func';
+export { guardType } from './guard-type.func';
+export { guardUndefined } from './guard-undefined.func';
\ No newline at end of file
diff --git a/src/public-api.ts b/src/public-api.ts
new file mode 100644
index 0000000..240e614
--- /dev/null
+++ b/src/public-api.ts
@@ -0,0 +1,39 @@
+/*
+ * Public API Surface of guard
+ */
+export {
+ // `guard` object.
+ guard,
+
+ // Prefixed `guard` functions.
+ guardArray,
+ guardBigInt,
+ guardBoolean,
+ guardClass,
+ guardDate,
+ guardDefined,
+ guardFalse,
+ guardFunction,
+ guardInstance,
+ guardKey,
+ guardNull,
+ guardNumber,
+ guardNumberBetween,
+ guardObject,
+ guardObjectKey,
+ guardObjectKeyIn,
+ guardObjectKeysIn,
+ guardObjectKeys,
+ guardObjectSomeKeys,
+ guardPrimitive,
+ guardRegExp,
+ guardString,
+ guardStringIncludes,
+ guardStringIncludesSome,
+ guardStringLength,
+ guardStringLengthBetween,
+ guardSymbol,
+ guardTrue,
+ guardType,
+ guardUndefined
+} from './lib';
diff --git a/src/test/guard-array.spec.ts b/src/test/guard-array.spec.ts
new file mode 100644
index 0000000..1552203
--- /dev/null
+++ b/src/test/guard-array.spec.ts
@@ -0,0 +1,53 @@
+// Function.
+import { guardArray } from '../lib/guard-array.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constants.
+ TESTING_ARRAY_BIGINT,
+ TESTING_ARRAY_BOOLEAN,
+ TESTING_ARRAY_CLASS,
+ TESTING_ARRAY_FUNCTION,
+ TESTING_ARRAY_NULL,
+ TESTING_ARRAY_NUMBER,
+ TESTING_ARRAY_OBJECT_ONE,
+ TESTING_ARRAY_STRING,
+ TESTING_ARRAY_SYMBOL_NUMBER,
+ TESTING_ARRAY_SYMBOL_STRING,
+ TESTING_ARRAY_UNDEFINED,
+
+ // Class.
+ TestingClass,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.array.describe,
+ tests.guard.array.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardArray.name, () => {
+ testing
+ // TRUE
+ .it('is DEFINED', () => expect(guardArray).toBeDefined())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_BIGINT)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_BOOLEAN)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_CLASS)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_FUNCTION)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_NULL)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_NUMBER)).toBeTruthy())
+ .it('Array Array', () => expect(guardArray(TESTING_ARRAY_OBJECT_ONE)).toBeTruthy())
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_STRING)).toBeTruthy())
+ .it('Array', () => {
+ expect(guardArray(TESTING_ARRAY_SYMBOL_STRING)).toBeTruthy();
+ expect(guardArray(TESTING_ARRAY_SYMBOL_NUMBER)).toBeTruthy();
+ })
+ .it('Array', () => expect(guardArray(TESTING_ARRAY_UNDEFINED)).toBeTruthy());
+});
diff --git a/src/test/guard-bigint.spec.ts b/src/test/guard-bigint.spec.ts
new file mode 100644
index 0000000..842844b
--- /dev/null
+++ b/src/test/guard-bigint.spec.ts
@@ -0,0 +1,52 @@
+// Function.
+import { guardBigInt } from '../lib/guard-big-int.func';
+// Object.
+import { guard } from '../lib/guard.object';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_BIGINT,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.bigint.describe,
+ tests.guard.bigint.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardBigInt.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardBigInt).toBeDefined())
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardBigInt(TESTING_BIGINT, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_BIGINT);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing.describe(`bigint`, () =>
+ testing
+ .it(`${TESTING_BIGINT}`, () => expect(guardBigInt(TESTING_BIGINT)).toBeTrue())
+ .it(`${TESTING_BIGINT}`, () => expect(guard.bigint(TESTING_BIGINT)).toBeTrue())
+ ));
+ });
+});
diff --git a/src/test/guard-boolean.spec.ts b/src/test/guard-boolean.spec.ts
new file mode 100644
index 0000000..2da8371
--- /dev/null
+++ b/src/test/guard-boolean.spec.ts
@@ -0,0 +1,70 @@
+// Function.
+import { guardBoolean } from '../lib/guard-boolean.func';
+// Object.
+import { guard } from '../lib/guard.object';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_FALSE,
+ TESTING_FALSE_INSTANCE,
+ TESTING_TRUE,
+ TESTING_TRUE_INSTANCE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.boolean.describe,
+ tests.guard.boolean.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardBoolean.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardBoolean).toBeDefined())
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardBoolean(TESTING_TRUE, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_TRUE);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ // ... primitives.
+ .describe(`primitive`, () => {
+ // boolean
+ testing.describe(`boolean`, () => {
+ testing
+ .it(`FALSE`, () => expect(guardBoolean(TESTING_FALSE)).toBeTrue())
+ .it(`TRUE`, () => expect(guardBoolean(TESTING_TRUE)).toBeTrue())
+ .it(`FALSE`, () => expect(guard.boolean(TESTING_FALSE)).toBeTrue())
+ .it(`TRUE`, () => expect(guard.boolean(TESTING_TRUE)).toBeTrue());
+ });
+ })
+ // ... instance.
+ .describe(`instance`, () => {
+ // boolean
+ testing.describe(`boolean`, () => {
+ testing
+ .it(`${TESTING_TRUE_INSTANCE}`, () => expect(guardBoolean(TESTING_TRUE_INSTANCE)).toBeTrue())
+ .it(`${TESTING_FALSE_INSTANCE}`, () => expect(guardBoolean(TESTING_FALSE_INSTANCE)).toBeTrue())
+ .it(`${TESTING_FALSE_INSTANCE}`, () => expect(guard.boolean(TESTING_FALSE_INSTANCE)).toBeTrue())
+ .it(`${TESTING_TRUE_INSTANCE}`, () => expect(guard.boolean(TESTING_TRUE_INSTANCE)).toBeTrue());
+ });
+ });
+ });
+});
diff --git a/src/test/guard-class.spec.ts b/src/test/guard-class.spec.ts
new file mode 100644
index 0000000..7273c20
--- /dev/null
+++ b/src/test/guard-class.spec.ts
@@ -0,0 +1,49 @@
+// Object.
+import { guard } from '../lib/guard.object';
+// Function.
+import { guardClass } from '../lib/guard-class.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_FUNCTION,
+ TestingPerson
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.class.describe,
+ tests.guard.class.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardClass.name, () => {
+ testing
+ .it('is DEFINED', () => expect(guardClass).toBeDefined())
+ .it('with callback and payload', () => {
+ guardClass(TestingPerson, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TestingPerson);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ .it(`Class`, () => {
+ expect(guardClass(TestingPerson)).toBeTrue();
+ expect(guard.class(TestingPerson)).toBeTrue();
+ })
+ .it(`FUNCTION`, () => {
+ expect(guardClass(TESTING_FUNCTION)).toBeFalse();
+ expect(guard.class(TESTING_FUNCTION)).toBeFalse();
+ });
+});
diff --git a/src/test/guard-date.spec.ts b/src/test/guard-date.spec.ts
new file mode 100644
index 0000000..0bd2961
--- /dev/null
+++ b/src/test/guard-date.spec.ts
@@ -0,0 +1,74 @@
+// Function.
+import { guardDate } from '../lib/guard-date.func';
+// Object.
+import { guard } from '../lib/guard.object';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_DATE,
+ TESTING_FUNCTION,
+
+ // Class.
+ TestingPerson
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.date.describe,
+ tests.guard.date.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardDate.name, () => {
+ let guardSpy: any;
+ testing
+ .it('is DEFINED', () => expect(guardDate).toBeDefined());
+
+ beforeEach(() => guardSpy = { ...{}, ...guard });
+ testing
+ .it('with callback and payload', () => {
+ guardDate(TESTING_DATE, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_DATE);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ .it(`called with ${TESTING_DATE}`, () => {
+ spyOn(guardSpy, 'date').withArgs(TESTING_DATE).and.returnValue(true);
+ guardSpy.date(TESTING_DATE);
+ expect(guardSpy.date).toHaveBeenCalled();
+ })
+ .it(`guard new Date()`, () => {
+ expect(guardDate(new Date('December 17, 1995 03:24:00'))).toBeTrue();
+ expect(guardDate(new Date('1995-12-17T03:24:00'))).toBeTrue();
+ expect(guardDate(new Date(1995, 11, 17))).toBeTrue();
+ expect(guardDate(new Date(1995, 11, 17, 3, 24, 0))).toBeTrue();
+ expect(guardDate(new Date(628021800000))).toBeTrue();
+ expect(guardDate(new Date(98, 1))).toBeTrue();
+ expect(guardDate(new Date(22, 1))).toBeTrue();
+
+ expect(guard.date(new Date('December 17, 1995 03:24:00'))).toBeTrue();
+ expect(guard.date(new Date('1995-12-17T03:24:00'))).toBeTrue();
+ expect(guard.date(new Date(1995, 11, 17))).toBeTrue();
+ expect(guard.date(new Date(1995, 11, 17, 3, 24, 0))).toBeTrue();
+ expect(guard.date(new Date(628021800000))).toBeTrue();
+ expect(guard.date(new Date(98, 1))).toBeTrue();
+ expect(guard.date(new Date(22, 1))).toBeTrue();
+ })
+ .it(`guard new Date() false`, () => {
+ expect(guardDate(new Date('invalid date'))).toBeFalse();
+ expect(guard.date(new Date('invalid date'))).toBeFalse();
+ });
+});
diff --git a/src/test/guard-defined.spec.ts b/src/test/guard-defined.spec.ts
new file mode 100644
index 0000000..515d8e4
--- /dev/null
+++ b/src/test/guard-defined.spec.ts
@@ -0,0 +1,45 @@
+// Function.
+import { guardDefined } from '../lib/guard-defined.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.defined.describe,
+ tests.guard.defined.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardDefined.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardDefined).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardDefined(TESTING_STRING, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_STRING);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ .it('undefined', () => expect(guardDefined(undefined as any)).toBeFalse());
+ });
+});
diff --git a/src/test/guard-false.spec.ts b/src/test/guard-false.spec.ts
new file mode 100644
index 0000000..e51f9e4
--- /dev/null
+++ b/src/test/guard-false.spec.ts
@@ -0,0 +1,59 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_TRUE,
+ TESTING_FALSE
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardFalse } from '../lib/guard-false.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.false.describe,
+ tests.guard.false.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardFalse.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardFalse).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardFalse(TESTING_FALSE, (result, value, payload) => {
+ expect(result).toBe(TESTING_TRUE);
+ expect(value).toBeFalse();
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing
+ .it(`${TESTING_FALSE}`, () => expect(guardFalse(TESTING_FALSE)).toBeTrue())
+ .it(`${TESTING_TRUE}`, () => expect(guardFalse(TESTING_TRUE as any)).toBeFalse())
+ )
+
+ // ... object.
+ .describe(`object`, () =>
+ testing
+ .it(`new Boolean(${TESTING_TRUE})`, () => expect(guardFalse(new Boolean(TESTING_TRUE) as any)).toBeFalse())
+ .it(`new Boolean(${TESTING_FALSE})`, () => expect(guardFalse(new Boolean(TESTING_FALSE) as any)).toBeTrue())
+ );
+ });
+});
diff --git a/src/test/guard-function.spec.ts b/src/test/guard-function.spec.ts
new file mode 100644
index 0000000..ddd5684
--- /dev/null
+++ b/src/test/guard-function.spec.ts
@@ -0,0 +1,42 @@
+// Function.
+import { guardFunction } from '../lib/guard-function.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_FUNCTION,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardFalse } from '../lib/guard-false.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.function.describe,
+ tests.guard.function.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardFalse.name, () => {
+ testing
+ // TRUE
+ .it('is DEFINED', () => expect(guardFunction).toBeDefined())
+ .it('with callback and payload', () => {
+ guardFunction(TESTING_FUNCTION, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_FUNCTION);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ .it(`function | Function`, () => expect(guardFunction(TESTING_FUNCTION)).toBeTrue());
+});
diff --git a/src/test/guard-instance.spec.ts b/src/test/guard-instance.spec.ts
new file mode 100644
index 0000000..824d82f
--- /dev/null
+++ b/src/test/guard-instance.spec.ts
@@ -0,0 +1,89 @@
+// Function.
+import { guardInstance } from '../lib/guard-instance.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_FALSE_INSTANCE,
+ TESTING_NUMBER,
+ TESTING_NUMBER_CONSTRUCTOR,
+ TESTING_NUMBER_INSTANCE,
+ TESTING_STRING,
+ TESTING_STRING_CONSTRUCTOR,
+ TESTING_STRING_INSTANCE,
+ TESTING_TRUE_INSTANCE,
+ TESTING_FUNCTION_CONSTRUCTOR_PERSON,
+ TESTING_PERSON,
+
+ // Class.
+ TestingClass,
+ TestingPerson,
+ TestingPersonShape
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.instance.describe,
+ tests.guard.instance.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardInstance.name, () => {
+ const personInstance: TestingPersonShape = new (TESTING_FUNCTION_CONSTRUCTOR_PERSON as any)('First name', 'Sur name', 27);
+
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardInstance).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('callback', () => {
+ guardInstance(TESTING_CLASS, TestingClass, (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_CLASS);
+ }
+ return result;
+ });
+ })
+ // ... instance.
+ .describe(`instance`, () => {
+ testing
+ .it(`CLASS`, () => expect(guardInstance(TESTING_CLASS, TestingClass)).toBeTrue())
+ .it(`class TestingPerson`, () => expect(guardInstance(TESTING_PERSON, TestingPerson)).toBeTrue())
+ .it(`function`, () => expect(guardInstance(personInstance, TESTING_FUNCTION_CONSTRUCTOR_PERSON as any)).toBeTrue());
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // boolean
+ .describe(`boolean`, () => {
+ testing
+ .it(`${TESTING_TRUE_INSTANCE}`, () => expect(guardInstance(TESTING_TRUE_INSTANCE, Boolean)).toBeTrue())
+ .it(`${TESTING_FALSE_INSTANCE}`, () => expect(guardInstance(TESTING_FALSE_INSTANCE, Boolean)).toBeTrue());
+ })
+
+ // number
+ .describe(`number`, () => {
+ testing
+ .it(`Number(${TESTING_NUMBER})`, () => expect(guardInstance(TESTING_NUMBER_CONSTRUCTOR, Number)).toBeFalse())
+ .it(`new Number(${TESTING_NUMBER})`, () => expect(guardInstance(TESTING_NUMBER_INSTANCE, Number)).toBeTrue());
+ })
+
+ // string
+ .describe(`string`, () => {
+ it(`String(${TESTING_STRING})`, () => expect(guardInstance(TESTING_STRING_CONSTRUCTOR, String)).toBeFalse());
+ it(`new String(${TESTING_STRING})`, () => expect(guardInstance(TESTING_STRING_INSTANCE, String)).toBeTrue());
+ });
+ });
+ });
+});
diff --git a/src/test/guard-key.spec.ts b/src/test/guard-key.spec.ts
new file mode 100644
index 0000000..b10cc37
--- /dev/null
+++ b/src/test/guard-key.spec.ts
@@ -0,0 +1,61 @@
+// Function.
+import { guardKey } from '../lib/guard-key.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_NUMBER,
+ TESTING_STRING,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.key.describe,
+ tests.guard.key.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardKey.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardKey).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardKey(TESTING_NUMBER, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_NUMBER);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // number
+ .describe(`number`, () => it(`${TESTING_NUMBER}`, () => expect(guardKey(TESTING_NUMBER)).toBeTrue()))
+ // string
+ .describe(`string`, () => it(`${TESTING_STRING}`, () => expect(guardKey(TESTING_STRING)).toBeTrue()))
+ // symbol
+ .describe(`symbol`, () => {
+ it(`Symbol(${TESTING_NUMBER})`, () => expect(guardKey(TESTING_SYMBOL_NUMBER)).toBeTrue());
+ it(`Symbol(${TESTING_STRING})`, () => expect(guardKey(TESTING_SYMBOL_STRING)).toBeTrue());
+ });
+ });
+ });
+});
diff --git a/src/test/guard-null.spec.ts b/src/test/guard-null.spec.ts
new file mode 100644
index 0000000..256a2f6
--- /dev/null
+++ b/src/test/guard-null.spec.ts
@@ -0,0 +1,48 @@
+// Function.
+import { guardNull } from '../lib/guard-null.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_NULL,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.null.describe,
+ tests.guard.null.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardNull.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardNull).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+
+ testing
+ .it('with callback and payload', () => {
+ guardNull(TESTING_NULL, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_NULL);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => testing.it(`${TESTING_NULL}`, () => expect(guardNull(TESTING_NULL)).toBeTrue()));
+ });
+});
diff --git a/src/test/guard-number-between.spec.ts b/src/test/guard-number-between.spec.ts
new file mode 100644
index 0000000..c43c0b6
--- /dev/null
+++ b/src/test/guard-number-between.spec.ts
@@ -0,0 +1,54 @@
+// Function.
+import { guardNumberBetween } from '../lib/guard-number-between.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_NUMBER,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.numberBetween.describe,
+ tests.guard.numberBetween.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardNumberBetween.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardNumberBetween).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardNumberBetween(TESTING_NUMBER, 1, TESTING_NUMBER, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_NUMBER);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // number
+ .describe(`number`, () => {
+ testing
+ .it(`${TESTING_NUMBER}`, () => expect(guardNumberBetween(TESTING_NUMBER, 1, TESTING_NUMBER)).toBeTrue());
+ });
+ });
+ });
+});
diff --git a/src/test/guard-number.spec.ts b/src/test/guard-number.spec.ts
new file mode 100644
index 0000000..76a1fd8
--- /dev/null
+++ b/src/test/guard-number.spec.ts
@@ -0,0 +1,59 @@
+// Function.
+import { guardNumber } from '../lib/guard-number.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_NUMBER,
+ TESTING_NUMBER_CONSTRUCTOR,
+ TESTING_NUMBER_INSTANCE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.number.describe,
+ tests.guard.number.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardNumber.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardNumber).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardNumber(TESTING_NUMBER, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_NUMBER);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // number
+ .describe(`number`, () =>
+ testing
+ .it(`${TESTING_NUMBER}`, () => expect(guardNumber(TESTING_NUMBER)).toBeTrue())
+ .it(`${TESTING_NUMBER_CONSTRUCTOR}`, () => expect(guardNumber(TESTING_NUMBER_CONSTRUCTOR)).toBeTrue()))
+ // number object
+ .describe(`number object`, () =>
+ testing.it(`${TESTING_NUMBER_INSTANCE}`, () => expect(guardNumber(TESTING_NUMBER_INSTANCE)).toBeTrue()));
+ });
+ });
+});
diff --git a/src/test/guard-object-key-in.spec.ts b/src/test/guard-object-key-in.spec.ts
new file mode 100644
index 0000000..0d2e69f
--- /dev/null
+++ b/src/test/guard-object-key-in.spec.ts
@@ -0,0 +1,96 @@
+// Function.
+import { guardObjectKeyIn } from '../lib/guard-object-key-in.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_NUMBER,
+ TESTING_OBJECT,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.objectKeyIn.describe,
+ tests.guard.objectKeyIn.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObjectKeyIn.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObjectKeyIn).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardObjectKeyIn(TESTING_CLASS, 'firstName', (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_CLASS);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... instance.
+ .describe(`instance`, () => {
+ testing.describe(`CLASS`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeyIn(TESTING_CLASS, 1030405027)).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_CLASS, 5)).toBeTrue();
+ })
+
+ .it('finds getter number', () => expect(guardObjectKeyIn(TESTING_CLASS, TESTING_NUMBER)).toBeTrue())
+
+ // string.
+ .it('has string key', () => expect(guardObjectKeyIn(TESTING_CLASS, 'surname')).toBeTrue())
+
+ // symbol.
+ .it('finds getter symbol key', () => {
+ expect(guardObjectKeyIn(TESTING_CLASS, TESTING_SYMBOL_NUMBER)).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_CLASS, TESTING_SYMBOL_STRING)).toBeTrue();
+ });
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing.describe(`OBJECT_ONE`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeyIn(TESTING_OBJECT, 1030405027)).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_OBJECT, 5)).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_OBJECT, TESTING_NUMBER)).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKeyIn(TESTING_OBJECT, 'key as string')).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_OBJECT, 'x')).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKeyIn(TESTING_OBJECT, TESTING_NUMBER)).toBeTrue();
+ expect(guardObjectKeyIn(TESTING_OBJECT, TESTING_SYMBOL_STRING)).toBeTrue();
+ });
+ });
+ });
+ });
+});
diff --git a/src/test/guard-object-key.spec.ts b/src/test/guard-object-key.spec.ts
new file mode 100644
index 0000000..187ffee
--- /dev/null
+++ b/src/test/guard-object-key.spec.ts
@@ -0,0 +1,93 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_FALSE,
+ TESTING_NUMBER,
+ TESTING_OBJECT,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardObjectKey } from '../lib/guard-object-key.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.objectKey.describe,
+ tests.guard.objectKey.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObjectKey.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObjectKey).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('callback', () => {
+ guardObjectKey(TESTING_CLASS, 'firstName', (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_CLASS);
+ }
+ return result;
+ });
+ })
+
+ // ... instance.
+ .describe(`instance`, () => {
+ testing.describe(`CLASS`, () => {
+ // number.
+ it('has number key', () => {
+ expect(guardObjectKey(TESTING_CLASS, 1030405027)).toBeTrue();
+ expect(guardObjectKey(TESTING_CLASS, 5)).toBeTrue();
+ });
+
+ it('finds getter number', () => expect(guardObjectKey(TESTING_CLASS, TESTING_NUMBER)).toBe(TESTING_FALSE));
+
+ // string.
+ it('has string key', () => expect(guardObjectKey(TESTING_CLASS, 'surname')).toBeTrue());
+
+ // symbol.
+ it('finds getter symbol key', () => {
+ expect(guardObjectKey(TESTING_CLASS, TESTING_SYMBOL_NUMBER)).toBe(TESTING_FALSE);
+ expect(guardObjectKey(TESTING_CLASS, TESTING_SYMBOL_STRING)).toBe(TESTING_FALSE);
+ });
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing.describe(`OBJECT_ONE`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKey(TESTING_OBJECT, 1030405027)).toBeTrue();
+ expect(guardObjectKey(TESTING_OBJECT, 5)).toBeTrue();
+ expect(guardObjectKey(TESTING_OBJECT, TESTING_NUMBER)).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKey(TESTING_OBJECT, 'key as string')).toBeTrue();
+ expect(guardObjectKey(TESTING_OBJECT, 'x')).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKey(TESTING_OBJECT, TESTING_NUMBER)).toBeTrue();
+ expect(guardObjectKey(TESTING_OBJECT, TESTING_SYMBOL_STRING)).toBeTrue();
+ });
+ });
+ });
+ });
+});
diff --git a/src/test/guard-object-keys-in.spec.ts b/src/test/guard-object-keys-in.spec.ts
new file mode 100644
index 0000000..7b9bb4b
--- /dev/null
+++ b/src/test/guard-object-keys-in.spec.ts
@@ -0,0 +1,108 @@
+// Function.
+import { guardObjectKeysIn } from '../lib/guard-object-keys-in.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_NUMBER,
+ TESTING_OBJECT,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.objectKeysIn.describe,
+ tests.guard.objectKeysIn.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObjectKeysIn.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObjectKeysIn).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ // ... instance.
+ .describe(`instance`, () => {
+ testing.describe(`TESTING_CLASS`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeysIn(TESTING_CLASS, [1030405027])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_CLASS, [5])).toBeTrue();
+ })
+
+ .it('finds getter number', () => expect(guardObjectKeysIn(TESTING_CLASS, [TESTING_NUMBER])).toBeTrue())
+
+ // string.
+ .it('has string key', () => expect(guardObjectKeysIn(TESTING_CLASS, ['surname'])).toBeTrue())
+
+ // symbol.
+ .it('finds getter symbol key', () => {
+ expect(guardObjectKeysIn(TESTING_CLASS, [TESTING_SYMBOL_NUMBER])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_CLASS, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing
+ .describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, [1030405027])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [5])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, ['key as string'])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, ['x'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER, TESTING_SYMBOL_STRING])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ })
+
+ .describe('object with some and every key', () => {
+ testing.describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key or any key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, [1030405027, 'key as string'])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [5])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, ['key as string'])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, ['x'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER])).toBeTrue();
+ expect(guardObjectKeysIn(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ });
+ });
+});
diff --git a/src/test/guard-object-keys.spec.ts b/src/test/guard-object-keys.spec.ts
new file mode 100644
index 0000000..6221b04
--- /dev/null
+++ b/src/test/guard-object-keys.spec.ts
@@ -0,0 +1,108 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_NUMBER,
+ TESTING_OBJECT,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardObjectKeys } from '../lib/guard-object-keys.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.objectKeys.describe,
+ tests.guard.objectKeys.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObjectKeys.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObjectKeys).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ // ... instance.
+ .describe(`instance`, () => {
+ testing.describe(`TESTING_CLASS`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeys(TESTING_CLASS, [1030405027])).toBeTrue();
+ expect(guardObjectKeys(TESTING_CLASS, [5])).toBeTrue();
+ })
+
+ .it('finds getter number', () => expect(guardObjectKeys(TESTING_CLASS, [TESTING_NUMBER])).toBeFalse())
+
+ // string.
+ .it('has string key', () => expect(guardObjectKeys(TESTING_CLASS, ['surname'])).toBeTrue())
+
+ // symbol.
+ .it('finds getter symbol key', () => {
+ expect(guardObjectKeys(TESTING_CLASS, [TESTING_SYMBOL_NUMBER])).toBeFalse();
+ expect(guardObjectKeys(TESTING_CLASS, [TESTING_SYMBOL_STRING])).toBeFalse();
+ });
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing
+ .describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, [1030405027])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [5])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, ['key as string'])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, ['x'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER, TESTING_SYMBOL_STRING])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ })
+
+ .describe('object with some and every key', () => {
+ testing.describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key or any key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, [1030405027, 'key as string'])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [5])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, ['key as string'])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, ['x'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER])).toBeTrue();
+ expect(guardObjectKeys(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ });
+ });
+});
diff --git a/src/test/guard-object-some-keys.spec.ts b/src/test/guard-object-some-keys.spec.ts
new file mode 100644
index 0000000..0e361b9
--- /dev/null
+++ b/src/test/guard-object-some-keys.spec.ts
@@ -0,0 +1,110 @@
+// Function.
+import { guardObjectSomeKeys } from '../lib/guard-object-some-keys.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_NUMBER,
+ TESTING_OBJECT,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.objectSomeKeys.describe,
+ tests.guard.objectSomeKeys.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObjectSomeKeys.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObjectSomeKeys).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ // ... instance.
+ .describe(`instance`, () => {
+ testing
+ .describe(`TESTING_CLASS`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectSomeKeys(TESTING_CLASS, [1030405027])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_CLASS, [5])).toBeTrue();
+ })
+
+ .it('finds getter number', () => expect(guardObjectSomeKeys(TESTING_CLASS, [TESTING_NUMBER])).toBeFalse())
+
+ // string.
+ .it('has string key', () => expect(guardObjectSomeKeys(TESTING_CLASS, ['surname'])).toBeTrue())
+
+ // symbol.
+ .it('finds getter symbol key', () => {
+ expect(guardObjectSomeKeys(TESTING_CLASS, [TESTING_SYMBOL_NUMBER])).toBeFalse();
+ expect(guardObjectSomeKeys(TESTING_CLASS, [TESTING_SYMBOL_STRING])).toBeFalse();
+ });
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing
+ .describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [1030405027])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [5])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, ['key as string'])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, ['x'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER, TESTING_SYMBOL_STRING])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ })
+
+ .describe('object with some and every key', () => {
+ testing
+ .describe(`TESTING_OBJECT`, () => {
+ testing
+ // number.
+ .it('has number key or any key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [1030405027, [5, TESTING_NUMBER]])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [[TESTING_NUMBER], [5]])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_NUMBER])).toBeTrue();
+ })
+
+ // string.
+ .it('has string key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, ['key as string', ['!@#$%^&*()Company', 'x']])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [['x', '!@#$%^&*()Company'], 'key as string'])).toBeTrue();
+ })
+
+ // symbol.
+ .it('has symbol key', () => {
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_SYMBOL_NUMBER, [TESTING_SYMBOL_NUMBER, TESTING_SYMBOL_STRING]])).toBeTrue();
+ expect(guardObjectSomeKeys(TESTING_OBJECT, [TESTING_SYMBOL_STRING])).toBeTrue();
+ });
+ });
+ });
+ });
+});
diff --git a/src/test/guard-object.spec.ts b/src/test/guard-object.spec.ts
new file mode 100644
index 0000000..2e51fe1
--- /dev/null
+++ b/src/test/guard-object.spec.ts
@@ -0,0 +1,51 @@
+// Function.
+import { guardObject } from '../lib/guard-object.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_CLASS,
+ TESTING_DATE,
+ TESTING_OBJECT,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.object.describe,
+ tests.guard.object.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardObject.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardObject).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('callback', () => {
+ guardObject(TESTING_OBJECT, (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_OBJECT);
+ }
+ return result;
+ });
+ })
+
+ // ... objects.
+ .describe('object', () => {
+ testing
+ .it(`CLASS`, () => expect(guardObject(TESTING_CLASS)).toBeTrue())
+ .it(`OBJECT_ONE`, () => expect(guardObject(TESTING_OBJECT)).toBeTrue())
+ .it(`TESTING_DATE`, () => expect(guardObject(TESTING_DATE)).toBeTrue());
+ });
+ });
+});
diff --git a/src/test/guard-primitive.spec.ts b/src/test/guard-primitive.spec.ts
new file mode 100644
index 0000000..e16a6cb
--- /dev/null
+++ b/src/test/guard-primitive.spec.ts
@@ -0,0 +1,88 @@
+// Function.
+import { guardPrimitive } from '../lib/guard-primitive.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_BIGINT,
+ TESTING_FALSE,
+ TESTING_NULL,
+ TESTING_NUMBER,
+ TESTING_STRING,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+ TESTING_TRUE,
+ TESTING_UNDEFINED,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.primitive.describe,
+ tests.guard.primitive.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardPrimitive.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardPrimitive).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('callback', () => {
+ guardPrimitive(TESTING_STRING, 'string' , (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_STRING);
+ }
+ return result;
+ });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // bigint
+ .describe(`bigint`, () => it(`${TESTING_BIGINT}`, () => expect(guardPrimitive(TESTING_BIGINT, 'bigint')).toBeTrue()))
+
+ // boolean
+ .describe(`boolean`, () => {
+ testing
+ .it(`${TESTING_TRUE}`, () => expect(guardPrimitive(TESTING_TRUE, 'boolean')).toBeTrue())
+ .it(`${TESTING_FALSE}`, () => expect(guardPrimitive(TESTING_FALSE, 'boolean')).toBeTrue());
+ })
+
+ // null
+ .it(`${TESTING_NULL}`, () => expect(guardPrimitive(TESTING_NULL, 'null')).toBeTrue())
+
+ // number
+ .describe(`number`, () => {
+ testing
+ .it(`${TESTING_NUMBER}`, () => expect(guardPrimitive(TESTING_NUMBER, 'number')).toBeTrue());
+ })
+
+ // string
+ .describe(`string`, () => {
+ testing
+ .it(`${TESTING_STRING}`, () => expect(guardPrimitive(TESTING_STRING, 'string')).toBeTrue());
+ })
+
+ // symbol
+ .describe(`symbol`, () => {
+ testing
+ .it(`Symbol(${TESTING_NUMBER})`, () => expect(guardPrimitive(TESTING_SYMBOL_NUMBER, 'symbol')).toBeTrue())
+ .it(`Symbol(${TESTING_STRING})`, () => expect(guardPrimitive(TESTING_SYMBOL_STRING, 'symbol')).toBeTrue());
+ })
+
+ // undefined
+ .it(`${TESTING_UNDEFINED}`, () => expect(guardPrimitive(TESTING_UNDEFINED, 'undefined')).toBeTrue());
+ });
+ });
+});
diff --git a/src/test/guard-regexp.spec.ts b/src/test/guard-regexp.spec.ts
new file mode 100644
index 0000000..e3d083a
--- /dev/null
+++ b/src/test/guard-regexp.spec.ts
@@ -0,0 +1,52 @@
+// Function.
+import { guardRegExp } from '../lib/guard-regexp.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_TRUE,
+ TESTING_REGEXP
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.regexp.describe,
+ tests.guard.regexp.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardRegExp.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardRegExp).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardRegExp(TESTING_REGEXP, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_REGEXP);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // bigint
+ .describe(`RegExp`, () => it(`${TESTING_REGEXP}`, () => expect(guardRegExp(TESTING_REGEXP)).toBe(TESTING_TRUE)));
+ });
+ });
+});
diff --git a/src/test/guard-string-includes-some.spec.ts b/src/test/guard-string-includes-some.spec.ts
new file mode 100644
index 0000000..8facc24
--- /dev/null
+++ b/src/test/guard-string-includes-some.spec.ts
@@ -0,0 +1,87 @@
+// Function.
+import { guardStringIncludesSome } from '../lib/guard-string-includes-some.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+ TESTING_STRING_CONSTRUCTOR,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.is.stringIncludesSome.describe,
+ tests.is.stringIncludesSome.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardStringIncludesSome.name, () => {
+ const TESTING_STRING_LONG = `Lorem Ipsum is simply dummy text of the printing and typesetting industry.
+ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
+ when an unknown printer took a galley of type and scrambled it to make a type specimen book.
+ It has survived not only five centuries, but also the leap into electronic typesetting,
+ remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
+ sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
+ like Aldus PageMaker including versions of Lorem Ipsum.`;
+
+ const TESTING_STRING_LONG_INSTANCE = new String(TESTING_STRING_LONG);
+
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardStringIncludesSome).toBeDefined())
+
+ // Checks ...
+ .describe(`checks`, () => {
+ testing
+ .it('callback', () => {
+ guardStringIncludesSome(TESTING_STRING, ['Company'], (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_STRING);
+ }
+ return result;
+ });
+ })
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // string
+ .describe(`string`, () => {
+ testing
+ .it(`TESTING_STRING, TESTING_STRING_LONG`, () => {
+ expect(guardStringIncludesSome(TESTING_STRING, [TESTING_STRING, '!@#$%^&*()', '3'])).toBeTrue();
+ // No word exists.
+ expect(guardStringIncludesSome(TESTING_STRING_LONG, [
+ 'no text',
+ 'no text is here'
+ ])).toBeFalse();
+
+ // Every word exists.
+ expect(guardStringIncludesSome(TESTING_STRING_LONG_INSTANCE, [
+ 'Lorem',
+ 'unchanged',
+ 'versions',
+ 'only',
+ ])).toBeTrue();
+
+ // Some word exists.
+ expect(guardStringIncludesSome(TESTING_STRING_LONG, [
+ 'Lorem',
+ 'unchanged',
+ 'versions',
+ 'only',
+ 'no text is here'
+ ])).toBeTrue();
+ })
+ .it(`String(${TESTING_STRING})`, () =>
+ expect(guardStringIncludesSome(TESTING_STRING_CONSTRUCTOR, [TESTING_STRING, '!@#$%^&*()', '3'])).toBeTrue());
+ });
+ });
+ });
+});
\ No newline at end of file
diff --git a/src/test/guard-string-includes.spec.ts b/src/test/guard-string-includes.spec.ts
new file mode 100644
index 0000000..9437501
--- /dev/null
+++ b/src/test/guard-string-includes.spec.ts
@@ -0,0 +1,88 @@
+// Function.
+import { guardStringIncludes } from '../lib/guard-string-includes.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+ TESTING_STRING_CONSTRUCTOR,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.stringIncludes.describe,
+ tests.guard.stringIncludes.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardStringIncludes.name, () => {
+ const TESTING_STRING_LONG = `Lorem Ipsum is simply dummy text of the printing and typesetting industry.
+ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
+ when an unknown printer took a galley of type and scrambled it to make a type specimen book.
+ It has survived not only five centuries, but also the leap into electronic typesetting,
+ remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
+ sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
+ like Aldus PageMaker including versions of Lorem Ipsum.`;
+
+ const TESTING_STRING_LONG_INSTANCE = new String(TESTING_STRING_LONG);
+
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardStringIncludes).toBeDefined())
+
+ // Checks ...
+ .describe(`checks`, () => {
+ testing
+ .it('callback', () => {
+ guardStringIncludes(TESTING_STRING, ['Company'], (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_STRING);
+ }
+ return result;
+ });
+ })
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // string
+ .describe(`string`, () => {
+ testing
+ .it(`${TESTING_STRING}`, () => {
+ expect(guardStringIncludes(TESTING_STRING, ['Company'])).toBeTrue();
+ expect(guardStringIncludes(TESTING_STRING, [TESTING_STRING, '!@#$%^&*()'])).toBeTrue();
+ // No word exists.
+ expect(guardStringIncludes(TESTING_STRING_LONG, [
+ 'no text',
+ 'no text is here'
+ ])).toBeFalse();
+
+ // Every word exists.
+ expect(guardStringIncludes(TESTING_STRING_LONG_INSTANCE, [
+ 'Lorem',
+ 'unchanged',
+ 'versions',
+ 'only',
+ ])).toBeTrue();
+
+ // Some word exists.
+ expect(guardStringIncludes(TESTING_STRING_LONG, [
+ 'Lorem',
+ 'unchanged',
+ 'versions',
+ 'only',
+ 'no text is here'
+ ])).toBeFalse();
+ })
+ .it(`String(${TESTING_STRING})`, () =>
+ expect(guardStringIncludes(TESTING_STRING_CONSTRUCTOR, [TESTING_STRING, '!@#$%^&*()'])).toBeTrue());
+ });
+ });
+ });
+});
diff --git a/src/test/guard-string-length-between.spec.ts b/src/test/guard-string-length-between.spec.ts
new file mode 100644
index 0000000..290ee17
--- /dev/null
+++ b/src/test/guard-string-length-between.spec.ts
@@ -0,0 +1,86 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+ TESTING_STRING_INSTANCE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardStringLengthBetween } from '../lib/guard-string-length-between.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.stringLengthBetween.describe,
+ tests.guard.stringLengthBetween.it
+);
+/**
+ * Tests.
+ */
+testing.describe(`guardStringLengthBetween()`, () => {
+ // Defined.
+ testing
+ .it('is DEFINED', () => expect(guardStringLengthBetween).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () =>
+ testing
+ .it('with callback and payload', () => {
+ guardStringLengthBetween(TESTING_STRING, 3, 1000, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_STRING);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing
+ .describe(`string`, () =>
+ testing
+ .it(`${TESTING_STRING} minimum 3`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING, 3, 1000)).toBeTrue()
+ )
+ .it(`${TESTING_STRING} maximum 3`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING, 0, 3)).toBeFalse()
+ )
+ )
+ .it(`${TESTING_STRING} minimum 18`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING, 18, 1000)).toBeFalse()
+ )
+ .it(`${TESTING_STRING} maximum 17`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING, 0, 17)).toBeTrue()
+ )
+ .it(`${TESTING_STRING} minimum 5 maximum 21`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING, 5, 21)).toBeTrue()
+ )
+ )
+ )
+ .describe(`String`, () =>
+ testing
+ .it(`new String(${TESTING_STRING}) minimum 3`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING_INSTANCE, 3, 1000)).toBeTrue()
+ )
+ .it(`new String(${TESTING_STRING}) maximum 3`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING_INSTANCE, 0, 3)).toBeFalse()
+ )
+ .it(`new String(${TESTING_STRING}) minimum 18`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING_INSTANCE, 18, 1000)).toBeFalse()
+ )
+ .it(`new String(${TESTING_STRING}) maximum 17`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING_INSTANCE, 0, 17)).toBeTrue()
+ )
+ .it(`new String(${TESTING_STRING}) minimum 5 maximum 21`, () =>
+ expect(guardStringLengthBetween(TESTING_STRING_INSTANCE, 5, 21)).toBeTrue()
+ )
+ );
+});
diff --git a/src/test/guard-string-length.spec.ts b/src/test/guard-string-length.spec.ts
new file mode 100644
index 0000000..0d92238
--- /dev/null
+++ b/src/test/guard-string-length.spec.ts
@@ -0,0 +1,70 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+ TESTING_STRING_INSTANCE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardStringLength } from '../lib/guard-string-length.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.stringLength.describe,
+ tests.guard.stringLength.it
+);
+/**
+ * Tests.
+ */
+testing.describe(`guardStringLength()`, () => {
+ // Defined.
+ testing
+ .it('is DEFINED', () => expect(guardStringLength).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () =>
+ testing
+ .it('with callback and payload', () => {
+ guardStringLength(TESTING_STRING, 17, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_STRING);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing
+ .describe(`string`, () =>
+ testing
+ .it(`${TESTING_STRING}`, () =>
+ expect(guardStringLength(TESTING_STRING, 17)).toBeTrue()
+ )
+ .it(`${TESTING_STRING}`, () =>
+ expect(guardStringLength(TESTING_STRING, 16)).toBeFalse()
+ )
+ .it(`${TESTING_STRING}`, () =>
+ expect(guardStringLength(TESTING_STRING, 18)).toBeFalse()
+ )
+ )
+ )
+ )
+ .describe(`String`, () =>
+ testing
+ .it(`new String(${TESTING_STRING})`, () =>
+ (expect(guardStringLength(TESTING_STRING_INSTANCE, 17)).toBeTrue(),
+ expect(guardStringLength(TESTING_STRING_INSTANCE, 16)).toBeFalse(),
+ expect(guardStringLength(TESTING_STRING_INSTANCE, 18)).toBeFalse())
+ )
+ );
+});
diff --git a/src/test/guard-string.spec.ts b/src/test/guard-string.spec.ts
new file mode 100644
index 0000000..1cbc586
--- /dev/null
+++ b/src/test/guard-string.spec.ts
@@ -0,0 +1,61 @@
+// Function.
+import { guardString } from '../lib/guard-string.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_STRING,
+ TESTING_STRING_INSTANCE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.string.describe,
+ tests.guard.string.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardString.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardString).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardString(TESTING_STRING, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_STRING);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ .describe(`string`, () =>
+ testing.it(`${TESTING_STRING}`, () =>
+ expect(guardString(TESTING_STRING)).toBeTrue()
+ )
+ )
+ .describe(`object`, () =>
+ testing.describe(`String`, () =>
+ testing.it(`new String(${TESTING_STRING})`, () =>
+ expect(guardString(TESTING_STRING_INSTANCE)).toBeTrue()
+ )
+ )
+ );
+ });
+ });
+});
diff --git a/src/test/guard-symbol.spec.ts b/src/test/guard-symbol.spec.ts
new file mode 100644
index 0000000..d461d90
--- /dev/null
+++ b/src/test/guard-symbol.spec.ts
@@ -0,0 +1,59 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_NUMBER,
+ TESTING_STRING,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+ TESTING_TRUE,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardSymbol } from '../lib/guard-symbol.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.symbol.describe,
+ tests.guard.symbol.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardSymbol.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardSymbol).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardSymbol(TESTING_SYMBOL_STRING, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_SYMBOL_STRING);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // symbol
+ .describe(`symbol`, () => {
+ testing
+ .it(`Symbol(${TESTING_NUMBER})`, () => expect(guardSymbol(TESTING_SYMBOL_NUMBER)).toBe(TESTING_TRUE))
+ .it(`Symbol(${TESTING_STRING})`, () => expect(guardSymbol(TESTING_SYMBOL_STRING)).toBe(TESTING_TRUE));
+ });
+ });
+ });
+});
diff --git a/src/test/guard-true.spec.ts b/src/test/guard-true.spec.ts
new file mode 100644
index 0000000..f04883a
--- /dev/null
+++ b/src/test/guard-true.spec.ts
@@ -0,0 +1,55 @@
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_TRUE,
+ TESTING_FALSE
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+import { guardTrue } from '../lib/guard-true.func';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.true.describe,
+ tests.guard.true.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardTrue.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardTrue).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing.it('callback', () => {
+ guardTrue(TESTING_TRUE, (result, value, payload) => {
+ expect(result).toBe(TESTING_TRUE);
+ if (payload) {
+ expect(value).toBeTrue();
+ }
+ return result;
+ });
+ })
+
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing
+ .it(`${TESTING_TRUE}`, () => expect(guardTrue(TESTING_TRUE)).toBe(TESTING_TRUE))
+ .it(`${TESTING_FALSE}`, () => expect(guardTrue(TESTING_FALSE as any)).toBe(TESTING_FALSE))
+ )
+
+ // ... object.
+ .describe(`object`, () =>
+ testing
+ .it(`new Boolean(${TESTING_TRUE})`, () => expect(guardTrue(new Boolean(TESTING_TRUE) as any)).toBe(TESTING_TRUE))
+ .it(`new Boolean(${TESTING_FALSE})`, () => expect(guardTrue(new Boolean(TESTING_FALSE) as any)).toBe(TESTING_FALSE))
+ );
+ });
+});
diff --git a/src/test/guard-type.spec.ts b/src/test/guard-type.spec.ts
new file mode 100644
index 0000000..fe77fd2
--- /dev/null
+++ b/src/test/guard-type.spec.ts
@@ -0,0 +1,132 @@
+// Function.
+import { guardType } from '../lib/guard-type.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_BIGINT,
+ TESTING_CLASS,
+ TESTING_FALSE,
+ TESTING_FALSE_INSTANCE,
+ TESTING_FUNCTION,
+ TESTING_NULL,
+ TESTING_NUMBER,
+ TESTING_NUMBER_CONSTRUCTOR,
+ TESTING_NUMBER_INSTANCE,
+ TESTING_OBJECT,
+ TESTING_STRING,
+ TESTING_STRING_CONSTRUCTOR,
+ TESTING_STRING_INSTANCE,
+ TESTING_SYMBOL_NUMBER,
+ TESTING_SYMBOL_STRING,
+ TESTING_TRUE,
+ TESTING_TRUE_INSTANCE,
+ TESTING_UNDEFINED,
+
+ // Class.
+ TestingClass,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+// Function.
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(tests.is.type.describe, tests.is.type.it);
+/**
+ * Tests.
+ */
+testing.describe(guardType.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardType).toBeDefined())
+
+ // Checks ...
+ .describe(`checks`, () => {
+ testing
+ .it('callback', () => {
+ guardType(TESTING_STRING, 'string', (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_STRING);
+ }
+ return result;
+ });
+ guardType(TESTING_NUMBER, 'number', (result, value, payload) => {
+ expect(result).toBeTrue();
+ if (payload) {
+ expect(value).toEqual(TESTING_NUMBER);
+ }
+ return result;
+ });
+ })
+ // ... instance.
+ .describe(`instance`, () => testing.it(`Class`, () => expect(guardType(TESTING_CLASS, TestingClass)).toBeTrue()))
+ // ... function.
+ .describe(`function`, () => {
+ testing
+ .it(`${TESTING_FUNCTION}`, () => expect(guardType(TESTING_FUNCTION, 'function')).toBeTrue())
+ .it(`${TESTING_CLASS}`, () => expect(guardType(TestingClass, 'function')).toBeFalse());
+ })
+ // ... objects.
+ .describe('object', () => {
+ testing
+ .it(`CLASS`, () => expect(guardType(TESTING_CLASS, 'object')).toBeTrue())
+ .it(`TESTING_OBJECT`, () => expect(guardType(TESTING_OBJECT, 'object')).toBeTrue());
+ })
+ // ... primitives.
+ .describe(`primitive`, () => {
+ testing
+ // bigint
+ .describe(`bigint`, () => testing.it(`${TESTING_BIGINT}`, () => expect(guardType(TESTING_BIGINT, 'bigint')).toBeTrue()))
+ // boolean
+ .describe(`boolean`, () => {
+ testing
+ .it(`${TESTING_TRUE}`, () => expect(guardType(TESTING_TRUE, 'boolean')).toBeTrue())
+ .it(`${TESTING_FALSE}`, () => expect(guardType(TESTING_FALSE, 'boolean')).toBeTrue());
+ })
+ // null
+ .it(`${TESTING_NULL}`, () => expect(guardType(TESTING_NULL, 'null')).toBeTrue())
+ // number
+ .describe(`number`, () => {
+ testing
+ .it(`${TESTING_NUMBER}`, () => expect(guardType(TESTING_NUMBER, 'number')).toBeTrue())
+ .it(`Number(${TESTING_NUMBER})`, () => expect(guardType(TESTING_NUMBER_CONSTRUCTOR, 'number')).toBeTrue());
+ })
+ // string
+ .describe(`string`, () => {
+ testing
+ .it(`${TESTING_STRING}`, () => expect(guardType(TESTING_STRING, 'string')).toBeTrue())
+ .it(`String(${TESTING_STRING})`, () => expect(guardType(TESTING_STRING_CONSTRUCTOR, 'string')).toBeTrue());
+ })
+ // symbol
+ .describe(`symbol`, () => {
+ testing
+ .it(`Symbol(${TESTING_NUMBER})`, () => expect(guardType(TESTING_SYMBOL_NUMBER, 'symbol')).toBeTrue())
+ .it(`Symbol(${TESTING_STRING})`, () => expect(guardType(TESTING_SYMBOL_STRING, 'symbol')).toBeTrue());
+ })
+ // undefined
+ .it(`${TESTING_UNDEFINED}`, () => expect(guardType(TESTING_UNDEFINED, 'undefined')).toBeTrue())
+ // ... object.
+ .describe(`object`, () => {
+ testing
+ // BigInt
+ .describe(`BigInt`, () => testing.it(`${TESTING_BIGINT}`, () => expect(guardType(TESTING_BIGINT, 'bigint')).toBeTrue()))
+ // Boolean
+ .describe(`Boolean`, () => {
+ testing
+ .it(`${TESTING_TRUE_INSTANCE}`, () => expect(guardType(TESTING_TRUE_INSTANCE, 'boolean')).toBeFalse())
+ .it(`${TESTING_FALSE_INSTANCE}`, () => expect(guardType(TESTING_FALSE_INSTANCE, 'boolean')).toBeFalse());
+ })
+ // Number
+ .describe(`Number`, () =>
+ testing.it(`new Number(${TESTING_NUMBER})`, () => expect(guardType(TESTING_NUMBER_INSTANCE, 'number')).toBeFalse()))
+ // String
+ .describe(`String`, () =>
+ testing.it(`new String(${TESTING_STRING})`, () => expect(guardType(TESTING_STRING_INSTANCE, 'string')).toBeFalse()));
+ });
+ });
+ });
+});
diff --git a/src/test/guard-undefined.spec.ts b/src/test/guard-undefined.spec.ts
new file mode 100644
index 0000000..6e7f9da
--- /dev/null
+++ b/src/test/guard-undefined.spec.ts
@@ -0,0 +1,50 @@
+// Function.
+import { guardUndefined } from '../lib/guard-undefined.func';
+// Testing.
+import {
+ // Main.
+ Testing,
+
+ // Constant.
+ TESTING_UNDEFINED,
+} from '@angular-package/testing';
+// Execute tests.
+import { tests } from '../execute-tests';
+/**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.guard.undefined.describe,
+ tests.guard.undefined.it
+);
+/**
+ * Tests.
+ */
+testing.describe(guardUndefined.name, () => {
+ testing
+ // Defined.
+ .it('is DEFINED', () => expect(guardUndefined).toBeDefined())
+
+ // Checks ...
+ .describe(`guards`, () => {
+ testing
+ .it('with callback and payload', () => {
+ guardUndefined(TESTING_UNDEFINED, (result, value, payload) => {
+ expect(result).toBeTrue();
+ expect(value).toEqual(TESTING_UNDEFINED);
+ if (payload) {
+ expect(payload.action).toEqual('action');
+ expect(payload.name).toEqual('name');
+ expect(payload.param).toEqual('param');
+ }
+ return result;
+ }, { action: 'action', name: 'name', param: 'param' });
+ })
+ // ... primitives.
+ .describe(`primitive`, () =>
+ testing.it(`${TESTING_UNDEFINED}`, () =>
+ expect(guardUndefined(TESTING_UNDEFINED)).toBeTrue()
+ )
+ );
+ });
+});
diff --git a/src/test/guard.spec.ts b/src/test/guard.spec.ts
new file mode 100644
index 0000000..4cc1bb2
--- /dev/null
+++ b/src/test/guard.spec.ts
@@ -0,0 +1,51 @@
+import { guard } from '../lib/guard.object';
+// Testing.
+import {
+ // Main.
+ Testing,
+ } from '@angular-package/testing';
+ // Execute tests.
+import { tests } from '../execute-tests';
+ /**
+ * Initialize testing.
+ */
+const testing = new Testing(
+ tests.object.guard.describe,
+ tests.object.guard.it
+ );
+ /**
+ * Tests.
+ */
+testing.describe(`guard`, () => {
+ testing
+ .describe('DEFINED', () => {
+ testing
+ .it('guard', () => expect(guard).toBeDefined())
+ .it('guard.array()', () => expect(guard.array).toBeDefined())
+ .it('guard.bigint()', () => expect(guard.bigint).toBeDefined())
+ .it('guard.boolean()', () => expect(guard.boolean).toBeDefined())
+ .it('guard.class()', () => expect(guard.class).toBeDefined())
+ .it('guard.defined()', () => expect(guard.defined).toBeDefined())
+ .it('guard.false()', () => expect(guard.false).toBeDefined())
+ .it('guard.function()', () => expect(guard.function).toBeDefined())
+ .it('guard.instance()', () => expect(guard.instance).toBeDefined())
+ .it('guard.key()', () => expect(guard.key).toBeDefined())
+ .it('guard.null()', () => expect(guard.null).toBeDefined())
+ .it('guard.number()', () => expect(guard.number).toBeDefined())
+ .it('guard.numberBetween()', () => expect(guard.numberBetween).toBeDefined())
+ .it('guard.object()', () => expect(guard.object).toBeDefined())
+ .it('guard.objectKey()', () => expect(guard.objectKey).toBeDefined())
+ .it('guard.objectKeyIn()', () => expect(guard.objectKeyIn).toBeDefined())
+ .it('guard.objectKeys()', () => expect(guard.objectKeys).toBeDefined())
+ .it('guard.objectKeysIn()', () => expect(guard.objectKeysIn).toBeDefined())
+ .it('guard.objectSomeKeys()', () => expect(guard.objectSomeKeys).toBeDefined())
+ .it('guard.primitive()', () => expect(guard.primitive).toBeDefined())
+ .it('guard.string()', () => expect(guard.string).toBeDefined())
+ .it('guard.stringIncludes()', () => expect(guard.stringIncludes).toBeDefined())
+ .it('guard.stringIncludesSome()', () => expect(guard.stringIncludesSome).toBeDefined())
+ .it('guard.symbol()', () => expect(guard.symbol).toBeDefined())
+ .it('guard.true()', () => expect(guard.true).toBeDefined())
+ .it('guard.type()', () => expect(guard.type).toBeDefined())
+ .it('guard.undefined()', () => expect(guard.undefined).toBeDefined());
+ });
+});
diff --git a/tsconfig.lib.json b/tsconfig.lib.json
new file mode 100644
index 0000000..2359bf6
--- /dev/null
+++ b/tsconfig.lib.json
@@ -0,0 +1,15 @@
+/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
+/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/lib",
+ "declaration": true,
+ "declarationMap": true,
+ "inlineSources": true,
+ "types": []
+ },
+ "exclude": [
+ "**/*.spec.ts"
+ ]
+}
diff --git a/tsconfig.lib.prod.json b/tsconfig.lib.prod.json
new file mode 100644
index 0000000..9215caa
--- /dev/null
+++ b/tsconfig.lib.prod.json
@@ -0,0 +1,11 @@
+/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
+/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
+{
+ "extends": "./tsconfig.lib.json",
+ "compilerOptions": {
+ "declarationMap": false
+ },
+ "angularCompilerOptions": {
+ "compilationMode": "partial"
+ }
+}
diff --git a/tsconfig.spec.json b/tsconfig.spec.json
new file mode 100644
index 0000000..254686d
--- /dev/null
+++ b/tsconfig.spec.json
@@ -0,0 +1,15 @@
+/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
+/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/spec",
+ "types": [
+ "jasmine"
+ ]
+ },
+ "include": [
+ "**/*.spec.ts",
+ "**/*.d.ts"
+ ]
+}