@oap75/utils
Version:
JavaScript utils for Subsocial blockchain.
15 lines (14 loc) • 630 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
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.toString();
};
exports.asString = asString;