Skip to content

Commit

Permalink
remove is-nan. fixes #208 (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
amiram committed Sep 7, 2021
1 parent 8568b50 commit ba99544
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
17 changes: 7 additions & 10 deletions lib/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Load Date class extensions
var CronDate = require('./date');

// Get Number.isNaN or the polyfill
var safeIsNaN = require('is-nan');

var stringifyField = require('./field_stringify');

/**
Expand Down Expand Up @@ -205,7 +202,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
continue;
}
// Check constraints
if (typeof value !== 'number' || safeIsNaN(value) || value < constraints.min || value > constraints.max) {
if (typeof value !== 'number' || Number.isNaN(value) || value < constraints.min || value > constraints.max) {
throw new Error(
'Constraint error, got value ' + value + ' expected range ' +
constraints.min + '-' + constraints.max
Expand All @@ -224,7 +221,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
var numResult = +result;

// Check constraints
if (safeIsNaN(numResult) || numResult < constraints.min || numResult > constraints.max) {
if (Number.isNaN(numResult) || numResult < constraints.min || numResult > constraints.max) {
throw new Error(
'Constraint error, got value ' + result + ' expected range ' +
constraints.min + '-' + constraints.max
Expand Down Expand Up @@ -309,7 +306,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
var min = +atoms[0];
var max = +atoms[1];

if (safeIsNaN(min) || safeIsNaN(max) ||
if (Number.isNaN(min) || Number.isNaN(max) ||
min < constraints.min || max > constraints.max) {
throw new Error(
'Constraint error, got range ' +
Expand All @@ -324,7 +321,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
// Create range
var repeatIndex = +repeatInterval;

if (safeIsNaN(repeatIndex) || repeatIndex <= 0) {
if (Number.isNaN(repeatIndex) || repeatIndex <= 0) {
throw new Error('Constraint error, cannot repeat at every ' + repeatIndex + ' time.');
}

Expand All @@ -340,7 +337,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
return stack;
}

return safeIsNaN(+val) ? val : +val;
return Number.isNaN(+val) ? val : +val;
}

return parseSequence(value);
Expand Down Expand Up @@ -873,7 +870,7 @@ CronExpression.parse = function parse(expression, options) {
throw new Error('Constraint error, invalid dayOfWeek `#` and `-` '
+ 'special characters are incompatible');
}
if (atoms.length > 2 || safeIsNaN(nthValue) || (nthValue < 1 || nthValue > 5)) {
if (atoms.length > 2 || Number.isNaN(nthValue) || (nthValue < 1 || nthValue > 5)) {
throw new Error('Constraint error, invalid dayOfWeek occurrence number (#)');
}

Expand Down Expand Up @@ -910,7 +907,7 @@ CronExpression.fieldsToExpression = function fieldsToExpression(fields, options)
continue;
}
// Check constraints
if (typeof value !== 'number' || safeIsNaN(value) || value < constraints.min || value > constraints.max) {
if (typeof value !== 'number' || Number.isNaN(value) || value < constraints.min || value > constraints.max) {
throw new Error(
'Constraint error, got value ' + value + ' expected range ' +
constraints.min + '-' + constraints.max
Expand Down
31 changes: 7 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
],
"license": "MIT",
"dependencies": {
"is-nan": "^1.3.2",
"luxon": "^1.26.0"
},
"devDependencies": {
Expand Down

0 comments on commit ba99544

Please sign in to comment.