cno-bedrock 0.0.1 → 0.0.2
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 +7 -0
- package/package.json +1 -1
- package/src/cno-assert.js +39 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.2](https://github.com/Anadian/cno-bedrock/compare/v0.0.1...v0.0.2) (2025-09-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* assertNullOrFunction ([8cc5955](https://github.com/Anadian/cno-bedrock/commit/8cc5955129b65affc65f3175d341a4238356930f))
|
|
11
|
+
|
|
5
12
|
### 0.0.1 (2025-06-14)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
package/src/cno-assert.js
CHANGED
|
@@ -245,7 +245,7 @@ function assertExpectedError( actual, expected, message = '' ){
|
|
|
245
245
|
} // assertExpectedError
|
|
246
246
|
/**
|
|
247
247
|
### assertObjectsQuantitativelyEqual
|
|
248
|
-
> Throws if
|
|
248
|
+
> Throws if actual doesn't have the same properties and values as expected. Compared via [lodash's `_.isEqual`](https://lodash.com/docs/4.17.15#isEqual).
|
|
249
249
|
|
|
250
250
|
#### Parametres
|
|
251
251
|
| name | type | description |
|
|
@@ -279,6 +279,40 @@ function assertObjectsQuantitativelyEqual( actual, expected, message = '' ){
|
|
|
279
279
|
throw return_error;
|
|
280
280
|
}
|
|
281
281
|
} // assertObjectsQuantitativelyEqual
|
|
282
|
+
/**
|
|
283
|
+
### assertNullOrFunction
|
|
284
|
+
> Throws if actual is neither `null` nor a function.
|
|
285
|
+
|
|
286
|
+
#### Parametres
|
|
287
|
+
| name | type | description |
|
|
288
|
+
| --- | --- | --- |
|
|
289
|
+
| actual | any | The actual object. |
|
|
290
|
+
| message | string | A custom message for the assertion. \[default: ''\] |
|
|
291
|
+
|
|
292
|
+
#### Throws
|
|
293
|
+
| code | type | condition |
|
|
294
|
+
| --- | --- | --- |
|
|
295
|
+
| 'ERR_ASSERTION_NULLORFUNCTION' | AssertionError | Thrown if actual is neither `null` nor a function. |
|
|
296
|
+
|
|
297
|
+
#### History
|
|
298
|
+
| version | change |
|
|
299
|
+
| --- | --- |
|
|
300
|
+
| 0.0.1 | WIP |
|
|
301
|
+
*/
|
|
302
|
+
function assertNullOrFunction( actual, message = '' ){
|
|
303
|
+
// Constants
|
|
304
|
+
const FUNCTION_NAME = 'assertNullOrFunction';
|
|
305
|
+
// Variables
|
|
306
|
+
var return_error = null;
|
|
307
|
+
// Function
|
|
308
|
+
if( actual != null && typeof(actual) !== 'function' ){
|
|
309
|
+
message ??= `'actual' (${inspThis.call( actual )}) is neither null nor a function.`;
|
|
310
|
+
return_error = new AssertNS.AssertionError( { message: message, actual: actual, expected: expected, operator: 'NullOrFunction' } );
|
|
311
|
+
return_error.code += '_NULLORFUNCTION';
|
|
312
|
+
annotateThis.call( return_error );
|
|
313
|
+
throw return_error;
|
|
314
|
+
}
|
|
315
|
+
} // assertNullOrFunction
|
|
282
316
|
|
|
283
317
|
const NAMESPACE = { ...AssertNS };
|
|
284
318
|
Object.defineProperties( NAMESPACE, {
|
|
@@ -305,6 +339,10 @@ Object.defineProperties( NAMESPACE, {
|
|
|
305
339
|
assertObjectsQuantitativelyEqual: {
|
|
306
340
|
value: assertObjectsQuantitativelyEqual,
|
|
307
341
|
enumerable: true
|
|
342
|
+
},
|
|
343
|
+
assertNullOrFunction: {
|
|
344
|
+
value: assertNullOrFunction,
|
|
345
|
+
enumerable: true
|
|
308
346
|
}
|
|
309
347
|
} );
|
|
310
348
|
|