Skip to content

Commit 05338ce

Browse files
committed
chore: replace unnecessary dependency "is-string-and-not-blank"
This package must be a joke, it contains literally three lines of code and another dependency - is-string-blank. The is-string-blank package is 6 years old and the source repository is gone. Moreover, it can be replaced with just a single line of code - it's used to check just a very short strings so the performance difference is negligible, if it still exists.
1 parent 76187c1 commit 05338ce

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"combine-errors": "^3.0.3",
1717
"cron-validate": "^1.4.5",
1818
"human-interval": "^2.0.1",
19-
"is-string-and-not-blank": "^0.0.2",
2019
"is-valid-path": "^0.1.1",
2120
"ms": "^2.1.3",
2221
"p-wait-for": "3",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const { Worker } = require('node:worker_threads');
99
const { join, resolve } = require('node:path');
1010
const { debuglog } = require('node:util');
1111
const combineErrors = require('combine-errors');
12-
const isSANB = require('is-string-and-not-blank');
1312
const isValidPath = require('is-valid-path');
1413
const later = require('@breejs/later');
1514
const pWaitFor = require('p-wait-for');
1615
const { setTimeout, setInterval } = require('safe-timers');
1716
const {
17+
isSANB,
1818
isSchedule,
1919
getName,
2020
getHumanToMs,

src/job-builder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { join } = require('node:path');
2-
const isSANB = require('is-string-and-not-blank');
32
const isValidPath = require('is-valid-path');
43
const later = require('@breejs/later');
5-
const { isSchedule, parseValue, getJobPath } = require('./job-utils');
4+
const { isSANB, isSchedule, parseValue, getJobPath } = require('./job-utils');
65

76
later.date.localTime();
87

src/job-utils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
const humanInterval = require('human-interval');
2-
const isSANB = require('is-string-and-not-blank');
32
const later = require('@breejs/later');
43
const ms = require('ms');
54

5+
/**
6+
* Returns true if `val` is a string and it's not blank.
7+
*
8+
* @param {any} value
9+
* @returns {boolean}
10+
*/
11+
const isSANB = (value) => {
12+
return typeof value === 'string' && value.trim().length > 0;
13+
};
14+
615
/**
716
* Naively checks if passed value is of later.js schedule format (https://breejs.github.io/later/schedules.html)
817
*
@@ -124,6 +133,7 @@ module.exports = {
124133
getJobNames,
125134
getJobPath,
126135
getName,
136+
isSANB,
127137
isSchedule,
128138
parseValue
129139
};

src/job-validator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ const fs = require('node:fs');
22
const { join } = require('node:path');
33
const combineErrors = require('combine-errors');
44
const cron = require('cron-validate');
5-
const isSANB = require('is-string-and-not-blank');
65
const isValidPath = require('is-valid-path');
7-
const { getName, isSchedule, parseValue, getJobPath } = require('./job-utils');
6+
const {
7+
getName,
8+
isSANB,
9+
isSchedule,
10+
parseValue,
11+
getJobPath
12+
} = require('./job-utils');
813

914
const validateReservedJobName = (name) => {
1015
// Don't allow a job to have the `index` file name

0 commit comments

Comments
 (0)