cno-bedrock 0.0.3 → 0.0.5
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 +19 -0
- package/package.json +1 -1
- package/src/cno-assert.js +38 -0
- package/src/lib.test.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.0.5](https://github.com/Anadian/cno-bedrock/compare/v0.0.4...v0.0.5) (2025-11-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **assert:** Add assertIsMap. ([9bc952b](https://github.com/Anadian/cno-bedrock/commit/9bc952b1b82580a496bab38f44e6514547614cb8))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
* Added test for assertIsMap. ([af82fb3](https://github.com/Anadian/cno-bedrock/commit/af82fb3831a96afd64c241db7ea894b2d20a48d2))
|
|
16
|
+
|
|
17
|
+
### [0.0.4](https://github.com/Anadian/cno-bedrock/compare/v0.0.3...v0.0.4) (2025-11-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Chores
|
|
21
|
+
|
|
22
|
+
* Hotfix to synchronise pnpm lock file with package.jsom. ([ec65486](https://github.com/Anadian/cno-bedrock/commit/ec65486ca54176871edb583e30db5bdd7cfcf50d))
|
|
23
|
+
|
|
5
24
|
### [0.0.3](https://github.com/Anadian/cno-bedrock/compare/v0.0.2...v0.0.3) (2025-11-07)
|
|
6
25
|
|
|
7
26
|
|
package/package.json
CHANGED
package/src/cno-assert.js
CHANGED
|
@@ -423,6 +423,40 @@ function assertNullOrFunction( actual ){
|
|
|
423
423
|
throw return_error;
|
|
424
424
|
}
|
|
425
425
|
} // assertNullOrFunction
|
|
426
|
+
/**
|
|
427
|
+
### assertIsMap
|
|
428
|
+
> Throws if actual is neither `null` nor a function.
|
|
429
|
+
|
|
430
|
+
#### Parametres
|
|
431
|
+
| name | type | description |
|
|
432
|
+
| --- | --- | --- |
|
|
433
|
+
| actual | any | The actual object. |
|
|
434
|
+
|
|
435
|
+
#### Throws
|
|
436
|
+
| code | type | condition |
|
|
437
|
+
| --- | --- | --- |
|
|
438
|
+
| 'ERR_ASSERTION_NULLORFUNCTION' | AssertionError | Thrown if actual is neither `null` nor a function. |
|
|
439
|
+
|
|
440
|
+
#### History
|
|
441
|
+
| version | change |
|
|
442
|
+
| --- | --- |
|
|
443
|
+
| 0.0.5 | WIP |
|
|
444
|
+
*/
|
|
445
|
+
function assertIsMap( actual ){
|
|
446
|
+
// Constants
|
|
447
|
+
const FUNCTION_NAME = 'assertIsMap';
|
|
448
|
+
// Variables
|
|
449
|
+
var return_error = null;
|
|
450
|
+
var message = '';
|
|
451
|
+
// Function
|
|
452
|
+
if( _.isMap( actual ) !== true ){
|
|
453
|
+
message = `'actual' (${inspThis.call( actual )}) is not a Map.`;
|
|
454
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, operator: 'IsMap' } );
|
|
455
|
+
return_error.code += '_ISMAP';
|
|
456
|
+
annotateThis.call( return_error );
|
|
457
|
+
throw return_error;
|
|
458
|
+
}
|
|
459
|
+
} // assertIsMap
|
|
426
460
|
|
|
427
461
|
const NAMESPACE = { ...AssertNS };
|
|
428
462
|
Object.defineProperties( NAMESPACE, {
|
|
@@ -465,6 +499,10 @@ Object.defineProperties( NAMESPACE, {
|
|
|
465
499
|
assertNullOrFunction: {
|
|
466
500
|
value: assertNullOrFunction,
|
|
467
501
|
enumerable: true
|
|
502
|
+
},
|
|
503
|
+
assertIsMap: {
|
|
504
|
+
value: assertIsMap,
|
|
505
|
+
enumerable: true
|
|
468
506
|
}
|
|
469
507
|
} );
|
|
470
508
|
|
package/src/lib.test.js
CHANGED
|
@@ -192,6 +192,17 @@ function main_test(){
|
|
|
192
192
|
if( e !== true || n !== true || f !== false ){
|
|
193
193
|
console.error( 'Something is wrong!', e, n, f );
|
|
194
194
|
}
|
|
195
|
+
var map = new Map();
|
|
196
|
+
var maplike = {
|
|
197
|
+
a: 'b',
|
|
198
|
+
size: 1
|
|
199
|
+
};
|
|
200
|
+
Bedrock.assert.assertIsMap( map );
|
|
201
|
+
try{
|
|
202
|
+
Bedrock.assert.assertIsMap( maplike );
|
|
203
|
+
} catch( error ){
|
|
204
|
+
Bedrock.assert.assertExpectedError( error, { constructor: AssertionError, code: 'ERR_ASSERTION_ISMAP' } );
|
|
205
|
+
}
|
|
195
206
|
}
|
|
196
207
|
main_test();
|
|
197
208
|
|