Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
comparejs implements JavaScript's comparison operators the way you would expect them to be.
comparejs implements JavaScript's comparison operators the way you would expect them to be.
$ npm install comparejs
To use comparejs you need to reference it from your application by adding the following line:
const cmp = require('comparejs');
number
, string
, boolean
, function
, object
, array
and undefined
.number
and new Number()
.<
, <=
, >
and >=
by handling them as subsets.undefined
correctly, as <=
and >=
are problematic in plain JavaScript.Now you are able to use the various comparison operators. All you need to do is access the cmp
object and
use its functions:
Operator | Alias | Description |
---|---|---|
cmp.eq(first, second) | cmp.equal(first, second) | equal |
cmp.ne(first, second) | cmp.notEqual(first, second) | not equal |
cmp.gt(first, second) | cmp.greaterThan(first, second) | greater than |
cmp.ge(first, second) | cmp.greaterThanOrEqual(first, second) | greater than or equal |
cmp.lt(first, second) | cmp.lessThan(first, second) | less than |
cmp.le(first, second) | cmp.lessThanOrEqual(first, second) | less than or equal |
cmp.id(first, second) | cmp.identical(first, second) | identical |
Please note that each comparison operator works on each combination of types and does what you would expect it to do.
For objects, there are special operators that compare by structure. Among other things, they can be used to verify objects against interfaces:
Operator | Alias | Description |
---|---|---|
cmp.eqs(first, second) | cmp.equalByStructure(first, second) | equal by structure |
cmp.nes(first, second) | cmp.notEqualByStructure(first, second) | not equal by structure |
cmp.gts(first, second) | cmp.greaterThanByStructure(first, second) | greater than by structure |
cmp.ges(first, second) | cmp.greaterThanOrEqualByStructure(first, second) | greater than or equal by structure |
cmp.lts(first, second) | cmp.lessThanByStructure(first, second) | less than by structure |
cmp.les(first, second) | cmp.lessThanOrEqualByStructure(first, second) | less than or equal by structure |
Please note that these operators only work for objects. For any other type, they return false
.
To build this module use roboter.
$ npx roboter
The MIT License (MIT) Copyright (c) 2012-2019 the native web.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
comparejs implements JavaScript's comparison operators the way you would expect them to be.
The npm package comparejs receives a total of 21,631 weekly downloads. As such, comparejs popularity was classified as popular.
We found that comparejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.