nhb-toolbox
Version:
A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.
14 lines (13 loc) • 637 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.palindromePlugin = void 0;
const guards_1 = require("../../string/guards");
/** * Plugin to inject `isPalindromeDate` method */
const palindromePlugin = (ChronosClass) => {
ChronosClass.prototype.isPalindromeDate = function (shortYear = false) {
const padded = this.formatStrict(shortYear ? 'YY-MM-DD' : 'YYYY-MM-DD');
const normal = this.formatStrict(shortYear ? 'YY-M-D' : 'YYYY-M-D');
return (0, guards_1.isPalindrome)(padded) || (0, guards_1.isPalindrome)(normal);
};
};
exports.palindromePlugin = palindromePlugin;