@hestia-earth/utils 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +32 -9
- package/dist/validate-terms.js +2 -2
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const isEmpty: (value: any, minKeys?: number) => boolean;
|
|
2
2
|
export declare const isIri: (value?: string) => boolean;
|
|
3
|
-
export declare const isUndefined: <T>(value: T) => boolean;
|
|
4
|
-
export declare const reduceUndefinedValues: <T>(obj: T) => Partial<T>;
|
|
5
|
-
export declare const filterUndefinedValues: <T>(values: T[]) => T[];
|
|
3
|
+
export declare const isUndefined: <T>(value: T, allowNull?: boolean) => boolean;
|
|
4
|
+
export declare const reduceUndefinedValues: <T>(obj: T, allowNull?: boolean) => Partial<T>;
|
|
5
|
+
export declare const filterUndefinedValues: <T>(values: T[], allowNull?: boolean) => T[];
|
package/dist/utils.js
CHANGED
|
@@ -10,6 +10,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
13
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
30
|
exports.filterUndefinedValues = exports.reduceUndefinedValues = exports.isUndefined = exports.isIri = exports.isEmpty = void 0;
|
|
15
31
|
var isEmpty = function (value, minKeys) {
|
|
@@ -25,18 +41,25 @@ var isEmpty = function (value, minKeys) {
|
|
|
25
41
|
exports.isEmpty = isEmpty;
|
|
26
42
|
var isIri = function (value) { return (value || '').startsWith('http'); };
|
|
27
43
|
exports.isIri = isIri;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
/* eslint-disable complexity */
|
|
45
|
+
var isUndefined = function (value, allowNull) {
|
|
46
|
+
if (allowNull === void 0) { allowNull = false; }
|
|
47
|
+
return (value === null && !allowNull) ||
|
|
48
|
+
typeof value === 'undefined' || (typeof value === 'object' && value !== null && !(value instanceof Date) && !Object.keys(value).length);
|
|
31
49
|
};
|
|
32
50
|
exports.isUndefined = isUndefined;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
/* eslint-enable complexity */
|
|
52
|
+
var reduceUndefinedValues = function (obj, allowNull) {
|
|
53
|
+
if (allowNull === void 0) { allowNull = false; }
|
|
54
|
+
return Object.entries(obj).reduce(function (prev, _a) {
|
|
55
|
+
var _b;
|
|
56
|
+
var _c = __read(_a, 2), key = _c[0], value = _c[1];
|
|
57
|
+
return __assign(__assign({}, prev), (exports.isUndefined(value, allowNull) ? {} : (_b = {}, _b[key] = value, _b)));
|
|
38
58
|
}, {});
|
|
39
59
|
};
|
|
40
60
|
exports.reduceUndefinedValues = reduceUndefinedValues;
|
|
41
|
-
var filterUndefinedValues = function (values
|
|
61
|
+
var filterUndefinedValues = function (values, allowNull) {
|
|
62
|
+
if (allowNull === void 0) { allowNull = false; }
|
|
63
|
+
return values.filter(function (value) { return !exports.isUndefined(value, allowNull); });
|
|
64
|
+
};
|
|
42
65
|
exports.filterUndefinedValues = filterUndefinedValues;
|
package/dist/validate-terms.js
CHANGED
|
@@ -63,7 +63,7 @@ var path_1 = require("path");
|
|
|
63
63
|
var https_1 = require("https");
|
|
64
64
|
var array_1 = require("./array");
|
|
65
65
|
var API_URL = process.env.API_URL;
|
|
66
|
-
var _a = __read(process.argv.slice(2),
|
|
66
|
+
var _a = __read(process.argv.slice(2), 2), folder = _a[0], extension = _a[1];
|
|
67
67
|
var readdir = fs_1.promises.readdir, lstat = fs_1.promises.lstat, readFile = fs_1.promises.readFile;
|
|
68
68
|
var encoding = 'utf8';
|
|
69
69
|
var Term = /** @class */ (function () {
|
|
@@ -104,7 +104,7 @@ var recursiveFiles = function (directory) { return __awaiter(void 0, void 0, voi
|
|
|
104
104
|
_a = _b.sent();
|
|
105
105
|
return [3 /*break*/, 4];
|
|
106
106
|
case 3:
|
|
107
|
-
_a = (path_1.join(directory, entry).endsWith('
|
|
107
|
+
_a = (path_1.join(directory, entry).endsWith("." + (extension || 'jsonld')) ? [path_1.join(directory, entry)] : []);
|
|
108
108
|
_b.label = 4;
|
|
109
109
|
case 4: return [2 /*return*/, _a];
|
|
110
110
|
}
|