ts-flex-query
Version:
Flexible and type-safe data queries
35 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.text = void 0;
const utils_1 = require("../helpers/utils");
exports.text = {
startsWith(v1, v2) {
return (0, utils_1.isDefined)(v1) && (0, utils_1.isDefined)(v2) && v1.startsWith(v2);
},
endsWith(v1, v2) {
return (0, utils_1.isDefined)(v1) && (0, utils_1.isDefined)(v2) && v1.endsWith(v2);
},
upperCase(v) {
return v === null || v === void 0 ? void 0 : v.toLocaleUpperCase();
},
lowerCase(v) {
return v === null || v === void 0 ? void 0 : v.toLocaleLowerCase();
},
concat(v1, v2) {
return (v1 !== null && v1 !== void 0 ? v1 : '') + (v2 !== null && v2 !== void 0 ? v2 : '');
},
contains(v1, v2) {
return (0, utils_1.isDefined)(v1) && (0, utils_1.isDefined)(v2) && v1.indexOf(v2) >= 0;
},
indexOf(v1, v2) {
return (0, utils_1.isDefined)(v1) && (0, utils_1.isDefined)(v2) ? v1.indexOf(v2) : -1;
},
getLength(v) {
return (v !== null && v !== void 0 ? v : '').length;
},
/** Converts the value to a string. No guarantuees are made on the string format. If the value cannot be converted to a string, undefined is returned. */
asString(v) {
return typeof (v === null || v === void 0 ? void 0 : v.toString) === 'function' ? v.toString() : undefined;
}
};
//# sourceMappingURL=text.js.map