UNPKG

@subsocial/utils

Version:
19 lines (18 loc) 801 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.asStringArray = exports.asString = exports.nonEmptyStr = exports.isEmptyStr = exports.isStr = void 0; const defined_1 = require("./defined"); const isStr = (x) => typeof x === 'string'; exports.isStr = isStr; const isEmptyStr = (x) => (0, defined_1.notDefined)(x) || ((0, exports.isStr)(x) && x.trim().length === 0); exports.isEmptyStr = isEmptyStr; const nonEmptyStr = (x) => (0, exports.isStr)(x) && x.trim().length > 0; exports.nonEmptyStr = nonEmptyStr; const asString = (x) => { return typeof x === 'string' ? x : x === null || x === void 0 ? void 0 : x.toString(); }; exports.asString = asString; const asStringArray = (x) => { return x.map(exports.asString); }; exports.asStringArray = asStringArray;