hijri-ma
Version:
```sh npm install ```
33 lines (27 loc) • 938 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.wrapString = exports.zeroFill = void 0;
/**
* Adds 0 to the string representation for month that are less than 10,
* leave it as it is otherwise
*@example
* // returns "07"
* zeroFill(7)
* // returns "11"
* zeroFill(11)
* @param {Number} monthNumber the month number
* @returns {String} the month number as a string with a leading 0 if ncecessart
*/
const zeroFill = n => ('' + n).length < 2 ? '0' + n : '' + n;
/**
*Used to correctly wrap a string to use in a concatenation with different direction ( rtl and ltr)
*
* @param {String} str the string to wrap
* @param {Boolean} isRtl true if direction === 'rtl', false otherwise
* @returns {String} the wrapped string
*/
exports.zeroFill = zeroFill;
const wrapString = (str, isRtl) => isRtl ? '\u202B' + str + '\u202C' : '\u202A' + str + '\u202C';
exports.wrapString = wrapString;