cno-bedrock 0.0.4 → 0.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/CHANGELOG.md +38 -0
- package/package.json +116 -116
- package/scripts/generate-docs.js +0 -0
- package/src/cno-assert.js +222 -15
- package/src/cno-assert.test.js +331 -0
- package/src/cno-base64.js +230 -0
- package/src/cno-base64.test.js +262 -0
- package/src/cno-bytes.js +387 -0
- package/src/cno-bytes.test.js +222 -0
- package/src/cno-constants.js +121 -0
- package/src/cno-files.js +2135 -0
- package/src/cno-files.test.js +939 -0
- package/src/cno-math.js +407 -0
- package/src/cno-math.test.js +249 -0
- package/src/cno-noop.js +6 -2
- package/src/cno-options.js +73 -4
- package/src/cno-options.test.js +65 -0
- package/src/cno-sha2-256.js +831 -0
- package/src/cno-sha2-256.test.js +697 -0
- package/src/cno-test-matrix.js +709 -0
- package/src/cno-test-matrix.test.js +199 -0
- package/src/cno-timed-cache-map.js +103 -0
- package/src/cno-timed-cache-map.test.js +113 -0
- package/src/cno-tree.js +365 -0
- package/src/cno-tree.test.js +147 -0
- package/src/cno-utility.js +545 -2
- package/src/cno-utility.test.js +276 -0
- package/src/cno-vector.js +1053 -0
- package/src/cno-vector.test.js +523 -0
- package/src/lib.js +5 -138
- package/src/lib.test.js +19 -7
- package/src/stream-test.js +116 -0
- package/test/big-lorem.txt +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.1.0](https://github.com/Anadian/cno-bedrock/compare/v0.0.5...v0.1.0) (2026-11-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Big additions including cno-files, cno-test* and plenty more cno-utility functions. ([be656e7](https://github.com/Anadian/cno-bedrock/commit/be656e7ecf2168bbee571467be387ee6b8673797))
|
|
11
|
+
* Finally got cno-sha2-256 working. ([d0567b2](https://github.com/Anadian/cno-bedrock/commit/d0567b219c2deea2d7dd59c95f4b2c0b978541c0))
|
|
12
|
+
* TimedCacheMap ([6622f99](https://github.com/Anadian/cno-bedrock/commit/6622f9979d881d0015fb672bbb28eab1a90fc352))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* Exports for previous commit. ([1aa8ab2](https://github.com/Anadian/cno-bedrock/commit/1aa8ab2054ce82331c07e5d73b224b8eb496ab5b))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Refactoring
|
|
21
|
+
|
|
22
|
+
* Moved isStrictlyNotEqual and isNullOrEmpty to utility to clean up lib.js ([ca740a7](https://github.com/Anadian/cno-bedrock/commit/ca740a7e6601c00b5806504b22facc887e74cd73))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Tests
|
|
26
|
+
|
|
27
|
+
* Basic usage test for `cno-tree`. ([e1ff4af](https://github.com/Anadian/cno-bedrock/commit/e1ff4af076826dd3f3a3a41d5ed7e412b87cbbb5))
|
|
28
|
+
* Completed tests and coverage for `cno-math`. ([17e37e4](https://github.com/Anadian/cno-bedrock/commit/17e37e4ae7a7dfc529a34a2e937e88f04d9cc14d))
|
|
29
|
+
* Tests for `cno-vector.js` ([0cda317](https://github.com/Anadian/cno-bedrock/commit/0cda317157cd33e16139e1d55e46c55ac69c598f))
|
|
30
|
+
|
|
31
|
+
### [0.0.5](https://github.com/Anadian/cno-bedrock/compare/v0.0.4...v0.0.5) (2025-11-08)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **assert:** Add assertIsMap. ([9bc952b](https://github.com/Anadian/cno-bedrock/commit/9bc952b1b82580a496bab38f44e6514547614cb8))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Tests
|
|
40
|
+
|
|
41
|
+
* Added test for assertIsMap. ([af82fb3](https://github.com/Anadian/cno-bedrock/commit/af82fb3831a96afd64c241db7ea894b2d20a48d2))
|
|
42
|
+
|
|
5
43
|
### [0.0.4](https://github.com/Anadian/cno-bedrock/compare/v0.0.3...v0.0.4) (2025-11-07)
|
|
6
44
|
|
|
7
45
|
|
package/package.json
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
2
|
+
"name": "cno-bedrock",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Micropackage: a test bed for various small pieces of reusable code.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Anadian/cno-bedrock.git"
|
|
8
|
+
},
|
|
9
|
+
"author": "Anadian",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/lib.js"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Anadian/cno-bedrock/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Anadian/cno-bedrock#readme",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"cno",
|
|
24
|
+
"framework",
|
|
25
|
+
"minimal",
|
|
26
|
+
"essential",
|
|
27
|
+
"micro",
|
|
28
|
+
"micropackage",
|
|
29
|
+
"libre",
|
|
30
|
+
"free",
|
|
31
|
+
"open",
|
|
32
|
+
"mit"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "node --test ./src/*.test.js",
|
|
36
|
+
"coverage": "c8 pnpm test",
|
|
37
|
+
"coverage-report": "c8 report -r=text-lcov > coverage/lcov.txt",
|
|
38
|
+
"do-ci": "pnpm coverage && pnpm coverage-report",
|
|
39
|
+
"lint": "eslint ./src/main.js",
|
|
40
|
+
"generate-docs": "scripts/generate-docs.js",
|
|
41
|
+
"update-config": "hjson -j ci/github-actions.hjson | json2yaml -o .github/workflows/ci.yml && git change 'chore: Updated GitHub Actions.'",
|
|
42
|
+
"update-deps": "npm-check-updates -u",
|
|
43
|
+
"release": "standard-version",
|
|
44
|
+
"publish-release": "git push --follow-tags origin main && pnpm publish"
|
|
45
|
+
},
|
|
46
|
+
"standard-version": {
|
|
47
|
+
"types": [
|
|
48
|
+
{
|
|
49
|
+
"type": "build",
|
|
50
|
+
"section": "Build",
|
|
51
|
+
"hidden": false
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "ci",
|
|
55
|
+
"section": "Continuous Integration",
|
|
56
|
+
"hidden": false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "chore",
|
|
60
|
+
"section": "Chores",
|
|
61
|
+
"hidden": false
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "docs",
|
|
65
|
+
"section": "Documentation",
|
|
66
|
+
"hidden": false
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "feat",
|
|
70
|
+
"section": "Features",
|
|
71
|
+
"hidden": false
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "fix",
|
|
75
|
+
"section": "Bug Fixes",
|
|
76
|
+
"hidden": false
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "perf",
|
|
80
|
+
"section": "Performance",
|
|
81
|
+
"hidden": false
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"type": "refactor",
|
|
85
|
+
"section": "Refactoring",
|
|
86
|
+
"hidden": false
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"type": "style",
|
|
90
|
+
"section": "Code Style",
|
|
91
|
+
"hidden": false
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"type": "test",
|
|
95
|
+
"section": "Tests",
|
|
96
|
+
"hidden": false
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"bin": {
|
|
101
|
+
"cno-bedrock": "./src/cli.js"
|
|
102
|
+
},
|
|
103
|
+
"devDependencies": {
|
|
104
|
+
"c8": "^12.0.0",
|
|
105
|
+
"eslint": "^10.8.1",
|
|
106
|
+
"extract-documentation-comments": "^0.4.2",
|
|
107
|
+
"hjson": "^3.2.2",
|
|
108
|
+
"npm-check-updates": "^23.0.2",
|
|
109
|
+
"shelljs": "^0.10.0",
|
|
110
|
+
"standard-version": "^9.5.0"
|
|
111
|
+
},
|
|
112
|
+
"dependencies": {
|
|
113
|
+
"lodash": "^4.18.1",
|
|
114
|
+
"mathjs": "^15.2.0",
|
|
115
|
+
"nanoid": "^6.0.1"
|
|
116
|
+
}
|
|
117
|
+
}
|
package/scripts/generate-docs.js
CHANGED
|
File without changes
|
package/src/cno-assert.js
CHANGED
|
@@ -41,6 +41,157 @@ const FILENAME = 'cno-assert.js';
|
|
|
41
41
|
|
|
42
42
|
//# Global Variables
|
|
43
43
|
/**## Functions*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
### assertTruthy
|
|
47
|
+
> Throws if `value` isn't truthy.
|
|
48
|
+
|
|
49
|
+
#### Parametres
|
|
50
|
+
| name | type | description |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| actual | any | The actual value. |
|
|
53
|
+
|
|
54
|
+
#### Throws
|
|
55
|
+
| code | type | condition |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| 'ERR_ASSERTION_SAMETYPE' | AssertionError | Thrown if `!value`. |
|
|
58
|
+
|
|
59
|
+
#### History
|
|
60
|
+
| version | change |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| 0.0.3 | WIP |
|
|
63
|
+
*/
|
|
64
|
+
export function assertTruthy( actual ){
|
|
65
|
+
// Constants
|
|
66
|
+
const FUNCTION_NAME = 'assertTruthy';
|
|
67
|
+
// Variables
|
|
68
|
+
var return_error = null;
|
|
69
|
+
var message = '';
|
|
70
|
+
// Function
|
|
71
|
+
try{
|
|
72
|
+
AssertNS( actual );
|
|
73
|
+
} catch( error ){
|
|
74
|
+
//if( typeof(actual) !== typeof(expected) ){
|
|
75
|
+
message = `'actual' (${actual}) is not truthy.`;
|
|
76
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: true, operator: 'Truthy' } );
|
|
77
|
+
return_error.code += '_TRUTHY';
|
|
78
|
+
return_error.cause = error;
|
|
79
|
+
annotateThis.call( return_error );
|
|
80
|
+
throw return_error;
|
|
81
|
+
}
|
|
82
|
+
} // assertTruthy
|
|
83
|
+
/**
|
|
84
|
+
### assertNumber
|
|
85
|
+
> Throws if `value` isn't a number.
|
|
86
|
+
|
|
87
|
+
#### Parametres
|
|
88
|
+
| name | type | description |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| actual | any | The actual value. |
|
|
91
|
+
|
|
92
|
+
#### Throws
|
|
93
|
+
| code | type | condition |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| 'ERR_ASSERTION_SAMETYPE' | AssertionError | Thrown if `typeof(actual) != 'number'`. |
|
|
96
|
+
|
|
97
|
+
#### History
|
|
98
|
+
| version | change |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| 0.0.3 | WIP |
|
|
101
|
+
*/
|
|
102
|
+
export function assertNumber( actual ){
|
|
103
|
+
// Constants
|
|
104
|
+
const FUNCTION_NAME = 'assertNumber';
|
|
105
|
+
// Variables
|
|
106
|
+
var return_error = null;
|
|
107
|
+
var message = '';
|
|
108
|
+
// Function
|
|
109
|
+
try{
|
|
110
|
+
AssertNS.deepStrictEqual( typeof(actual), 'number' );
|
|
111
|
+
} catch( error ){
|
|
112
|
+
//if( typeof(actual) !== typeof(expected) ){
|
|
113
|
+
message = `'actual' (${actual}) is not number.`;
|
|
114
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: true, operator: 'Number' } );
|
|
115
|
+
return_error.code += '_NUMBER';
|
|
116
|
+
return_error.cause = error;
|
|
117
|
+
annotateThis.call( return_error );
|
|
118
|
+
throw return_error;
|
|
119
|
+
}
|
|
120
|
+
} // assertNumber
|
|
121
|
+
/**
|
|
122
|
+
### assertLessThan
|
|
123
|
+
> Throws if actual is not less than expected or if either isn't a number.
|
|
124
|
+
|
|
125
|
+
#### Parametres
|
|
126
|
+
| name | type | description |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| actual | any | The actual value. |
|
|
129
|
+
| expected | any | The expected value. |
|
|
130
|
+
|
|
131
|
+
#### Throws
|
|
132
|
+
| code | type | condition |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| 'ERR_ASSERTION_SAMETYPE' | AssertionError | Thrown if `actual >= expected`. |
|
|
135
|
+
|
|
136
|
+
#### History
|
|
137
|
+
| version | change |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| 0.0.3 | WIP |
|
|
140
|
+
*/
|
|
141
|
+
export function assertLessThan( actual, expected ){
|
|
142
|
+
// Constants
|
|
143
|
+
const FUNCTION_NAME = 'assertLessThan';
|
|
144
|
+
// Variables
|
|
145
|
+
var return_error = null;
|
|
146
|
+
var message = '';
|
|
147
|
+
// Function
|
|
148
|
+
assertNumber( actual );
|
|
149
|
+
assertNumber( expected );
|
|
150
|
+
if( actual >= expected ){
|
|
151
|
+
message = `'actual' (${actual}) is not less than 'expected' (${expected}).`;
|
|
152
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'LessThan' } );
|
|
153
|
+
return_error.code += '_LESSTHAN';
|
|
154
|
+
annotateThis.call( return_error );
|
|
155
|
+
throw return_error;
|
|
156
|
+
}
|
|
157
|
+
} // assertLessThan
|
|
158
|
+
/**
|
|
159
|
+
### assertGreaterThan
|
|
160
|
+
> Throws if actual is not greater than expected or if either isn't a number.
|
|
161
|
+
|
|
162
|
+
#### Parametres
|
|
163
|
+
| name | type | description |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| actual | any | The actual value. |
|
|
166
|
+
| expected | any | The expected value. |
|
|
167
|
+
|
|
168
|
+
#### Throws
|
|
169
|
+
| code | type | condition |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| 'ERR_ASSERTION_SAMETYPE' | AssertionError | Thrown if `actual <= expected`. |
|
|
172
|
+
|
|
173
|
+
#### History
|
|
174
|
+
| version | change |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| 0.0.3 | WIP |
|
|
177
|
+
*/
|
|
178
|
+
export function assertGreaterThan( actual, expected ){
|
|
179
|
+
// Constants
|
|
180
|
+
const FUNCTION_NAME = 'assertGreaterThan';
|
|
181
|
+
// Variables
|
|
182
|
+
var return_error = null;
|
|
183
|
+
var message = '';
|
|
184
|
+
// Function
|
|
185
|
+
assertNumber( actual );
|
|
186
|
+
assertNumber( expected );
|
|
187
|
+
if( actual <= expected ){
|
|
188
|
+
message = `'actual' (${actual}) is not greater than 'expected' (${expected}).`;
|
|
189
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'GreaterThan' } );
|
|
190
|
+
return_error.code += '_GREATERTHAN';
|
|
191
|
+
annotateThis.call( return_error );
|
|
192
|
+
throw return_error;
|
|
193
|
+
}
|
|
194
|
+
} // assertGreaterThan
|
|
44
195
|
/**
|
|
45
196
|
### assertSameType
|
|
46
197
|
> Throws if actual's type is not the same as expected's, according to a strict `typeof` comparison.
|
|
@@ -62,7 +213,7 @@ const FILENAME = 'cno-assert.js';
|
|
|
62
213
|
| 0.0.3 | Removed message parametre. |
|
|
63
214
|
| 0.0.1 | WIP |
|
|
64
215
|
*/
|
|
65
|
-
function assertSameType( actual, expected ){
|
|
216
|
+
export function assertSameType( actual, expected ){
|
|
66
217
|
// Constants
|
|
67
218
|
const FUNCTION_NAME = 'assertSameType';
|
|
68
219
|
// Variables
|
|
@@ -98,7 +249,7 @@ function assertSameType( actual, expected ){
|
|
|
98
249
|
| 0.0.3 | Redone |
|
|
99
250
|
| 0.0.1 | WIP |
|
|
100
251
|
*/
|
|
101
|
-
function assertNonstrictNotEqual( actual, expected ){
|
|
252
|
+
export function assertNonstrictNotEqual( actual, expected ){
|
|
102
253
|
// Constants
|
|
103
254
|
const FUNCTION_NAME = 'assertNonstrictNotEqual';
|
|
104
255
|
// Variables
|
|
@@ -115,7 +266,7 @@ function assertNonstrictNotEqual( actual, expected ){
|
|
|
115
266
|
} // assertNonstrictNotEqual
|
|
116
267
|
/**
|
|
117
268
|
### assertIsEmpty
|
|
118
|
-
> Throws if `actual` is not empty.
|
|
269
|
+
> Throws if `actual` is not empty via [`_.isEmpty`](https://lodash.com/docs/4.17.21#isEmpty).
|
|
119
270
|
|
|
120
271
|
#### Parametres
|
|
121
272
|
| name | type | description |
|
|
@@ -130,12 +281,13 @@ function assertNonstrictNotEqual( actual, expected ){
|
|
|
130
281
|
#### History
|
|
131
282
|
| version | change |
|
|
132
283
|
| --- | --- |
|
|
284
|
+
| 0.1.1 | Uses lodash's `isEmpty` function. |
|
|
133
285
|
| 0.0.3 | WIP |
|
|
134
286
|
*/
|
|
135
|
-
function assertIsEmpty( actual ){
|
|
287
|
+
export function assertIsEmpty( actual ){
|
|
136
288
|
var return_error = null;
|
|
137
|
-
if(
|
|
138
|
-
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual})
|
|
289
|
+
if( _.isEmpty( actual ) !== true ){
|
|
290
|
+
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual}) is not empty.`, actual: actual, operator: 'IsEmpty' } );
|
|
139
291
|
return_error.code += '_ISEMPTY';
|
|
140
292
|
throw return_error;
|
|
141
293
|
}
|
|
@@ -159,7 +311,7 @@ function assertIsEmpty( actual ){
|
|
|
159
311
|
| --- | --- |
|
|
160
312
|
| 0.0.3 | WIP |
|
|
161
313
|
*/
|
|
162
|
-
function assertIsNullOrUndefined( actual ){
|
|
314
|
+
export function assertIsNullOrUndefined( actual ){
|
|
163
315
|
var return_error = null;
|
|
164
316
|
if( actual !== null && actual !== undefined ){
|
|
165
317
|
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual}) is neither null nor undefined.`, actual: actual, operator: 'IsNullOrUndefined' } );
|
|
@@ -186,7 +338,7 @@ function assertIsNullOrUndefined( actual ){
|
|
|
186
338
|
| --- | --- |
|
|
187
339
|
| 0.0.3 | WIP |
|
|
188
340
|
*/
|
|
189
|
-
function assertIsNullOrEmpty( actual ){
|
|
341
|
+
export function assertIsNullOrEmpty( actual ){
|
|
190
342
|
// Constants
|
|
191
343
|
const FUNCTION_NAME = 'assertIsNullOrEmpty';
|
|
192
344
|
// Variables
|
|
@@ -233,7 +385,7 @@ function assertIsNullOrEmpty( actual ){
|
|
|
233
385
|
#### Throws
|
|
234
386
|
| code | type | condition |
|
|
235
387
|
| --- | --- | --- |
|
|
236
|
-
| 'ERR_ASSERTION_STRICTLYNOTEQUAL' | AssertionError | Thrown if actual is not strictly-not-equal (
|
|
388
|
+
| 'ERR_ASSERTION_STRICTLYNOTEQUAL' | AssertionError | Thrown if actual is not strictly-not-equal (` != `) && typeof((`) === typeof(`)) to expected. |
|
|
237
389
|
|
|
238
390
|
#### History
|
|
239
391
|
| version | change |
|
|
@@ -241,7 +393,7 @@ function assertIsNullOrEmpty( actual ){
|
|
|
241
393
|
| 0.0.3 | Removed message parametre. |
|
|
242
394
|
| 0.0.1 | WIP |
|
|
243
395
|
*/
|
|
244
|
-
function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
396
|
+
export function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
245
397
|
// Constants
|
|
246
398
|
const FUNCTION_NAME = 'assertStrictlyNotEqual';
|
|
247
399
|
// Variables
|
|
@@ -291,7 +443,7 @@ function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
|
291
443
|
| 0.0.3 | Removed message parametre. |
|
|
292
444
|
| 0.0.1 | WIP |
|
|
293
445
|
*/
|
|
294
|
-
function assertInstanceof( actual, expected ){
|
|
446
|
+
export function assertInstanceof( actual, expected ){
|
|
295
447
|
// Constants
|
|
296
448
|
const FUNCTION_NAME = 'assertInstanceof';
|
|
297
449
|
// Variables
|
|
@@ -326,7 +478,7 @@ function assertInstanceof( actual, expected ){
|
|
|
326
478
|
| --- | --- |
|
|
327
479
|
| 0.0.1 | WIP |
|
|
328
480
|
*/
|
|
329
|
-
function assertExpectedError( actual, expected ){
|
|
481
|
+
export function assertExpectedError( actual, expected ){
|
|
330
482
|
// Constants
|
|
331
483
|
const FUNCTION_NAME = 'assertExpectedError';
|
|
332
484
|
// Variables
|
|
@@ -372,7 +524,7 @@ function assertExpectedError( actual, expected ){
|
|
|
372
524
|
| 0.0.3 | Removed message parametre. |
|
|
373
525
|
| 0.0.1 | WIP |
|
|
374
526
|
*/
|
|
375
|
-
function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
527
|
+
export function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
376
528
|
|
|
377
529
|
// Constants
|
|
378
530
|
const FUNCTION_NAME = 'assertObjectsQuantitativelyEqual';
|
|
@@ -408,7 +560,7 @@ function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
|
408
560
|
| 0.0.3 | Removed message parametre. |
|
|
409
561
|
| 0.0.1 | WIP |
|
|
410
562
|
*/
|
|
411
|
-
function assertNullOrFunction( actual ){
|
|
563
|
+
export function assertNullOrFunction( actual ){
|
|
412
564
|
// Constants
|
|
413
565
|
const FUNCTION_NAME = 'assertNullOrFunction';
|
|
414
566
|
// Variables
|
|
@@ -423,9 +575,59 @@ function assertNullOrFunction( actual ){
|
|
|
423
575
|
throw return_error;
|
|
424
576
|
}
|
|
425
577
|
} // assertNullOrFunction
|
|
578
|
+
/**
|
|
579
|
+
### assertIsMap
|
|
580
|
+
> Throws if actual is neither `null` nor a function.
|
|
581
|
+
|
|
582
|
+
#### Parametres
|
|
583
|
+
| name | type | description |
|
|
584
|
+
| --- | --- | --- |
|
|
585
|
+
| actual | any | The actual object. |
|
|
586
|
+
|
|
587
|
+
#### Throws
|
|
588
|
+
| code | type | condition |
|
|
589
|
+
| --- | --- | --- |
|
|
590
|
+
| 'ERR_ASSERTION_NULLORFUNCTION' | AssertionError | Thrown if actual is neither `null` nor a function. |
|
|
591
|
+
|
|
592
|
+
#### History
|
|
593
|
+
| version | change |
|
|
594
|
+
| --- | --- |
|
|
595
|
+
| 0.0.5 | WIP |
|
|
596
|
+
*/
|
|
597
|
+
export function assertIsMap( actual ){
|
|
598
|
+
// Constants
|
|
599
|
+
const FUNCTION_NAME = 'assertIsMap';
|
|
600
|
+
// Variables
|
|
601
|
+
var return_error = null;
|
|
602
|
+
var message = '';
|
|
603
|
+
// Function
|
|
604
|
+
if( _.isMap( actual ) !== true ){
|
|
605
|
+
message = `'actual' (${inspThis.call( actual )}) is not a Map.`;
|
|
606
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, operator: 'IsMap' } );
|
|
607
|
+
return_error.code += '_ISMAP';
|
|
608
|
+
annotateThis.call( return_error );
|
|
609
|
+
throw return_error;
|
|
610
|
+
}
|
|
611
|
+
} // assertIsMap
|
|
426
612
|
|
|
427
613
|
const NAMESPACE = { ...AssertNS };
|
|
428
614
|
Object.defineProperties( NAMESPACE, {
|
|
615
|
+
assertTruthy: {
|
|
616
|
+
value: assertTruthy,
|
|
617
|
+
enumerable: true
|
|
618
|
+
},
|
|
619
|
+
assertNumber: {
|
|
620
|
+
value: assertNumber,
|
|
621
|
+
enumerable: true
|
|
622
|
+
},
|
|
623
|
+
assertLessThan: {
|
|
624
|
+
value: assertLessThan,
|
|
625
|
+
enumerable: true
|
|
626
|
+
},
|
|
627
|
+
assertGreaterThan: {
|
|
628
|
+
value: assertGreaterThan,
|
|
629
|
+
enumerable: true
|
|
630
|
+
},
|
|
429
631
|
assertSameType: {
|
|
430
632
|
value: assertSameType,
|
|
431
633
|
enumerable: true
|
|
@@ -465,10 +667,15 @@ Object.defineProperties( NAMESPACE, {
|
|
|
465
667
|
assertNullOrFunction: {
|
|
466
668
|
value: assertNullOrFunction,
|
|
467
669
|
enumerable: true
|
|
670
|
+
},
|
|
671
|
+
assertIsMap: {
|
|
672
|
+
value: assertIsMap,
|
|
673
|
+
enumerable: true
|
|
468
674
|
}
|
|
469
675
|
} );
|
|
470
676
|
|
|
471
|
-
export default
|
|
677
|
+
export { NAMESPACE as default };
|
|
678
|
+
export * from 'node:assert/strict';
|
|
472
679
|
|
|
473
680
|
// cno-assert.js EOF
|
|
474
681
|
|