Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
unit-compare
Advanced tools
Readme
Compare date/time and byte units
npm install --save unit-compare
The example below asserts if a number if less then 10 megabytes:
const compare = require('unit-compare');
const n = 1024;
const isLessThen10Mb = compare.isNumber(n).assert('<10mb')
if (isLessThen10Mb) {
console.log(`${n} is less than 10mb`);
}
Assert if a given number against a string byte size expression:
const greaterThan10kb = compare.isNumber(n).assert('>10kb')
Using comparison methods directly:
const greaterThan10kb = compare.isNumber(n).lessThan(10, 'k');
Assert if a given number against a string datetime expression:
const date = moment();
const equalTo10Mins = compare.isDate(date).assert('>10 minutes');
Using comparison methods directly:
const date = moment().subtract(10, 'minutes');
const greaterThan10kb = compare.isDate(date).lessThan(10, 'days');
compare.isDate() -> DateAssertion
Returns an DateAssertion instance.
compare.isNumber() -> ByteAssertion
Returns a ByteAssertion instance.
.assert(sizeExpression) -> boolean
sizeExpression - accepts a positive integer representing the file size. File size units are:
If no unit is specified, bytes is used by default.
Optionally, expressions can be prefixed with a comparison operator, including:
Examples:
.lessThan(int, unit) -> boolean
.greaterThan(int, unit) -> boolean
.equalTo(int, unit) -> boolean
.greaterThanOrEqual(int, unit) -> boolean
.lessThanOrEqual(int, unit) -> boolean
dateExpression - accepts a time unit. Time units are:
If no unit is specified, days is used by default.
Optionally, expressions can be prefixed with a comparison operator, including:
If no comparison operator is specified, equality is used by default.
Examples:
.lessThan(int, timeUnit) -> boolean
.greaterThan(int, timeUnit) -> boolean
.equalTo(int, timeUnit) -> boolean
.greaterThanOrEqual(int, timeUnit) -> boolean
.lessThanOrEqual(int, timeUnit) -> boolean
npm test
To generate a test coverage report:
npm run coverage
npm run lint
to check your code..jsbeautifyrc
to help.FAQs
Compare byte and datetime units
We found that unit-compare demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).