simple-common-utils
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -240,2 +240,20 @@ export default class StaticUtils { | ||
} | ||
static verifyPropertyPresence(object, property, type) { | ||
StaticUtils.verify(object.hasOwnProperty(property), `Property '${property}' is undefined.`); | ||
if (type) { | ||
StaticUtils.verify(object[property].constructor == type || object[property] instanceof type, `Property '${property}' must be a ${type.name}, not a ${object[property].constructor.name}.`); | ||
} | ||
} | ||
static verifyPropertyAbsence(object, property) { | ||
if (Array.isArray(property)) { | ||
for (const name of property) { | ||
StaticUtils.verifyPropertyAbsence(object, name); | ||
} | ||
} else { | ||
StaticUtils.verify(!object.hasOwnProperty(property), `Property '${property}' is already defined.`); | ||
} | ||
} | ||
} |
{ | ||
"name": "simple-common-utils", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A collection of utility classes.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -251,2 +251,3 @@ This is a collection of utility classes used for JS development. | ||
-|- | ||
v2.1.0|`StaticUtils.verifyPropertyPresence()` / `StaticUtils.verifyPropertyAbsence()` are added. | ||
v2.0.0|Backwards-incompatible changes in `data-transmission-protocol` classes:<br>1. `Packet.constructor()` changed and `Packet.wrap()` added.<br>2. `Format` is filled dynamically: it's necessary to import relevant format-defining classes. | ||
@@ -253,0 +254,0 @@ v1.7.1|Autobinding removed from the `data-transmission-protocol` classes. |
32094
597
264