$ npm install comparejs
To use comparejs you need to reference it from your application by adding the following line:
const compare = default;
If you use TypeScript, use the following code instead:
- Supports comparison of
- Supports comparison of native data types and constructor-created data types, such as
- Supports comparison of objects and arrays using deep-equal.
- Supports comparison of objects and arrays with
>=by handling them as subsets.
- Supports comparison of objects by structure.
- Supports comparison with
- Supports comparison in a perfectly type-safe way out-of-the-box.
- Supports comparison by equality and identity, depending on what makes sense.
Now you are able to use the various comparison operators. All you need to do is access the
compare object and use its functions:
||less than or equal|
||greater than or equal|
Please note that each comparison operator works on each combination of types and does what you would expect it to do.
Structure comparison operators
For objects, there are special operators that compare by structure. Among other things, they can be used to verify objects against interfaces:
||equal by structure|
||not equal by structure|
||less than by structure|
||less than or equal by structure|
||greater than by structure|
||greater than or equal by structure|
Please note that these operators only work for objects. For any other type, they return
Running the build
To build this module use roboter.
$ npx roboter