Skip to content

Commit f6a01a2

Browse files
committed
feature(readify) drop support of node < 14
1 parent cb51e4e commit f6a01a2

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

lib/readdir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const {join} = require('path');
4-
const {readdir} = require('fs').promises;
4+
const {readdir} = require('fs/promises');
55

66
const tryToCatch = require('try-to-catch');
77
const superstat = require('superstat');

lib/readify.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const format = require('format-io');
44
const currify = require('currify');
55
const tryToCatch = require('try-to-catch');
66

7-
const sortify = currify(require('@cloudcmd/sortify'));
7+
const sortify = require('@cloudcmd/sortify');
88
const formatify = require('@cloudcmd/formatify');
99

1010
const WIN = process.platform === 'win32';
@@ -15,6 +15,7 @@ const replaceProperty = currify(_replaceProperty);
1515
const nicki = !WIN && require('nicki');
1616

1717
const readdir = require('./readdir');
18+
const isString = (a) => typeof a === 'string';
1819

1920
module.exports = readify;
2021

@@ -25,8 +26,12 @@ async function readify(path, options = {}) {
2526
sort = 'name',
2627
} = options;
2728

28-
check(path, type);
29-
checkSort(sort, order);
29+
check({
30+
path,
31+
type,
32+
sort,
33+
order,
34+
});
3035

3136
const names = await readdir(path);
3237

@@ -36,21 +41,14 @@ async function readify(path, options = {}) {
3641
return await fillJSON(path, type, formated);
3742
}
3843

39-
function check(path, type) {
40-
const isString = (a) => typeof a === 'string';
41-
42-
const pathMsg = 'path should be string!';
43-
const typeMsg = 'type should be a string or not to be defined!';
44-
44+
function check({path, type, sort, order}) {
4545
if (!isString(path))
46-
throw Error(pathMsg);
46+
throw Error('path should be string!');
4747

4848
if (type && !isString(type))
49-
throw Error(typeMsg);
50-
}
51-
52-
function checkSort(sort, order) {
53-
if (sort && typeof sort !== 'string')
49+
throw Error('type should be a string or not to be defined!');
50+
51+
if (sort && !isString(sort))
5452
throw Error('sort should be a string!');
5553

5654
if (order && !/^(asc|desc)$/.test(order))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"license": "MIT",
5050
"main": "lib/readify.js",
5151
"engines": {
52-
"node": ">=10"
52+
"node": ">=14"
5353
},
5454
"devDependencies": {
5555
"@cloudcmd/stub": "^3.0.0",

0 commit comments

Comments
 (0)