@hestia-earth/utils
Advanced tools
Comparing version 0.11.1 to 0.11.2
export declare const isEmpty: (value: any, minKeys?: number) => boolean; | ||
export declare const isIri: (value?: string) => boolean; | ||
export declare const isUndefined: <T>(value: T) => boolean; | ||
export declare const reduceUndefinedValues: <T>(obj: T) => Partial<T>; | ||
export declare const filterUndefinedValues: <T>(values: T[]) => T[]; | ||
export declare const isUndefined: <T>(value: T, allowNull?: boolean) => boolean; | ||
export declare const reduceUndefinedValues: <T>(obj: T, allowNull?: boolean) => Partial<T>; | ||
export declare const filterUndefinedValues: <T>(values: T[], allowNull?: boolean) => T[]; |
@@ -13,2 +13,18 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,16 +45,23 @@ exports.filterUndefinedValues = exports.reduceUndefinedValues = exports.isUndefined = exports.isIri = exports.isEmpty = void 0; | ||
exports.isIri = isIri; | ||
var isUndefined = function (value) { | ||
return value === null || | ||
typeof value === 'undefined' || (typeof value === 'object' && !(value instanceof Date) && !Object.keys(value).length); | ||
/* eslint-disable complexity */ | ||
var isUndefined = function (value, allowNull) { | ||
if (allowNull === void 0) { allowNull = false; } | ||
return (value === null && !allowNull) || | ||
typeof value === 'undefined' || (typeof value === 'object' && value !== null && !(value instanceof Date) && !Object.keys(value).length); | ||
}; | ||
exports.isUndefined = isUndefined; | ||
var reduceUndefinedValues = function (obj) { | ||
return Object.keys(obj).reduce(function (prev, key) { | ||
var _a; | ||
var value = obj[key]; | ||
return __assign(__assign({}, prev), (exports.isUndefined(value) ? {} : (_a = {}, _a[key] = value, _a))); | ||
/* eslint-enable complexity */ | ||
var reduceUndefinedValues = function (obj, allowNull) { | ||
if (allowNull === void 0) { allowNull = false; } | ||
return Object.entries(obj).reduce(function (prev, _a) { | ||
var _b; | ||
var _c = __read(_a, 2), key = _c[0], value = _c[1]; | ||
return __assign(__assign({}, prev), (exports.isUndefined(value, allowNull) ? {} : (_b = {}, _b[key] = value, _b))); | ||
}, {}); | ||
}; | ||
exports.reduceUndefinedValues = reduceUndefinedValues; | ||
var filterUndefinedValues = function (values) { return values.filter(function (value) { return !exports.isUndefined(value); }); }; | ||
var filterUndefinedValues = function (values, allowNull) { | ||
if (allowNull === void 0) { allowNull = false; } | ||
return values.filter(function (value) { return !exports.isUndefined(value, allowNull); }); | ||
}; | ||
exports.filterUndefinedValues = filterUndefinedValues; |
@@ -66,3 +66,3 @@ "use strict"; | ||
var API_URL = process.env.API_URL; | ||
var _a = __read(process.argv.slice(2), 1), folder = _a[0]; | ||
var _a = __read(process.argv.slice(2), 2), folder = _a[0], extension = _a[1]; | ||
var readdir = fs_1.promises.readdir, lstat = fs_1.promises.lstat, readFile = fs_1.promises.readFile; | ||
@@ -108,3 +108,3 @@ var encoding = 'utf8'; | ||
case 3: | ||
_a = (path_1.join(directory, entry).endsWith('.jsonld') ? [path_1.join(directory, entry)] : []); | ||
_a = (path_1.join(directory, entry).endsWith("." + (extension || 'jsonld')) ? [path_1.join(directory, entry)] : []); | ||
_b.label = 4; | ||
@@ -111,0 +111,0 @@ case 4: return [2 /*return*/, _a]; |
{ | ||
"name": "@hestia-earth/utils", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Hestia Utils library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45367
1103