@carlsebastian/jsu 1.0.40 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +112 -0
- package/global.js +1 -0
- package/package.json +31 -3
- package/src/docs/api/api.md +22 -0
- package/src/docs/custom/custom.md +38 -0
- package/src/docs/custom/error/builder/builder.md +24 -0
- package/src/docs/custom/error/constructor/error.constructor.md +33 -0
- package/src/docs/custom/error/constructor/opts/argumentError.md +78 -0
- package/src/docs/custom/error/constructor/opts/indexOutOfBounds.md +77 -0
- package/src/docs/custom/error/constructor/opts/invalidPropertyError.md +83 -0
- package/src/docs/custom/error/constructor/opts/missingParameterError.md +75 -0
- package/src/docs/custom/error/constructor/opts/missingPropertyError.md +81 -0
- package/src/docs/custom/error/constructor/opts/noSuchElementTagError.md +81 -0
- package/src/docs/custom/error/constructor/opts/notSupportedError.md +81 -0
- package/src/docs/custom/error/constructor/opts/unknownPropertyError.md +82 -0
- package/src/docs/custom/error/error.md +36 -0
- package/src/docs/custom/utils/clamp.md +45 -0
- package/src/docs/custom/utils/constructorOrTypeOf.md +39 -0
- package/src/docs/custom/utils/generator/generator.md +59 -0
- package/src/docs/custom/utils/generator/methods/generator.newToken.md +35 -0
- package/src/docs/custom/utils/generator/methods/generator.randomCharacters.md +35 -0
- package/src/docs/custom/utils/generator/methods/generator.randomInteger.md +41 -0
- package/src/docs/custom/utils/nameOf.md +39 -0
- package/src/types/api/api.d.ts +27 -9
- package/src/types/custom/error/builder/error.builder.d.ts +1 -1
- package/src/types/custom/error/constructor/error.custom.d.ts +24 -8
- package/src/types/custom/error/constructor/error.meta.d.ts +6 -6
- package/src/types/global.d.ts +3 -3
- package/src/utils/Arithmetic/arithmetic.js +0 -0
- package/src/utils/Arithmetic/operations/operation.divide.js +79 -0
- package/src/utils/Arithmetic/operations/operation.multiply.js +79 -0
- package/src/utils/Arithmetic/operations/operation.subtract.js +76 -0
- package/src/utils/Arithmetic/operations/operation.sum.js +76 -0
- package/src/utils/custom/error/builder/error.builder.js +3 -3
- package/src/utils/custom/error/error.js +2 -2
- package/src/utils/custom/utils/custom.utils.js +3 -3
- package/src/utils/custom/utils/generator/generator.js +4 -4
- package/src/utils/dom/attr/attr.class.js +4 -4
- package/src/utils/dom/attr/attr.id.js +3 -3
- package/src/utils/dom/attr/attr.style.js +5 -5
- package/src/utils/dom/element/create/element.create.js +14 -14
- package/src/utils/dom/element/getElementBy/dom.getElementBy.js +6 -6
- package/src/utils/dom/element/query/dom.query.js +3 -3
- package/src/utils/dom/element/tag-verifier/verifier.js +5 -5
- package/src/utils/dom/lifecycle/mount.js +3 -3
- package/src/utils/dom/lifecycle/unmount.js +2 -2
- package/src/utils/storage/local/storage.local.js +3 -3
- package/src/utils/storage/session/storage.session.js +3 -3
- package/src/utils/storage/storage.js +2 -2
- package/src/utils/variables.js +13 -7
- package/tsconfig.json +0 -14
package/README.MD
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
## Table-Of-Contents
|
|
4
|
+
|
|
5
|
+
- [README](#readme)
|
|
6
|
+
- [Table-Of-Contents](#table-of-contents)
|
|
7
|
+
- [Introduction](#introduction)
|
|
8
|
+
- [About](#about)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [How To Use](#how-to-use)
|
|
11
|
+
- [Example](#example)
|
|
12
|
+
- [Source Code / Repository](#source-code--repository)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
- [Navigate To](#navigate-to)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Introduction
|
|
19
|
+
|
|
20
|
+
- Hello welcome to my first utility project **JavaScriptUtilities** (**JSU**) for `JavaScript`. This project provides a collection of **customs** and **enhanced** version of methods and/or utilities `ad-hoc` such as `TypeGuards`, `Formats`, `CustomizedErrors`, and many more!
|
|
21
|
+
|
|
22
|
+
## About
|
|
23
|
+
|
|
24
|
+
- I build this project for myself to enhanced my productivity and decided to make it public which might help other developer for re-writing common or mostly used `ad-hoc` utilities for their projects.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```cmd
|
|
29
|
+
npm i @carlsebastian/jsu
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## How To Use
|
|
33
|
+
|
|
34
|
+
- With bundler or path resolver.
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import "@carlsebastian/jsu";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Or via HTML file:
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<html>
|
|
44
|
+
<body>
|
|
45
|
+
<!-- Must always be first or top order of other scripts -->
|
|
46
|
+
<script type="module">
|
|
47
|
+
import "@carlsebastian/jsu";
|
|
48
|
+
</script>
|
|
49
|
+
<script src="your-scripts-path"></script>
|
|
50
|
+
</body>
|
|
51
|
+
</html>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- Without bundler or path resolver.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import "./node_modules/@carlsebastian/jsu/global.js";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Or via HTML file:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<html>
|
|
64
|
+
<body>
|
|
65
|
+
<!-- Must always be first or top order of other scripts -->
|
|
66
|
+
<script type="module" src="./node_modules/@carlsebastian/jsu/global.js"></script>
|
|
67
|
+
<script src="your-scripts-path"></script>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Example
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
// @Required
|
|
76
|
+
// Check #HowToUse section if you didn't check or read it, to avoid confusion.
|
|
77
|
+
import "@carlsebastian/jsu";
|
|
78
|
+
|
|
79
|
+
// #: Creating an anchor element with facebook link.
|
|
80
|
+
const Anchor = DOM.Create.HTMLElement("a", {
|
|
81
|
+
// -- Pre-defined properties --
|
|
82
|
+
ClassNames: ["link", "fb-link"], // Can also be a single class token by provided a string value.
|
|
83
|
+
Id: "link-fb", // Unique identified (id).
|
|
84
|
+
Text: "Facebook Link", // textContent.
|
|
85
|
+
// Style property with CSSStyleDeclaration intellisense.
|
|
86
|
+
Styles: {
|
|
87
|
+
all: "unset",
|
|
88
|
+
backgroundColor: "#153499",
|
|
89
|
+
color: "#fff",
|
|
90
|
+
padding: "10px 15px",
|
|
91
|
+
cursor: "pointer"
|
|
92
|
+
}
|
|
93
|
+
// -- Other / Customized properties --
|
|
94
|
+
href: "https://www.facebook.com/" // { [OtherAttr: string]: any }
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// #: Mount or display it at <body> of html document.
|
|
98
|
+
const B = DOM.Select("body"); // <body>...</body>
|
|
99
|
+
DOM.Mount(B, Anchor); // Now visible to document contents or user's view.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Source Code / Repository
|
|
103
|
+
|
|
104
|
+
- [Github - Sebastian-Carl/JSU](https://github.com/Sebastian-Carl/JSU)
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
- [Apache 2.0](http://www.apache.org/licenses/)
|
|
109
|
+
|
|
110
|
+
## Navigate To
|
|
111
|
+
|
|
112
|
+
- [APIs](./src/docs/api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
package/global.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carlsebastian/jsu",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A ready-to-use JavaScripts custom utilities such as types validations, formats validations, formatter, and many more!",
|
|
5
5
|
"main": "./global.js",
|
|
6
6
|
"types": "./src/types/global.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
9
|
-
"global.js"
|
|
10
|
-
"tsconfig.json"
|
|
9
|
+
"global.js"
|
|
11
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./global.js",
|
|
14
|
+
"types": "./src/types/global.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./custom": {
|
|
17
|
+
"require": "./src/utils/custom/custom.js",
|
|
18
|
+
"types": "./src/types/custom/custom.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./custom/error": {
|
|
21
|
+
"require": "./src/utils/custom/error/error.js",
|
|
22
|
+
"types": "./src/types/custom/error/error.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./dom": {
|
|
25
|
+
"require": "./src/utils/dom/dom.js",
|
|
26
|
+
"types": "./src/types/dom/dom.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./primitives": {
|
|
29
|
+
"require": "./src/utils/primitives/primitives.js",
|
|
30
|
+
"types": "./src/types/primitives/primitives.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./storage": {
|
|
33
|
+
"require": "./src/utils/storage/storage.js",
|
|
34
|
+
"types": "./src/types/storage/storage.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./variables": {
|
|
37
|
+
"require": "./src/utils/variables.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
12
40
|
"scripts": {
|
|
13
41
|
"dev": "node ./src/index.js"
|
|
14
42
|
},
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# JSU - APIs
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - APIs](#jsu---apis)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [About](#about)
|
|
8
|
+
- [API List](#api-list)
|
|
9
|
+
- [Navigate To](#navigate-to)
|
|
10
|
+
|
|
11
|
+
## About
|
|
12
|
+
|
|
13
|
+
- **JSU**'s APIs are where you every available customized and enhanced collection of utilities such as customized `ErrorConstructors`, `CustomGenerator`, `GuardTypes`, and more! This provides a ready-to-use ***utilities*** or ***objects*** for you to use on your projects, this covers the time-cost on re-creating or writing utilities that are mostly you used throughout your projects.
|
|
14
|
+
|
|
15
|
+
## API List
|
|
16
|
+
|
|
17
|
+
- [Custom API](../custom/custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
18
|
+
- [ERROR API](../custom/error/error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
19
|
+
|
|
20
|
+
## Navigate To
|
|
21
|
+
|
|
22
|
+
- [JSU - README](../../../README.MD) - *JSU Homepage Documentation.*
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# JSU - Custom API
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - Custom API](#jsu---custom-api)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [About](#about)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Properties](#properties)
|
|
10
|
+
- [Navigate To](#navigate-to)
|
|
11
|
+
|
|
12
|
+
## About
|
|
13
|
+
|
|
14
|
+
- Provides and handles the attachment of available customized `ad-hoc` and/or `objects` from your projects runtime.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
// Loads all available JSU APIs from your project's runtime.
|
|
20
|
+
import "@carlsebastian/jsu";
|
|
21
|
+
|
|
22
|
+
// Only loads the Custom API of JSU from your project's runtime.
|
|
23
|
+
import "@carlsebastian/jsu/custom";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Properties
|
|
27
|
+
|
|
28
|
+
- [Clamp()](./utils/clamp.md) - *Mutates the given numerical value within the given **minimum** and **maximum** range.*
|
|
29
|
+
- [ConstructorOrTypeOf()](./utils/constructorOrTypeOf.md) - *Retrieves the **constructor** or **type** of the given argument.*
|
|
30
|
+
- [Generator()](./utils/generator/generator.md) - *A customized generator constructor for generating randomized **tokens**, **characters**, and **integer**.*
|
|
31
|
+
- [NameOf()](./utils/nameOf.md) - *Retrieves the **name** property of the given object.*
|
|
32
|
+
|
|
33
|
+
## Navigate To
|
|
34
|
+
|
|
35
|
+
- [APIs](../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
36
|
+
- [ERROR](./error/error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
37
|
+
|
|
38
|
+
- [JSU - README](../../../README.MD) - *JSU Homepage Documentation.*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# JSU - ERROR API - Raise
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Raise](#jsu---error-api---raise)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Properties](#properties)
|
|
9
|
+
- [Navigate To](#navigate-to)
|
|
10
|
+
|
|
11
|
+
## What it does?
|
|
12
|
+
|
|
13
|
+
- It provides a variety of pre-defined collection of static contents meta of every available **Constructors** of **ERROR API** that only requires a few parameters for data to fill in with those contents and throws them through your project's runtime.
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
## Navigate To
|
|
18
|
+
|
|
19
|
+
- [ERROR](../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
20
|
+
- [Raise](../builder/builder.md) - *A collection of customized error class constructors.*
|
|
21
|
+
|
|
22
|
+
- [JSU - README](../../../../../README.MD) - *JSU Homepage Documentation*
|
|
23
|
+
- [APIs](../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
24
|
+
- [Custom](../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# JSU - ERROR API - Constructors
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Constructors](#jsu---error-api---constructors)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Properties](#properties)
|
|
9
|
+
- [Navigate To](#navigate-to)
|
|
10
|
+
|
|
11
|
+
## What it does?
|
|
12
|
+
|
|
13
|
+
- It provides a variety of customized and/or enhanced collection of error classes.
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
- [ArgumentError()](./opts/argumentError.md) - *A custom version of Javascript's **TypeError** for invalid arguments types.*
|
|
18
|
+
- [IndexOutOfBoundsError()](./opts/indexOutOfBounds.md) - *A custom version of Javascript's **RangeError** for index that exceeded the maximum index-bound of an object.*
|
|
19
|
+
- [InvalidPropertyError()](./opts/invalidPropertyError.md) - *A custom error class for objects with invalid property.*
|
|
20
|
+
- [MissingParameterError()](./opts/missingParameterError.md) - *A custom error class for parameters that does not provided a data.*
|
|
21
|
+
- [MissingPropertyError()](./opts/missingPropertyError.md) - *A custom error class for incomplete or missing key-pair data of an object.*
|
|
22
|
+
- [NoSuchElementTagError()](./opts/noSuchElementTagError.md) - *A custom error class for unknown or not qualified **HTMLElement**, **MathMLElement**, **SVGElement** tags.*
|
|
23
|
+
- [NotSupportedError()](./opts/notSupportedError.md) - *A custom error class for not supported **objects**, **methods**, and/or **functions**.*
|
|
24
|
+
- [UnknownPropertyError()](./opts/unknownPropertyError.md) - *A custom error class for unknown property that is trying to be access from an object.*
|
|
25
|
+
|
|
26
|
+
## Navigate To
|
|
27
|
+
|
|
28
|
+
- [ERROR](../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
29
|
+
- [Raise](../builder/builder.md) - *A collection of pre-defined contents builder and raiser of errors.*
|
|
30
|
+
|
|
31
|
+
- [JSU - README](../../../../../README.MD) - *JSU Homepage Documentation*
|
|
32
|
+
- [APIs](../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
33
|
+
- [Custom](../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# JSU - ERROR API - Constructors.ArgumentError()
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Constructors.ArgumentError()](#jsu---error-api---constructorsargumenterror)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Parameter](#parameter)
|
|
9
|
+
- [Properties](#properties)
|
|
10
|
+
- [Example Usage](#example-usage)
|
|
11
|
+
- [Navigate To](#navigate-to)
|
|
12
|
+
|
|
13
|
+
## What it does?
|
|
14
|
+
|
|
15
|
+
- It raises a report on your project's runtime for any arguments type that violates the expected argument type of certain ***functions*** or ***methods***.
|
|
16
|
+
|
|
17
|
+
## Parameter
|
|
18
|
+
|
|
19
|
+
- `meta` - The meta data object of this error.
|
|
20
|
+
- `meta.Message` - The message of this error. ( ***Required*** )
|
|
21
|
+
- `meta.Context` - The meta context object of this error.
|
|
22
|
+
- `meta.Context.Message` - A context message that points the root cause of error.
|
|
23
|
+
- `meta.Context.Emitter` - The source id of an object that is responsible of raising this error.
|
|
24
|
+
- `meta.Args` - A meta argument object of this error to check the reported arguments.
|
|
25
|
+
- `meta.Args.Id` - The reported argument id that cause this error.
|
|
26
|
+
- `meta.Args.ReceivedArgument` - The reported received argument value that triggered this error.
|
|
27
|
+
- `meta.Args.ExpectedArguments` - A list of expected arguments to receive from an argument.
|
|
28
|
+
- `Guide` - A guide for fixing this error.
|
|
29
|
+
|
|
30
|
+
## Properties
|
|
31
|
+
|
|
32
|
+
- `Message` - The message of this error.
|
|
33
|
+
- `Context` - The context object of this error.
|
|
34
|
+
- `Args` - The arguments object of this error.
|
|
35
|
+
- `Guide` - A provided guide for fixing this error.
|
|
36
|
+
- `TimeStamp` - The date & time of when this error has occurred.
|
|
37
|
+
|
|
38
|
+
## Example Usage
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// #: Check and raise an argument error when data is not-a-string type.
|
|
42
|
+
const data = 1;
|
|
43
|
+
const IsStr = typeof data === "string";
|
|
44
|
+
|
|
45
|
+
if (!IsStr)
|
|
46
|
+
throw new ERROR.Constructors.ArgumentError({
|
|
47
|
+
Message: "Received a non-string data!",
|
|
48
|
+
Context: {
|
|
49
|
+
Message: "constant 'data' is a non-string data!",
|
|
50
|
+
Emitter: "foo"
|
|
51
|
+
},
|
|
52
|
+
Args: {
|
|
53
|
+
Id: "data",
|
|
54
|
+
ReceivedArgument: data,
|
|
55
|
+
ExpectedArguments: ["String"]
|
|
56
|
+
},
|
|
57
|
+
Guide: "Ensure to provide a string value from constant 'data'!"
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// [Terminal]: Uncaught ArgumentError ...
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Navigate To
|
|
64
|
+
|
|
65
|
+
- [Error](../../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
66
|
+
- [Constructors](../error.constructor.md) - *A collection of customized error class constructors.*
|
|
67
|
+
- [IndexOutOfBoundsError()](./indexOutOfBounds.md) - *A custom version of Javascript's **RangeError** for index that exceeded the maximum index-bound of an object.*
|
|
68
|
+
- [InvalidPropertyError()](./invalidPropertyError.md) - *A custom error class for objects with invalid property.*
|
|
69
|
+
- [MissingParameterError()](./missingParameterError.md) - *A custom error class for parameters that does not provided a data.*
|
|
70
|
+
- [MissingPropertyError()](./missingPropertyError.md) - *A custom error class for incomplete or missing key-pair data of an object.*
|
|
71
|
+
- [NoSuchElementTagError()](./noSuchElementTagError.md) - *A custom error class for unknown or not qualified **HTMLElement**, **MathMLElement**, **SVGElement** tags.*
|
|
72
|
+
- [NotSupportedError()](./notSupportedError.md) - *A custom error class for not supported **objects**, **methods**, and/or **functions**.*
|
|
73
|
+
- [UnknownPropertyError()](./unknownPropertyError.md) - *A custom error class for unknown property that is trying to be access from an object.*
|
|
74
|
+
- [Raise](../../builder/builder.md) - *A collection of pre-defined contents builder and raiser of errors.*
|
|
75
|
+
|
|
76
|
+
- [JSU - README](../../../../../../README.MD) - *JSU Homepage Documentation.*
|
|
77
|
+
- [APIs](../../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
78
|
+
- [Custom](../../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# JSU - ERROR API - Constructors.IndexOutOfBoundsError()
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Constructors.IndexOutOfBoundsError()](#jsu---error-api---constructorsindexoutofboundserror)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Parameters](#parameters)
|
|
9
|
+
- [Properties](#properties)
|
|
10
|
+
- [Example Usage](#example-usage)
|
|
11
|
+
- [Navigate To](#navigate-to)
|
|
12
|
+
|
|
13
|
+
## What it does?
|
|
14
|
+
|
|
15
|
+
- It raises a report on your project's runtime from an index that exceeded the maximum index-bound of an object list.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
- `meta` - The meta data object of this error.
|
|
20
|
+
- `meta.Message` - The message of this error. ( ***Required*** )
|
|
21
|
+
- `meta.Context` - The meta context object of this error.
|
|
22
|
+
- `meta.Context.Message` - A context message that points the root cause of error.
|
|
23
|
+
- `meta.Context.Emitter` - The source id of an object that is responsible of raising this error.
|
|
24
|
+
- `meta.Args` - A meta argument object of this error to check the reported arguments.
|
|
25
|
+
- `meta.Args.Id` - The reported argument id that cause this error.
|
|
26
|
+
- `meta.Args.Index` - The index the falls or exceeds the maximum-bound of the object list.
|
|
27
|
+
- `meta.Args.MaxBound` - The maximum-bound of index can be at object list.
|
|
28
|
+
- `Guide` - A guide for fixing this error.
|
|
29
|
+
|
|
30
|
+
## Properties
|
|
31
|
+
|
|
32
|
+
- `Message` - The message of this error.
|
|
33
|
+
- `Context` - The context object of this error.
|
|
34
|
+
- `Args` - The arguments object of this error.
|
|
35
|
+
- `Guide` - A provided guide for fixing this error.
|
|
36
|
+
- `TimeStamp` - The date & time of when this error has occurred.
|
|
37
|
+
|
|
38
|
+
## Example Usage
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
const Pos = 5;
|
|
42
|
+
const Nums = [1, 2, 3, 4, 5];
|
|
43
|
+
|
|
44
|
+
if (Pos > (Nums.length - 1))
|
|
45
|
+
throw new ERROR.Constructors.IndexOutOfBounds({
|
|
46
|
+
Message: "A out-of-bounds index is found!",
|
|
47
|
+
Context: {
|
|
48
|
+
Message: `Index '${Pos}' has exceeded the maximum bound of Nums[]`,
|
|
49
|
+
Emitter: "foo"
|
|
50
|
+
},
|
|
51
|
+
Args: {
|
|
52
|
+
Id: "Pos",
|
|
53
|
+
Index: Pos,
|
|
54
|
+
MaxBound: (Nums.length - 1)
|
|
55
|
+
},
|
|
56
|
+
Guide: `Ensure to provide a index that is within the maximum bound of an object list.`
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// #: Uncaught IndexOutOfBoundsError: ...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Navigate To
|
|
63
|
+
|
|
64
|
+
- [Error](../../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
65
|
+
- [Constructors](../error.constructor.md) - *A collection of customized error class constructors.*
|
|
66
|
+
- [ArgumentError()](./argumentError.md) - *A custom version of Javascript's **TypeError** for invalid arguments types.*
|
|
67
|
+
- [InvalidPropertyError()](./invalidPropertyError.md) - *A custom error class for objects with invalid property.*
|
|
68
|
+
- [MissingParameterError()](./missingParameterError.md) - *A custom error class for parameters that does not provided a data.*
|
|
69
|
+
- [MissingPropertyError()](./missingPropertyError.md) - *A custom error class for incomplete or missing key-pair data of an object.*
|
|
70
|
+
- [NoSuchElementTagError()](./noSuchElementTagError.md) - *A custom error class for unknown or not qualified **HTMLElement**, **MathMLElement**, **SVGElement** tags.*
|
|
71
|
+
- [NotSupportedError()](./notSupportedError.md) - *A custom error class for not supported **objects**, **methods**, and/or **functions**.*
|
|
72
|
+
- [UnknownPropertyError()](./unknownPropertyError.md) - *A custom error class for unknown property that is trying to be access from an object.*
|
|
73
|
+
- [Raise](../../builder/builder.md) - *A collection of pre-defined contents builder and raiser of errors.*
|
|
74
|
+
|
|
75
|
+
- [JSU - README](../../../../../../README.MD) - *JSU Homepage Documentation.*
|
|
76
|
+
- [APIs](../../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
77
|
+
- [Custom](../../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# JSU - ERROR API - Constructors.InvalidPropertyError()
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Constructors.InvalidPropertyError()](#jsu---error-api---constructorsinvalidpropertyerror)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Parameter](#parameter)
|
|
9
|
+
- [Properties](#properties)
|
|
10
|
+
- [Example Usage](#example-usage)
|
|
11
|
+
- [Navigate To](#navigate-to)
|
|
12
|
+
|
|
13
|
+
## What it does?
|
|
14
|
+
|
|
15
|
+
- It raises a report on your project's runtime upon a certain object that contains a invalid property (key-pair) data at certain object found. This is useful for strict object structure.
|
|
16
|
+
|
|
17
|
+
## Parameter
|
|
18
|
+
|
|
19
|
+
- `meta` - The meta data object of this error.
|
|
20
|
+
- `meta.Message` - The message of this error. ( ***Required*** )
|
|
21
|
+
- `meta.Context` - The meta context object of this error.
|
|
22
|
+
- `meta.Context.Message` - A context message that points the root cause of error.
|
|
23
|
+
- `meta.Context.Emitter` - The source id of an object that is responsible of raising this error.
|
|
24
|
+
- `meta.Args` - A meta argument object of this error to check the reported arguments.
|
|
25
|
+
- `meta.Args.Id` - The reported argument id that cause this error.
|
|
26
|
+
- `meta.Args.PropertyId` - The invalid property that has been found at argument id.`
|
|
27
|
+
- `Guide` - A guide for fixing this error.
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
- `Message` - The message of this error.
|
|
32
|
+
- `Context` - The context object of this error.
|
|
33
|
+
- `Args` - The arguments object of this error.
|
|
34
|
+
- `Guide` - A provided guide for fixing this error.
|
|
35
|
+
- `TimeStamp` - A record of date & time of when this error has occurred.
|
|
36
|
+
|
|
37
|
+
## Example Usage
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const User = {
|
|
41
|
+
Id: 0,
|
|
42
|
+
Name: "Carl Aaron ...",
|
|
43
|
+
Address: "...",
|
|
44
|
+
Age: 21,
|
|
45
|
+
Greet() => { ... },
|
|
46
|
+
T() => { ... }
|
|
47
|
+
}
|
|
48
|
+
const UserProps = ["Id", "Name", "Address", "Age", "Greed"];
|
|
49
|
+
for (const prop of Object.keys(User)) {
|
|
50
|
+
if (!UserProps.includes(prop))
|
|
51
|
+
throw new ERROR.Constructors.InvalidPropertyError({
|
|
52
|
+
Message: "A invalid property is found at user object!",
|
|
53
|
+
Context: {
|
|
54
|
+
Message: `User.${prop}: Property is unknown or not part of user's object properties.`
|
|
55
|
+
Emitter: "foo"
|
|
56
|
+
},
|
|
57
|
+
Args: {
|
|
58
|
+
Id: "User",
|
|
59
|
+
PropertyId: prop
|
|
60
|
+
},
|
|
61
|
+
Guide: "Ensure to not provide or include a unknown property from 'User' object!"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// #: Uncaught InvalidPropertyError: ...
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Navigate To
|
|
69
|
+
|
|
70
|
+
- [Error](../../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
71
|
+
- [Constructors](../error.constructor.md) - *A collection of customized error class constructors.*
|
|
72
|
+
- [ArgumentError()](./argumentError.md) - *A custom version of Javascript's **TypeError** for invalid arguments types.*
|
|
73
|
+
- [IndexOutOfBoundsError()](./indexOutOfBounds.md) - *A custom version of Javascript's **RangeError** for index that exceeded the maximum index-bound of an object.*
|
|
74
|
+
- [MissingParameterError()](./missingParameterError.md) - *A custom error class for parameters that does not provided a data.*
|
|
75
|
+
- [MissingPropertyError()](./missingPropertyError.md) - *A custom error class for incomplete or missing key-pair data of an object.*
|
|
76
|
+
- [NoSuchElementTagError()](./noSuchElementTagError.md) - *A custom error class for unknown or not qualified **HTMLElement**, **MathMLElement**, **SVGElement** tags.*
|
|
77
|
+
- [NotSupportedError()](./notSupportedError.md) - *A custom error class for not supported **objects**, **methods**, and/or **functions**.*
|
|
78
|
+
- [UnknownPropertyError()](./unknownPropertyError.md) - *A custom error class for unknown property that is trying to be access from an object.*
|
|
79
|
+
- [Raise](../../builder/builder.md) - *A collection of pre-defined contents builder and raiser of errors.*
|
|
80
|
+
|
|
81
|
+
- [JSU - README](../../../../../../README.MD) - *JSU Homepage Documentation.*
|
|
82
|
+
- [APIs](../../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
83
|
+
- [Custom](../../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# JSU - ERROR API - Constructors.MissingParameterError()
|
|
2
|
+
|
|
3
|
+
## Table Of Contents
|
|
4
|
+
|
|
5
|
+
- [JSU - ERROR API - Constructors.MissingParameterError()](#jsu---error-api---constructorsmissingparametererror)
|
|
6
|
+
- [Table Of Contents](#table-of-contents)
|
|
7
|
+
- [What it does?](#what-it-does)
|
|
8
|
+
- [Parameter](#parameter)
|
|
9
|
+
- [Properties](#properties)
|
|
10
|
+
- [Example Usage](#example-usage)
|
|
11
|
+
- [Navigate To](#navigate-to)
|
|
12
|
+
|
|
13
|
+
## What it does?
|
|
14
|
+
|
|
15
|
+
- It raises a report on your project's runtime about a missing parameter data from a certain **_function_** or **_method_**.
|
|
16
|
+
|
|
17
|
+
## Parameter
|
|
18
|
+
|
|
19
|
+
- `meta` - The meta data object of this error.
|
|
20
|
+
- `meta.Message` - The message of this error. ( **_Required_** )
|
|
21
|
+
- `meta.Context` - The meta context object of this error.
|
|
22
|
+
- `meta.Context.Message` - A context message that points the root cause of error.
|
|
23
|
+
- `meta.Context.Emitter` - The source id of an object that is responsible of raising this error.
|
|
24
|
+
- `meta.Args` - A meta argument object of this error to check the reported arguments.
|
|
25
|
+
- `meta.Args.Id` - The reported argument id that cause this error.
|
|
26
|
+
- `meta.Args.Value` - The current state value of missing parameter.
|
|
27
|
+
- `Guide` - A guide for fixing this error.
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
- `Message` - The message of this error.
|
|
32
|
+
- `Context` - The context object of this error.
|
|
33
|
+
- `Args` - The arguments object of this error.
|
|
34
|
+
- `Guide` - A provided guide for fixing this error.
|
|
35
|
+
- `TimeStamp` - A record of date & time of when this error has occurred.
|
|
36
|
+
|
|
37
|
+
## Example Usage
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
function DoSomething(arg) {
|
|
41
|
+
if (arg === null || arg === undefined)
|
|
42
|
+
throw new ERROR.Constructors.MissingParameterError({
|
|
43
|
+
Message: `A missing parameter is found at DoSomething()!`,
|
|
44
|
+
Context: {
|
|
45
|
+
Message: `DoSomething(arg: ${arg}): Expects argument to be provided!`,
|
|
46
|
+
Emitter: "DoSomething"
|
|
47
|
+
},
|
|
48
|
+
Args: {
|
|
49
|
+
Id: "arg",
|
|
50
|
+
Value: arg
|
|
51
|
+
},
|
|
52
|
+
Guide: "Ensure to provide the parameter argument DoSomething()!"
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return arg++;
|
|
56
|
+
}
|
|
57
|
+
DoSomething(); // #: Uncaught MissingParameterError: ...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Navigate To
|
|
61
|
+
|
|
62
|
+
- [Error](../../error.md) - *An API that provides a collection of customized and/or enhanced error classes.*
|
|
63
|
+
- [Constructors](../error.constructor.md) - *A collection of customized error class constructors.*
|
|
64
|
+
- [ArgumentError()](./argumentError.md) - *A custom version of Javascript's **TypeError** for invalid arguments types.*
|
|
65
|
+
- [IndexOutOfBoundsError()](./indexOutOfBounds.md) - *A custom version of Javascript's **RangeError** for index that exceeded the maximum index-bound of an object.*
|
|
66
|
+
- [InvalidPropertyError()](./invalidPropertyError.md) - *A custom error class for objects with invalid property.*
|
|
67
|
+
- [MissingPropertyError()](./missingPropertyError.md) - *A custom error class for incomplete or missing key-pair data of an object.*
|
|
68
|
+
- [NoSuchElementTagError()](./noSuchElementTagError.md) - *A custom error class for unknown or not qualified **HTMLElement**, **MathMLElement**, **SVGElement** tags.*
|
|
69
|
+
- [NotSupportedError()](./notSupportedError.md) - *A custom error class for not supported **objects**, **methods**, and/or **functions**.*
|
|
70
|
+
- [UnknownPropertyError()](./unknownPropertyError.md) - *A custom error class for unknown property that is trying to be access from an object.*
|
|
71
|
+
- [Raise](../../builder/builder.md) - *A collection of pre-defined contents builder and raiser of errors.*
|
|
72
|
+
|
|
73
|
+
- [JSU - README](../../../../../../README.MD) - *JSU Homepage Documentation.*
|
|
74
|
+
- [APIs](../../../../api/api.md) - *A complete collection list of available APIs of ***JSU***.*
|
|
75
|
+
- [Custom](../../../custom.md) - *An API that provides a collection of customized and/or enhanced utilities or objects.*
|