cno-bedrock 0.0.5 → 0.1.1
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/.github/workflows/ci.yml +11 -13
- package/CHANGELOG.md +39 -0
- package/ci/github-actions.hjson +10 -11
- package/package.json +8 -8
- package/scripts/generate-docs.js +0 -0
- package/src/cno-assert.js +268 -17
- 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 +955 -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 +8 -7
- package/src/stream-test.js +116 -0
- package/test/big-lorem.txt +29 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: ci
|
|
2
|
-
|
|
2
|
+
on:
|
|
3
3
|
- push
|
|
4
4
|
- pull_request
|
|
5
5
|
jobs:
|
|
@@ -11,20 +11,18 @@ jobs:
|
|
|
11
11
|
- macos-latest
|
|
12
12
|
- windows-latest
|
|
13
13
|
node:
|
|
14
|
-
- '18'
|
|
15
|
-
- '20'
|
|
16
14
|
- latest
|
|
15
|
+
- lts/*
|
|
17
16
|
name: source-${{matrix.os}}-node-${{matrix.node}}
|
|
18
17
|
runs-on: ${{matrix.os}}
|
|
19
18
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
21
|
-
- uses: actions/setup-node@
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
- uses: actions/setup-node@v7
|
|
22
21
|
with:
|
|
23
22
|
node-version: ${{matrix.node}}
|
|
24
|
-
- uses: pnpm/action-setup@
|
|
23
|
+
- uses: pnpm/action-setup@v6.1.1
|
|
25
24
|
with:
|
|
26
|
-
version:
|
|
27
|
-
if: ${{ matrix.node >= 18 || matrix.node == 'latest' }}
|
|
25
|
+
version: latest
|
|
28
26
|
- run: pnpm install
|
|
29
27
|
- run: pnpm test
|
|
30
28
|
coverage:
|
|
@@ -32,16 +30,16 @@ jobs:
|
|
|
32
30
|
name: coverage-ubuntu-latest-node-latest
|
|
33
31
|
runs-on: ubuntu-latest
|
|
34
32
|
steps:
|
|
35
|
-
- uses: actions/checkout@
|
|
36
|
-
- uses: actions/setup-node@
|
|
33
|
+
- uses: actions/checkout@v7
|
|
34
|
+
- uses: actions/setup-node@v7
|
|
37
35
|
with:
|
|
38
36
|
node-version: latest
|
|
39
|
-
- uses: pnpm/action-setup@
|
|
37
|
+
- uses: pnpm/action-setup@v6.1.1
|
|
40
38
|
with:
|
|
41
|
-
version:
|
|
39
|
+
version: latest
|
|
42
40
|
- run: pnpm install
|
|
43
41
|
- run: pnpm do-ci
|
|
44
|
-
- uses: coverallsapp/github-action@v2.
|
|
42
|
+
- uses: coverallsapp/github-action@v2.3.8
|
|
45
43
|
with:
|
|
46
44
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
47
45
|
file: coverage/lcov.txt
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
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.1](https://github.com/Anadian/cno-bedrock/compare/v0.1.0...v0.1.1) (2026-11-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Added LessThanOrEqual and GreaterThanOrEqual to asserts. ([80878a2](https://github.com/Anadian/cno-bedrock/commit/80878a2a16c3514996be6f26d4f12519491c70eb))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chores
|
|
14
|
+
|
|
15
|
+
* Updated GitHub Actions. ([14defe8](https://github.com/Anadian/cno-bedrock/commit/14defe8ccda7aabc351e0709c04b0df75058e53e))
|
|
16
|
+
* Updated GitHub Actions. ([190d917](https://github.com/Anadian/cno-bedrock/commit/190d917e74abf7c6d9f3334595a3f8e3a7fb2413))
|
|
17
|
+
|
|
18
|
+
## [0.1.0](https://github.com/Anadian/cno-bedrock/compare/v0.0.5...v0.1.0) (2026-11-29)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* Big additions including cno-files, cno-test* and plenty more cno-utility functions. ([be656e7](https://github.com/Anadian/cno-bedrock/commit/be656e7ecf2168bbee571467be387ee6b8673797))
|
|
24
|
+
* Finally got cno-sha2-256 working. ([d0567b2](https://github.com/Anadian/cno-bedrock/commit/d0567b219c2deea2d7dd59c95f4b2c0b978541c0))
|
|
25
|
+
* TimedCacheMap ([6622f99](https://github.com/Anadian/cno-bedrock/commit/6622f9979d881d0015fb672bbb28eab1a90fc352))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* Exports for previous commit. ([1aa8ab2](https://github.com/Anadian/cno-bedrock/commit/1aa8ab2054ce82331c07e5d73b224b8eb496ab5b))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Refactoring
|
|
34
|
+
|
|
35
|
+
* Moved isStrictlyNotEqual and isNullOrEmpty to utility to clean up lib.js ([ca740a7](https://github.com/Anadian/cno-bedrock/commit/ca740a7e6601c00b5806504b22facc887e74cd73))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Tests
|
|
39
|
+
|
|
40
|
+
* Basic usage test for `cno-tree`. ([e1ff4af](https://github.com/Anadian/cno-bedrock/commit/e1ff4af076826dd3f3a3a41d5ed7e412b87cbbb5))
|
|
41
|
+
* Completed tests and coverage for `cno-math`. ([17e37e4](https://github.com/Anadian/cno-bedrock/commit/17e37e4ae7a7dfc529a34a2e937e88f04d9cc14d))
|
|
42
|
+
* Tests for `cno-vector.js` ([0cda317](https://github.com/Anadian/cno-bedrock/commit/0cda317157cd33e16139e1d55e46c55ac69c598f))
|
|
43
|
+
|
|
5
44
|
### [0.0.5](https://github.com/Anadian/cno-bedrock/compare/v0.0.4...v0.0.5) (2025-11-08)
|
|
6
45
|
|
|
7
46
|
|
package/ci/github-actions.hjson
CHANGED
|
@@ -6,25 +6,24 @@
|
|
|
6
6
|
strategy: {
|
|
7
7
|
matrix: {
|
|
8
8
|
os: ['ubuntu-latest', 'macos-latest', 'windows-latest'],
|
|
9
|
-
node: [
|
|
9
|
+
node: [ 'latest', 'lts/*' ]
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
name: 'source-${{matrix.os}}-node-${{matrix.node}}',
|
|
13
13
|
'runs-on': '${{matrix.os}}',
|
|
14
14
|
steps: [
|
|
15
|
-
{ uses: 'actions/checkout@
|
|
15
|
+
{ uses: 'actions/checkout@v7' },
|
|
16
16
|
{
|
|
17
|
-
uses: 'actions/setup-node@
|
|
17
|
+
uses: 'actions/setup-node@v7',
|
|
18
18
|
with: {
|
|
19
19
|
'node-version': '${{matrix.node}}'
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
uses: 'pnpm/action-setup@
|
|
23
|
+
uses: 'pnpm/action-setup@v6.1.1',
|
|
24
24
|
with: {
|
|
25
|
-
version: '
|
|
25
|
+
version: 'latest'
|
|
26
26
|
},
|
|
27
|
-
if: "${{ matrix.node >= 18 || matrix.node == 'latest' }}"
|
|
28
27
|
},
|
|
29
28
|
{
|
|
30
29
|
run: 'pnpm install'
|
|
@@ -39,17 +38,17 @@
|
|
|
39
38
|
name: 'coverage-ubuntu-latest-node-latest',
|
|
40
39
|
'runs-on': 'ubuntu-latest',
|
|
41
40
|
steps: [
|
|
42
|
-
{ uses: 'actions/checkout@
|
|
41
|
+
{ uses: 'actions/checkout@v7' },
|
|
43
42
|
{
|
|
44
|
-
uses: 'actions/setup-node@
|
|
43
|
+
uses: 'actions/setup-node@v7',
|
|
45
44
|
with: {
|
|
46
45
|
'node-version': 'latest'
|
|
47
46
|
}
|
|
48
47
|
},
|
|
49
48
|
{
|
|
50
|
-
uses: 'pnpm/action-setup@
|
|
49
|
+
uses: 'pnpm/action-setup@v6.1.1',
|
|
51
50
|
with: {
|
|
52
|
-
version: '
|
|
51
|
+
version: 'latest'
|
|
53
52
|
},
|
|
54
53
|
},
|
|
55
54
|
{
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
run: 'pnpm do-ci'
|
|
60
59
|
},
|
|
61
60
|
{
|
|
62
|
-
uses: 'coverallsapp/github-action@v2.
|
|
61
|
+
uses: 'coverallsapp/github-action@v2.3.8',
|
|
63
62
|
with: {
|
|
64
63
|
"github-token": '${{secrets.GITHUB_TOKEN}}',
|
|
65
64
|
"file": 'coverage/lcov.txt',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cno-bedrock",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Micropackage: a test bed for various small pieces of reusable code.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -89,21 +89,21 @@
|
|
|
89
89
|
"cno-bedrock": "./src/cli.js"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"c8": "^
|
|
93
|
-
"eslint": "^
|
|
92
|
+
"c8": "^12.0.0",
|
|
93
|
+
"eslint": "^10.8.1",
|
|
94
94
|
"extract-documentation-comments": "^0.4.2",
|
|
95
95
|
"hjson": "^3.2.2",
|
|
96
|
-
"npm-check-updates": "^
|
|
96
|
+
"npm-check-updates": "^23.0.2",
|
|
97
97
|
"shelljs": "^0.10.0",
|
|
98
98
|
"standard-version": "^9.5.0"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"lodash": "^4.
|
|
102
|
-
"mathjs": "^15.
|
|
103
|
-
"nanoid": "^
|
|
101
|
+
"lodash": "^4.18.1",
|
|
102
|
+
"mathjs": "^15.2.0",
|
|
103
|
+
"nanoid": "^6.0.1"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
106
|
-
"test": "node --test ./src
|
|
106
|
+
"test": "node --test ./src/*.test.js",
|
|
107
107
|
"coverage": "c8 pnpm test",
|
|
108
108
|
"coverage-report": "c8 report -r=text-lcov > coverage/lcov.txt",
|
|
109
109
|
"do-ci": "pnpm coverage && pnpm coverage-report",
|
package/scripts/generate-docs.js
CHANGED
|
File without changes
|
package/src/cno-assert.js
CHANGED
|
@@ -41,6 +41,231 @@ 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_LESSTHAN' | 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
|
+
### assertLessThanOrEqual
|
|
160
|
+
> Throws if actual is not less than or equal to 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_LESSTHANOREQUAL' | AssertionError | Thrown if `actual > expected`. |
|
|
172
|
+
|
|
173
|
+
#### History
|
|
174
|
+
| version | change |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| 0.1.1 | WIP |
|
|
177
|
+
*/
|
|
178
|
+
export function assertLessThanOrEqual( actual, expected ){
|
|
179
|
+
// Constants
|
|
180
|
+
const FUNCTION_NAME = 'assertLessThanOrEqual';
|
|
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 less than or equal to 'expected' (${expected}).`;
|
|
189
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'LessThanOrEqual' } );
|
|
190
|
+
return_error.code += '_LESSTHANOREQUAL';
|
|
191
|
+
annotateThis.call( return_error );
|
|
192
|
+
throw return_error;
|
|
193
|
+
}
|
|
194
|
+
} // assertLessThanOrEqual
|
|
195
|
+
/**
|
|
196
|
+
### assertGreaterThan
|
|
197
|
+
> Throws if actual is not greater than expected or if either isn't a number.
|
|
198
|
+
|
|
199
|
+
#### Parametres
|
|
200
|
+
| name | type | description |
|
|
201
|
+
| --- | --- | --- |
|
|
202
|
+
| actual | any | The actual value. |
|
|
203
|
+
| expected | any | The expected value. |
|
|
204
|
+
|
|
205
|
+
#### Throws
|
|
206
|
+
| code | type | condition |
|
|
207
|
+
| --- | --- | --- |
|
|
208
|
+
| 'ERR_ASSERTION_GREATERTHAN' | AssertionError | Thrown if `actual <= expected`. |
|
|
209
|
+
|
|
210
|
+
#### History
|
|
211
|
+
| version | change |
|
|
212
|
+
| --- | --- |
|
|
213
|
+
| 0.0.3 | WIP |
|
|
214
|
+
*/
|
|
215
|
+
export function assertGreaterThan( actual, expected ){
|
|
216
|
+
// Constants
|
|
217
|
+
const FUNCTION_NAME = 'assertGreaterThan';
|
|
218
|
+
// Variables
|
|
219
|
+
var return_error = null;
|
|
220
|
+
var message = '';
|
|
221
|
+
// Function
|
|
222
|
+
assertNumber( actual );
|
|
223
|
+
assertNumber( expected );
|
|
224
|
+
if( actual <= expected ){
|
|
225
|
+
message = `'actual' (${actual}) is not greater than 'expected' (${expected}).`;
|
|
226
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'GreaterThan' } );
|
|
227
|
+
return_error.code += '_GREATERTHAN';
|
|
228
|
+
annotateThis.call( return_error );
|
|
229
|
+
throw return_error;
|
|
230
|
+
}
|
|
231
|
+
} // assertGreaterThan
|
|
232
|
+
/**
|
|
233
|
+
### assertGreaterThanOrEqual
|
|
234
|
+
> Throws if actual is not greater than or equal to expected or if either isn't a number.
|
|
235
|
+
|
|
236
|
+
#### Parametres
|
|
237
|
+
| name | type | description |
|
|
238
|
+
| --- | --- | --- |
|
|
239
|
+
| actual | any | The actual value. |
|
|
240
|
+
| expected | any | The expected value. |
|
|
241
|
+
|
|
242
|
+
#### Throws
|
|
243
|
+
| code | type | condition |
|
|
244
|
+
| --- | --- | --- |
|
|
245
|
+
| 'ERR_ASSERTION_GREATERTHANOREQUAL' | AssertionError | Thrown if `actual < expected`. |
|
|
246
|
+
|
|
247
|
+
#### History
|
|
248
|
+
| version | change |
|
|
249
|
+
| --- | --- |
|
|
250
|
+
| 0.1.1 | WIP |
|
|
251
|
+
*/
|
|
252
|
+
export function assertGreaterThanOrEqual( actual, expected ){
|
|
253
|
+
// Constants
|
|
254
|
+
const FUNCTION_NAME = 'assertGreaterThanOrEqual';
|
|
255
|
+
// Variables
|
|
256
|
+
var return_error = null;
|
|
257
|
+
var message = '';
|
|
258
|
+
// Function
|
|
259
|
+
assertNumber( actual );
|
|
260
|
+
assertNumber( expected );
|
|
261
|
+
if( actual < expected ){
|
|
262
|
+
message = `'actual' (${actual}) is not greater than or equal to 'expected' (${expected}).`;
|
|
263
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'GreaterThanOrEqual' } );
|
|
264
|
+
return_error.code += '_GREATERTHANOREQUAL';
|
|
265
|
+
annotateThis.call( return_error );
|
|
266
|
+
throw return_error;
|
|
267
|
+
}
|
|
268
|
+
} // assertGreaterThanOrEqual
|
|
44
269
|
/**
|
|
45
270
|
### assertSameType
|
|
46
271
|
> Throws if actual's type is not the same as expected's, according to a strict `typeof` comparison.
|
|
@@ -62,7 +287,7 @@ const FILENAME = 'cno-assert.js';
|
|
|
62
287
|
| 0.0.3 | Removed message parametre. |
|
|
63
288
|
| 0.0.1 | WIP |
|
|
64
289
|
*/
|
|
65
|
-
function assertSameType( actual, expected ){
|
|
290
|
+
export function assertSameType( actual, expected ){
|
|
66
291
|
// Constants
|
|
67
292
|
const FUNCTION_NAME = 'assertSameType';
|
|
68
293
|
// Variables
|
|
@@ -98,7 +323,7 @@ function assertSameType( actual, expected ){
|
|
|
98
323
|
| 0.0.3 | Redone |
|
|
99
324
|
| 0.0.1 | WIP |
|
|
100
325
|
*/
|
|
101
|
-
function assertNonstrictNotEqual( actual, expected ){
|
|
326
|
+
export function assertNonstrictNotEqual( actual, expected ){
|
|
102
327
|
// Constants
|
|
103
328
|
const FUNCTION_NAME = 'assertNonstrictNotEqual';
|
|
104
329
|
// Variables
|
|
@@ -115,7 +340,7 @@ function assertNonstrictNotEqual( actual, expected ){
|
|
|
115
340
|
} // assertNonstrictNotEqual
|
|
116
341
|
/**
|
|
117
342
|
### assertIsEmpty
|
|
118
|
-
> Throws if `actual` is not empty.
|
|
343
|
+
> Throws if `actual` is not empty via [`_.isEmpty`](https://lodash.com/docs/4.17.21#isEmpty).
|
|
119
344
|
|
|
120
345
|
#### Parametres
|
|
121
346
|
| name | type | description |
|
|
@@ -130,12 +355,13 @@ function assertNonstrictNotEqual( actual, expected ){
|
|
|
130
355
|
#### History
|
|
131
356
|
| version | change |
|
|
132
357
|
| --- | --- |
|
|
358
|
+
| 0.1.1 | Uses lodash's `isEmpty` function. |
|
|
133
359
|
| 0.0.3 | WIP |
|
|
134
360
|
*/
|
|
135
|
-
function assertIsEmpty( actual ){
|
|
361
|
+
export function assertIsEmpty( actual ){
|
|
136
362
|
var return_error = null;
|
|
137
|
-
if(
|
|
138
|
-
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual})
|
|
363
|
+
if( _.isEmpty( actual ) !== true ){
|
|
364
|
+
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual}) is not empty.`, actual: actual, operator: 'IsEmpty' } );
|
|
139
365
|
return_error.code += '_ISEMPTY';
|
|
140
366
|
throw return_error;
|
|
141
367
|
}
|
|
@@ -159,7 +385,7 @@ function assertIsEmpty( actual ){
|
|
|
159
385
|
| --- | --- |
|
|
160
386
|
| 0.0.3 | WIP |
|
|
161
387
|
*/
|
|
162
|
-
function assertIsNullOrUndefined( actual ){
|
|
388
|
+
export function assertIsNullOrUndefined( actual ){
|
|
163
389
|
var return_error = null;
|
|
164
390
|
if( actual !== null && actual !== undefined ){
|
|
165
391
|
return_error = new AssertNS.AssertionError( { message: `'actual' (${actual}) is neither null nor undefined.`, actual: actual, operator: 'IsNullOrUndefined' } );
|
|
@@ -186,7 +412,7 @@ function assertIsNullOrUndefined( actual ){
|
|
|
186
412
|
| --- | --- |
|
|
187
413
|
| 0.0.3 | WIP |
|
|
188
414
|
*/
|
|
189
|
-
function assertIsNullOrEmpty( actual ){
|
|
415
|
+
export function assertIsNullOrEmpty( actual ){
|
|
190
416
|
// Constants
|
|
191
417
|
const FUNCTION_NAME = 'assertIsNullOrEmpty';
|
|
192
418
|
// Variables
|
|
@@ -219,7 +445,7 @@ function assertIsNullOrEmpty( actual ){
|
|
|
219
445
|
} // assertIsNullOrEmpty
|
|
220
446
|
/**
|
|
221
447
|
### assertStrictlyNotEqual
|
|
222
|
-
> Throws if actual is not the same type as expected or is the value as expected.
|
|
448
|
+
> Throws if actual is not the same type as expected or is the same value as expected.
|
|
223
449
|
|
|
224
450
|
#### Parametres
|
|
225
451
|
| name | type | description |
|
|
@@ -233,7 +459,7 @@ function assertIsNullOrEmpty( actual ){
|
|
|
233
459
|
#### Throws
|
|
234
460
|
| code | type | condition |
|
|
235
461
|
| --- | --- | --- |
|
|
236
|
-
| 'ERR_ASSERTION_STRICTLYNOTEQUAL' | AssertionError | Thrown if actual is not strictly-not-equal (
|
|
462
|
+
| 'ERR_ASSERTION_STRICTLYNOTEQUAL' | AssertionError | Thrown if actual is not strictly-not-equal (` != `) && typeof((`) === typeof(`)) to expected. |
|
|
237
463
|
|
|
238
464
|
#### History
|
|
239
465
|
| version | change |
|
|
@@ -241,7 +467,7 @@ function assertIsNullOrEmpty( actual ){
|
|
|
241
467
|
| 0.0.3 | Removed message parametre. |
|
|
242
468
|
| 0.0.1 | WIP |
|
|
243
469
|
*/
|
|
244
|
-
function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
470
|
+
export function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
245
471
|
// Constants
|
|
246
472
|
const FUNCTION_NAME = 'assertStrictlyNotEqual';
|
|
247
473
|
// Variables
|
|
@@ -291,7 +517,7 @@ function assertStrictlyNotEqual( actual, expected, name, value, expectedType ){
|
|
|
291
517
|
| 0.0.3 | Removed message parametre. |
|
|
292
518
|
| 0.0.1 | WIP |
|
|
293
519
|
*/
|
|
294
|
-
function assertInstanceof( actual, expected ){
|
|
520
|
+
export function assertInstanceof( actual, expected ){
|
|
295
521
|
// Constants
|
|
296
522
|
const FUNCTION_NAME = 'assertInstanceof';
|
|
297
523
|
// Variables
|
|
@@ -326,7 +552,7 @@ function assertInstanceof( actual, expected ){
|
|
|
326
552
|
| --- | --- |
|
|
327
553
|
| 0.0.1 | WIP |
|
|
328
554
|
*/
|
|
329
|
-
function assertExpectedError( actual, expected ){
|
|
555
|
+
export function assertExpectedError( actual, expected ){
|
|
330
556
|
// Constants
|
|
331
557
|
const FUNCTION_NAME = 'assertExpectedError';
|
|
332
558
|
// Variables
|
|
@@ -372,7 +598,7 @@ function assertExpectedError( actual, expected ){
|
|
|
372
598
|
| 0.0.3 | Removed message parametre. |
|
|
373
599
|
| 0.0.1 | WIP |
|
|
374
600
|
*/
|
|
375
|
-
function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
601
|
+
export function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
376
602
|
|
|
377
603
|
// Constants
|
|
378
604
|
const FUNCTION_NAME = 'assertObjectsQuantitativelyEqual';
|
|
@@ -408,7 +634,7 @@ function assertObjectsQuantitativelyEqual( actual, expected ){
|
|
|
408
634
|
| 0.0.3 | Removed message parametre. |
|
|
409
635
|
| 0.0.1 | WIP |
|
|
410
636
|
*/
|
|
411
|
-
function assertNullOrFunction( actual ){
|
|
637
|
+
export function assertNullOrFunction( actual ){
|
|
412
638
|
// Constants
|
|
413
639
|
const FUNCTION_NAME = 'assertNullOrFunction';
|
|
414
640
|
// Variables
|
|
@@ -442,7 +668,7 @@ function assertNullOrFunction( actual ){
|
|
|
442
668
|
| --- | --- |
|
|
443
669
|
| 0.0.5 | WIP |
|
|
444
670
|
*/
|
|
445
|
-
function assertIsMap( actual ){
|
|
671
|
+
export function assertIsMap( actual ){
|
|
446
672
|
// Constants
|
|
447
673
|
const FUNCTION_NAME = 'assertIsMap';
|
|
448
674
|
// Variables
|
|
@@ -460,6 +686,30 @@ function assertIsMap( actual ){
|
|
|
460
686
|
|
|
461
687
|
const NAMESPACE = { ...AssertNS };
|
|
462
688
|
Object.defineProperties( NAMESPACE, {
|
|
689
|
+
assertTruthy: {
|
|
690
|
+
value: assertTruthy,
|
|
691
|
+
enumerable: true
|
|
692
|
+
},
|
|
693
|
+
assertNumber: {
|
|
694
|
+
value: assertNumber,
|
|
695
|
+
enumerable: true
|
|
696
|
+
},
|
|
697
|
+
assertLessThan: {
|
|
698
|
+
value: assertLessThan,
|
|
699
|
+
enumerable: true
|
|
700
|
+
},
|
|
701
|
+
assertLessThanOrEqual: {
|
|
702
|
+
value: assertLessThanOrEqual,
|
|
703
|
+
enumerable: true
|
|
704
|
+
},
|
|
705
|
+
assertGreaterThan: {
|
|
706
|
+
value: assertGreaterThan,
|
|
707
|
+
enumerable: true
|
|
708
|
+
},
|
|
709
|
+
assertGreaterThanOrEqual: {
|
|
710
|
+
value: assertGreaterThanOrEqual,
|
|
711
|
+
enumerable: true
|
|
712
|
+
},
|
|
463
713
|
assertSameType: {
|
|
464
714
|
value: assertSameType,
|
|
465
715
|
enumerable: true
|
|
@@ -506,7 +756,8 @@ Object.defineProperties( NAMESPACE, {
|
|
|
506
756
|
}
|
|
507
757
|
} );
|
|
508
758
|
|
|
509
|
-
export default
|
|
759
|
+
export { NAMESPACE as default };
|
|
760
|
+
export * from 'node:assert/strict';
|
|
510
761
|
|
|
511
762
|
// cno-assert.js EOF
|
|
512
763
|
|