Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yookue/ts-lang-utils

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yookue/ts-lang-utils - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

53

dist/cjs/util/BooleanUtils.d.ts

@@ -9,15 +9,54 @@ /**

/**
* Returns a boolean value from the string value, or undefined if the value cannot be converted
* Returns whether the given value can be converted to true
*
* @param {string | number} value the string value to check
* @param {number | string | null} value the source value to check
*
* @returns {boolean} a boolean value from the string value, or undefined if the value cannot be converted
* @returns {boolean} whether the given value can be converted to true
*
* @example
* BooleanUtils.toBoolean(1); // true
* BooleanUtils.toBoolean('true'); // true
* BooleanUtils.toBoolean('yes'); // true
* BooleanUtils.isTrue(1); // true
* BooleanUtils.isTrue('true'); // true
* BooleanUtils.isTrue('yes'); // true
*/
static toBoolean(value?: string | number): boolean | undefined;
static isTrue(value?: string | number | null): boolean;
/**
* Returns whether the given value is nil or can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to false
*
* @example
* BooleanUtils.isNotTrue(undefined); // true
* BooleanUtils.isNotTrue(null); // true
* BooleanUtils.isNotTrue('no'); // true
*/
static isNotTrue(value?: string | number | null): boolean;
/**
* Returns whether the given value can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value can be converted to false
*
* @example
* BooleanUtils.isFalse(0); // true
* BooleanUtils.isFalse('false'); // true
* BooleanUtils.isFalse('no'); // true
*/
static isFalse(value?: string | number | null): boolean;
/**
* Returns whether the given value is nil or can be converted to true
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to true
*
* @example
* BooleanUtils.isNotFalse(undefined); // true
* BooleanUtils.isNotFalse(null); // true
* BooleanUtils.isNotFalse('yes'); // true
*/
static isNotFalse(value?: string | number | null): boolean;
/**
* Returns a string value from the boolean value

@@ -24,0 +63,0 @@ *

@@ -29,27 +29,72 @@ var __defProp = Object.defineProperty;

/**
* Returns a boolean value from the string value, or undefined if the value cannot be converted
* Returns whether the given value can be converted to true
*
* @param {string | number} value the string value to check
* @param {number | string | null} value the source value to check
*
* @returns {boolean} a boolean value from the string value, or undefined if the value cannot be converted
* @returns {boolean} whether the given value can be converted to true
*
* @example
* BooleanUtils.toBoolean(1); // true
* BooleanUtils.toBoolean('true'); // true
* BooleanUtils.toBoolean('yes'); // true
* BooleanUtils.isTrue(1); // true
* BooleanUtils.isTrue('true'); // true
* BooleanUtils.isTrue('yes'); // true
*/
static toBoolean(value) {
static isTrue(value) {
if (typeof value === "number") {
return value > 0;
} else if (typeof value === "string") {
if (import_StringUtils.StringUtils.equalsAnyIgnoreCase(value, ["true", "yes", "on", "y", "t", "1"])) {
return true;
}
if (import_StringUtils.StringUtils.equalsAnyIgnoreCase(value, ["false", "no", "off", "n", "f", "0"])) {
return false;
}
return import_StringUtils.StringUtils.equalsAnyIgnoreCase(value, ["true", "yes", "on", "y", "t", "1"]);
}
return void 0;
return false;
}
/**
* Returns whether the given value is nil or can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to false
*
* @example
* BooleanUtils.isNotTrue(undefined); // true
* BooleanUtils.isNotTrue(null); // true
* BooleanUtils.isNotTrue('no'); // true
*/
static isNotTrue(value) {
return value === void 0 || value === null || this.isFalse(value);
}
/**
* Returns whether the given value can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value can be converted to false
*
* @example
* BooleanUtils.isFalse(0); // true
* BooleanUtils.isFalse('false'); // true
* BooleanUtils.isFalse('no'); // true
*/
static isFalse(value) {
if (typeof value === "number") {
return value <= 0;
} else if (typeof value === "string") {
return import_StringUtils.StringUtils.equalsAnyIgnoreCase(value, ["false", "no", "off", "n", "f", "0"]);
}
return false;
}
/**
* Returns whether the given value is nil or can be converted to true
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to true
*
* @example
* BooleanUtils.isNotFalse(undefined); // true
* BooleanUtils.isNotFalse(null); // true
* BooleanUtils.isNotFalse('yes'); // true
*/
static isNotFalse(value) {
return value === void 0 || value === null || this.isTrue(value);
}
/**
* Returns a string value from the boolean value

@@ -56,0 +101,0 @@ *

@@ -9,15 +9,54 @@ /**

/**
* Returns a boolean value from the string value, or undefined if the value cannot be converted
* Returns whether the given value can be converted to true
*
* @param {string | number} value the string value to check
* @param {number | string | null} value the source value to check
*
* @returns {boolean} a boolean value from the string value, or undefined if the value cannot be converted
* @returns {boolean} whether the given value can be converted to true
*
* @example
* BooleanUtils.toBoolean(1); // true
* BooleanUtils.toBoolean('true'); // true
* BooleanUtils.toBoolean('yes'); // true
* BooleanUtils.isTrue(1); // true
* BooleanUtils.isTrue('true'); // true
* BooleanUtils.isTrue('yes'); // true
*/
static toBoolean(value?: string | number): boolean | undefined;
static isTrue(value?: string | number | null): boolean;
/**
* Returns whether the given value is nil or can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to false
*
* @example
* BooleanUtils.isNotTrue(undefined); // true
* BooleanUtils.isNotTrue(null); // true
* BooleanUtils.isNotTrue('no'); // true
*/
static isNotTrue(value?: string | number | null): boolean;
/**
* Returns whether the given value can be converted to false
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value can be converted to false
*
* @example
* BooleanUtils.isFalse(0); // true
* BooleanUtils.isFalse('false'); // true
* BooleanUtils.isFalse('no'); // true
*/
static isFalse(value?: string | number | null): boolean;
/**
* Returns whether the given value is nil or can be converted to true
*
* @param {number | string | null} value the source value to check
*
* @returns {boolean} whether the given value is nil or can be converted to true
*
* @example
* BooleanUtils.isNotFalse(undefined); // true
* BooleanUtils.isNotFalse(null); // true
* BooleanUtils.isNotFalse('yes'); // true
*/
static isNotFalse(value?: string | number | null): boolean;
/**
* Returns a string value from the boolean value

@@ -24,0 +63,0 @@ *

33

dist/esm/util/BooleanUtils.js

@@ -10,17 +10,32 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

_createClass(BooleanUtils, null, [{
key: "toBoolean",
value: function toBoolean(value) {
key: "isTrue",
value: function isTrue(value) {
if (typeof value === 'number') {
return value > 0;
} else if (typeof value === 'string') {
if (StringUtils.equalsAnyIgnoreCase(value, ['true', 'yes', 'on', 'y', 't', '1'])) {
return true;
}
if (StringUtils.equalsAnyIgnoreCase(value, ['false', 'no', 'off', 'n', 'f', '0'])) {
return false;
}
return StringUtils.equalsAnyIgnoreCase(value, ['true', 'yes', 'on', 'y', 't', '1']);
}
return undefined;
return false;
}
}, {
key: "isNotTrue",
value: function isNotTrue(value) {
return value === undefined || value === null || this.isFalse(value);
}
}, {
key: "isFalse",
value: function isFalse(value) {
if (typeof value === 'number') {
return value <= 0;
} else if (typeof value === 'string') {
return StringUtils.equalsAnyIgnoreCase(value, ['false', 'no', 'off', 'n', 'f', '0']);
}
return false;
}
}, {
key: "isNotFalse",
value: function isNotFalse(value) {
return value === undefined || value === null || this.isTrue(value);
}
}, {
key: "toString",

@@ -27,0 +42,0 @@ value: function toString(value, truthy, falsy, nil) {

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TsLangUtils=e():t.TsLangUtils=e()}(self,(function(){return function(){var t={317:function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.__esModule=!0,t.exports.default=t.exports},486:function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},702:function(t,e,n){var r=n(281);function u(t,e){for(var n=0;n<e.length;n++){var u=e[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,r(u.key),u)}}t.exports=function(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},746:function(t,e,n){var r=n(508);t.exports=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var u=0,o=function(){};return{s:o,n:function(){return u>=t.length?{done:!0}:{done:!1,value:t[u++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw i}}}},t.exports.__esModule=!0,t.exports.default=t.exports},224:function(t,e,n){var r=n(944).default;t.exports=function(t,e){if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var u=n.call(t,e||"default");if("object"!=r(u))return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},281:function(t,e,n){var r=n(944).default,u=n(224);t.exports=function(t){var e=u(t,"string");return"symbol"==r(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},944:function(t){function e(n){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},508:function(t,e,n){var r=n(317);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function n(r){var u=e[r];if(void 0!==u)return u.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{ArrayUtils:function(){return v},BooleanUtils:function(){return h},DateUtils:function(){return g},JsonUtils:function(){return p},NumberUtils:function(){return d},ObjectUtils:function(){return f},RandomUtils:function(){return m},RegexUtils:function(){return c},StringUtils:function(){return y},ThreadUtils:function(){return k}});var t=n(746),e=n.n(t),u=n(944),o=n.n(u),i=n(486),a=n.n(i),l=n(702),s=n.n(l),f=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isNil",value:function(t){return null==t}},{key:"isNotNil",value:function(t){return!this.isNil(t)}},{key:"isNull",value:function(t){return null===t}},{key:"isNotNull",value:function(t){return!this.isNull(t)}},{key:"isUndefined",value:function(t){return void 0===t}},{key:"isNotUndefined",value:function(t){return!this.isUndefined(t)}},{key:"isEmpty",value:function(t){return!t||("string"==typeof t||Array.isArray(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"object"===o()(t)&&0===(null===(e=this.keys(t))||void 0===e?void 0:e.length));var e}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isPlainObject",value:function(t){return"object"===o()(t)&&"[object Object]"===Object.prototype.toString.call(t)}},{key:"isPromiseObject",value:function(t){return"object"===o()(t)&&"[object Promise]"===Object.prototype.toString.call(t)}},{key:"isPrototype",value:function(t){if("object"!==o()(t))return!1;var e=t.constructor;return t===("function"==typeof e?e.prototype:t.prototype)}},{key:"allNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||!n.some((function(e){return t.isNotNil(e)}))}},{key:"allNotNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&!n.some((function(e){return t.isNil(e)}))}},{key:"anyNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||n.some((function(e){return t.isNil(e)}))}},{key:"anyNotNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&n.some((function(e){return t.isNotNil(e)}))}},{key:"allEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||!n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&!n.some((function(e){return t.isEmpty(e)}))}},{key:"anyEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||n.some((function(e){return t.isEmpty(e)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&n.some((function(e){return t.isNotEmpty(e)}))}},{key:"firstNonNil",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(!e||0===e.length)return null;for(var r=0,u=e;r<u.length;r++){var o=u[r];if(this.isNotNil(o))return o}return null}},{key:"getProperty",value:function(t,e){if(!this.anyNil(t,e)&&"object"===o()(t)&&0!==(null==e?void 0:e.length)){var n=e.replace(/\[/g,".").replace(/]/g,"").split(".");if(n&&0!==(null==n?void 0:n.length))return 1===(null==n?void 0:n.length)?t[n[0]]:n.reduce((function(t,e){return(t||{})[e]}),t)}}},{key:"hasProperty",value:function(t,e){return this.allNotNil(t,e)&&"object"===o()(t)&&(null==e?void 0:e.length)>0&&Object.prototype.hasOwnProperty.call(t,e)}},{key:"keys",value:function(t){if(!t)return[];if(!this.isPrototype(t))return Object.keys(t);var e=[];for(var n in Object(t))"constructor"!==n&&this.hasProperty(t,n)&&e.push(n);return e}},{key:"toString",value:function(t,e){return t?t.toString():e}}]),t}(),c=function(){function t(){a()(this,t)}return s()(t,null,[{key:"extractWords",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;return t&&0!==t.length&&t.match(e)||void 0}}]),t}(),y=function(){function t(){a()(this,t)}return s()(t,null,[{key:"getLength",value:function(t){return t?t.length:0}},{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isBlank",value:function(t){return!t||0===(null==t?void 0:t.length)||/^\s*$/.test(t)}},{key:"isNotBlank",value:function(t){return!this.isBlank(t)}},{key:"allEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||!n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&!n.some((function(e){return t.isEmpty(e)}))}},{key:"anyEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||n.some((function(e){return t.isEmpty(e)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&(null==n?void 0:n.length)>0&&n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||!n.some((function(e){return t.isNotBlank(e)}))}},{key:"allNotBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&!n.some((function(e){return t.isBlank(e)}))}},{key:"anyBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||n.some((function(e){return t.isBlank(e)}))}},{key:"anyNotBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&n.some((function(e){return t.isNotBlank(e)}))}},{key:"appendIfMissing",value:function(t,e){return!t||this.isEmpty(e)||this.endsWith(t,e)?t:t+e}},{key:"appendIfMissingIgnoreCase",value:function(t,e){return!t||this.isEmpty(e)||this.endsWithIgnoreCase(t,e)?t:t+e}},{key:"capitalizeFirst",value:function(t){return t&&0!==t.length?t.substring(0,1).toUpperCase()+t.substring(1):void 0}},{key:"defaultString",value:function(t){return t||""}},{key:"defaultIfEmpty",value:function(t,e){return this.isEmpty(t)?e:t}},{key:"defaultIfBlank",value:function(t,e){return this.isBlank(t)?e:t}},{key:"endsWith",value:function(t,e){return t&&e?!(t.length<e.length)&&t.endsWith(e):t===e}},{key:"endsWithIgnoreCase",value:function(t,e){return t&&e?!(t.length<e.length)&&t.toLowerCase().endsWith(e.toLowerCase()):t===e}},{key:"endsWithAny",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.endsWith(t,e)}))}},{key:"endsWithAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.endsWithIgnoreCase(t,e)}))}},{key:"equals",value:function(t,e){return t===e||!t&&!e||!(!t||!e||(null==t?void 0:t.length)!==(null==e?void 0:e.length))&&t===e}},{key:"equalsIgnoreCase",value:function(t,e){return t===e||!t&&!e||!(!t||!e||(null==t?void 0:t.length)!==(null==e?void 0:e.length))&&(null==t?void 0:t.toUpperCase())===(null==e?void 0:e.toUpperCase())}},{key:"equalsAny",value:function(t,e){return v.includes(e,t)}},{key:"equalsAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.equalsIgnoreCase(t,e)}))}},{key:"formatBrace",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(!t||t.length<=2||!n||0===n.length)return t;for(var u=t,o=0,i=n;o<i.length;o++){var a=i[o];u=u.replace("{}",f.toString(a,""))}return u}},{key:"formatPercent",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(!t||t.length<=2||!n||0===n.length)return t;var u=t.match(/%[bcdfjosxX]/g)||[],o=v.minLength(u,n);if(0===o)return t;for(var i=t,a=0;a<o;a++){var l=n[a],s=u[a].substring(1);switch(s){case"b":case"c":case"d":case"o":case"x":case"X":try{var c=void 0;"string"==typeof l?c=Number.parseInt(l):l instanceof String?c=Number.parseInt(l.toString()):"number"==typeof l&&(c=l),c&&("b"===s?i=i.replace("%".concat(s),c.toString(2)):"c"===s?i=i.replace("%".concat(s),String.fromCharCode(c)):"d"===s?i=i.replace("%".concat(s),c.toString(10)):"o"===s?i=i.replace("%".concat(s),"0"+c.toString(8)):"x"===s?i=i.replace("%".concat(s),"0x"+c.toString(16)):"X"===s&&(i=i.replace("%".concat(s),"0x"+c.toString(16).toUpperCase())))}catch(t){throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a))}break;case"f":try{var y=void 0;"string"==typeof l?y=Number.parseFloat(l):l instanceof String?y=Number.parseFloat(l.toString()):"number"==typeof l&&(y=l),y&&(i=i.replace("%".concat(s),"0x"+y.toString()))}catch(t){throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a))}break;case"j":if(null==l){i=i.replace("%".concat(s),"");break}if(f.isPlainObject(l)){i=i.replace("%".concat(s),JSON.stringify(l));break}throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a));case"s":i=i.replace("%".concat(s),f.toString(l,""))}}return i}},{key:"formatPlaceholder",value:function(t,e){if(!t||t.length<=2||!e)return t;var n=t;for(var r in e){var u=new RegExp("\\{".concat(r,"\\}"),"g"),o=e[r];n=n.replace(u,o?o.toString():"")}return n}},{key:"includes",value:function(t,e){return t===e||!!t&&!!e&&t.includes(e)}},{key:"includesIgnoreCase",value:function(t,e){var n;return t===e||!!t&&!!e&&(null==t||null===(n=t.toUpperCase())||void 0===n?void 0:n.includes(null==e?void 0:e.toUpperCase()))}},{key:"includesAny",value:function(t,e){var n=this;return!(!t||!e)&&(null==e?void 0:e.some((function(e){return n.includes(t,e)})))}},{key:"includesAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&(null==e?void 0:e.some((function(e){return n.includesIgnoreCase(t,e)})))}},{key:"prependIfMissing",value:function(t,e){return!t||this.isEmpty(e)||this.startsWith(t,e)?t:e+t}},{key:"prependIfMissingIgnoreCase",value:function(t,e){return!t||this.isEmpty(e)||this.startsWithIgnoreCase(t,e)?t:e+t}},{key:"startsWith",value:function(t,e){return t&&e?!(t.length<e.length)&&t.startsWith(e):t===e}},{key:"startsWithIgnoreCase",value:function(t,e){return t&&e?!(t.length<e.length)&&t.toLowerCase().startsWith(e.toLowerCase()):t===e}},{key:"startsWithAny",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.startsWith(t,e)}))}},{key:"startsWithAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.startsWithIgnoreCase(t,e)}))}},{key:"substringAfter",value:function(t,e){if(t&&e&&0!==e.length){var n=t.indexOf(e);return-1===n?void 0:t.substring(n+e.length)}}},{key:"substringAfterLast",value:function(t,e){if(t&&e&&0!==e.length){var n=t.lastIndexOf(e);return-1===n?void 0:t.substring(n+e.length)}}},{key:"substringBefore",value:function(t,e){if(t&&e&&0!==e.length){var n=t.indexOf(e);return-1===n?void 0:t.substring(0,n)}}},{key:"substringBeforeLast",value:function(t,e){if(t&&e&&0!==e.length){var n=t.lastIndexOf(e);return-1===n?void 0:t.substring(0,n)}}},{key:"toCamelCase",value:function(t,e){var n=this;if(!t||0===t.length)return t;var r=c.extractWords(t,e);return r?r.reduce((function(t,e,r){return e=e.toLowerCase(),t+(r>0?n.capitalizeFirst(e):e)}),""):void 0}},{key:"toKebabCase",value:function(t,e){if(!t||0===t.length)return t;var n=c.extractWords(t,e);return n?n.reduce((function(t,e,n){return t+(n>0?"-":"")+e.toLowerCase()}),""):void 0}},{key:"trim",value:function(t,e){if(!t)return t;var n=t.trim();return e&&this.isEmpty(n)?null:n}}]),t}(),v=function(){function t(){a()(this,t)}return s()(t,null,[{key:"getLength",value:function(t){return t?t.length:0}},{key:"getTypeof",value:function(t){if(!this.isEmpty(t))return null==t?void 0:t.map((function(t){return Array.isArray(t)?"array":"object"===o()(t)?null===t?"null":"object":o()(t)}))}},{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isTypeof",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!this.isEmpty(t)&&!y.isBlank(e)&&(null==t?void 0:t.every((function(t){return o()(t)===e||n&&null===t&&y.equalsAny(e,["string","object"])})))}},{key:"includes",value:function(t,e){return f.allNotNil(t,e)&&t.includes(e)}},{key:"maxLength",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(this.isEmpty(e))return 0;for(var r=0,u=0,o=e;u<o.length;u++){var i=o[u];r=Math.max(r,this.getLength(i))}return r}},{key:"minLength",value:function(){for(var t,n=arguments.length,r=new Array(n),u=0;u<n;u++)r[u]=arguments[u];if(this.isEmpty(r))return 0;var o,i=null===(t=r[0])||void 0===t?void 0:t.length,a=e()(r.slice(1));try{for(a.s();!(o=a.n()).done;){var l=o.value;if(0===(i=Math.min(i,this.getLength(l))))break}}catch(t){a.e(t)}finally{a.f()}return i}},{key:"reverse",value:function(t,e,n){if(!this.isEmpty(t))for(var r=Math.max(e||0,0),u=Math.min(n||this.getLength(t),this.getLength(t))-1;t&&u>r;){var o=t[u];t[u]=t[r],t[r]=o,u--,r++}}}]),t}(),h=function(){function t(){a()(this,t)}return s()(t,null,[{key:"toBoolean",value:function(t){if("number"==typeof t)return t>0;if("string"==typeof t){if(y.equalsAnyIgnoreCase(t,["true","yes","on","y","t","1"]))return!0;if(y.equalsAnyIgnoreCase(t,["false","no","off","n","f","0"]))return!1}}},{key:"toString",value:function(t,e,n,r){return f.isNil(t)?r:t?e:n}},{key:"toStringTrueFalse",value:function(t){return this.toString(t,"true","false",void 0)}},{key:"toStringOnOff",value:function(t){return this.toString(t,"on","off",void 0)}},{key:"toStringYesNo",value:function(t){return this.toString(t,"yes","no",void 0)}},{key:"toStringYN",value:function(t){return this.toString(t,"Y","N",void 0)}},{key:"toStringTF",value:function(t){return this.toString(t,"T","F",void 0)}},{key:"toString10",value:function(t){return this.toString(t,"1","0",void 0)}}]),t}(),g=function(){function t(){a()(this,t)}return s()(t,null,[{key:"addYear",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setFullYear(t.getFullYear()+e),n}},{key:"addMonth",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setMonth(t.getMonth()+e),n}},{key:"addDay",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setDate(t.getDate()+e),n}},{key:"formatDateTime",value:function(t,e){if(!y.isBlank(e)){var n={"y+":t.getFullYear(),"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours()%12==0?12:t.getHours()%12,"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()},r=e;for(var u in n){var o=new RegExp("(".concat(u,")")).exec(r);o&&(r=/(y+)/.test(u)?r.replace(o[1],n[u].toString().substring(4-o[1].length)):r.replace(o[1],1===o[1].length?n[u].toString():n[u].toString().padStart(o[1].length,"0")))}return r}}},{key:"getCurrentDate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"yyyy-MM-dd";return this.formatDateTime(new Date,t)}},{key:"getCurrentDateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"yyyy-MM-dd hh:mm:ss";return this.formatDateTime(new Date,t)}},{key:"getCurrentTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hh:mm:ss";return this.formatDateTime(new Date,t)}},{key:"getStartOfYear",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear(),0,1),e.setHours(0,0,0,0),e}},{key:"getStartOfMonth",value:function(t){var e=new Date(t);return e.setDate(1),e.setHours(0,0,0,0),e}},{key:"getStartOfDay",value:function(t){var e=new Date(t);return e.setHours(0,0,0,0),e}},{key:"getEndOfYear",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear()+1,0,0),e.setHours(23,59,59,999),e}},{key:"getEndOfMonth",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear(),t.getMonth()+1,0),e.setHours(23,59,59,999),e}},{key:"getEndOfDay",value:function(t){var e=new Date(t);return e.setHours(23,59,59,999),e}},{key:"getTimezone",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=t.getTimezoneOffset(),n=Math.abs(e),r=Math.floor(n/60),u=n%60,o=u>0?":"+("0"+u).slice(-2):"";return(e<0?"+":"-")+r+o}},{key:"isFirstDayOfMonth",value:function(t){return 1===t.getDate()}},{key:"isLastDayOfMonth",value:function(t){return this.isSameDay(this.getEndOfDay(t),this.getEndOfMonth(t))}},{key:"isLeapYear",value:function(t){var e=t instanceof Date?t.getFullYear():t;return!((e%4||!(e%100))&&e%400)}},{key:"isSameYear",value:function(t,e){return t.getFullYear()===e.getFullYear()}},{key:"isSameMonth",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.getMonth()===e.getMonth()&&(!n||t.getFullYear()===e.getFullYear())}},{key:"isSameDay",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.getDate()===e.getDate()&&(!n||t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth())}},{key:"isWeekend",value:function(t){return 0===t.getDay()||6===t.getDay()}},{key:"isYesterday",value:function(t){return this.isSameDay(new Date,this.addDay(t,1))}},{key:"isTomorrow",value:function(t){return this.isSameDay(new Date,this.addDay(t,-1))}}]),t}(),p=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isJsonString",value:function(t){if(y.isBlank(t))return!1;try{if("object"===o()(JSON.parse(t)))return!0}catch(t){}return!1}},{key:"toJsonString",value:function(t){if("string"==typeof t&&t.length>0)try{var e=JSON.parse(t);if("object"===o()(e))return JSON.stringify(e)}catch(t){}if(f.isPlainObject(t))return JSON.stringify(t)}}]),t}(),d=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isInteger",value:function(t){return!!t&&Math.floor(t)===Math.ceil(t)}},{key:"toInteger",value:function(t){if(t)try{var e=Number.parseInt(t);return Number.isNaN(e)?void 0:e}catch(t){}}},{key:"toFloat",value:function(t){if(t)try{var e=Number.parseFloat(t);return Number.isNaN(e)?void 0:e}catch(t){}}},{key:"max",value:function(t){if(t&&0!==(null==t?void 0:t.length)){for(var e=t[0],n=1;n<t.length;n++)e<t[n]&&(e=t[n]);return e}}},{key:"min",value:function(t){if(t&&0!==(null==t?void 0:t.length)){for(var e=t[0],n=1;n<t.length;n++)e>t[n]&&(e=t[n]);return e}}},{key:"sum",value:function(t){return t.reduce((function(t,e){return t+e}))}},{key:"average",value:function(t){return this.sum(t)/t.length}}]),t}(),m=function(){function t(){a()(this,t)}return s()(t,null,[{key:"randomBoolean",value:function(){return Math.random()>=.5}},{key:"randomElement",value:function(t){return v.isNotEmpty(t)?t.at(this.randomInteger(0,t.length)):void 0}},{key:"randomElements",value:function(t,e){if(v.isEmpty(t)||e<=0)return[];if(v.getLength(t)<=e)return t;for(var n=new Set;n.size<e;)n.add(this.randomInteger(0,t.length));return t.filter((function(t,e){return n.has(e)}))}},{key:"randomInteger",value:function(t,e){return Math.floor(this.randomNumber(t,e))}},{key:"randomIntegers",value:function(t,e,n){if(t<=0)return[];for(var r=[],u=0;u<t;u++)r.push(this.randomInteger(e,n));return r}},{key:"randomNumber",value:function(t,e){var n=t||0,r=e||Number.MAX_SAFE_INTEGER-1;if(n>r)throw SyntaxError("The min value must not be greater than max value");return n===r?n:n+(r-n)*Math.random()}},{key:"randomNumbers",value:function(t,e,n){if(t<=0)return[];for(var r=[],u=0;u<t;u++)r.push(this.randomNumber(e,n));return r}}]),t}(),k=function(){function t(){a()(this,t)}return s()(t,null,[{key:"sleep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(e){setTimeout(e,t)}))}}]),t}()}(),r}()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TsLangUtils=e():t.TsLangUtils=e()}(self,(function(){return function(){var t={317:function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.__esModule=!0,t.exports.default=t.exports},486:function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},702:function(t,e,n){var r=n(281);function u(t,e){for(var n=0;n<e.length;n++){var u=e[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,r(u.key),u)}}t.exports=function(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},746:function(t,e,n){var r=n(508);t.exports=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var u=0,o=function(){};return{s:o,n:function(){return u>=t.length?{done:!0}:{done:!1,value:t[u++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw i}}}},t.exports.__esModule=!0,t.exports.default=t.exports},224:function(t,e,n){var r=n(944).default;t.exports=function(t,e){if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var u=n.call(t,e||"default");if("object"!=r(u))return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},281:function(t,e,n){var r=n(944).default,u=n(224);t.exports=function(t){var e=u(t,"string");return"symbol"==r(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},944:function(t){function e(n){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},508:function(t,e,n){var r=n(317);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function n(r){var u=e[r];if(void 0!==u)return u.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{ArrayUtils:function(){return v},BooleanUtils:function(){return h},DateUtils:function(){return g},JsonUtils:function(){return p},NumberUtils:function(){return d},ObjectUtils:function(){return f},RandomUtils:function(){return m},RegexUtils:function(){return c},StringUtils:function(){return y},ThreadUtils:function(){return k}});var t=n(746),e=n.n(t),u=n(944),o=n.n(u),i=n(486),a=n.n(i),l=n(702),s=n.n(l),f=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isNil",value:function(t){return null==t}},{key:"isNotNil",value:function(t){return!this.isNil(t)}},{key:"isNull",value:function(t){return null===t}},{key:"isNotNull",value:function(t){return!this.isNull(t)}},{key:"isUndefined",value:function(t){return void 0===t}},{key:"isNotUndefined",value:function(t){return!this.isUndefined(t)}},{key:"isEmpty",value:function(t){return!t||("string"==typeof t||Array.isArray(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"object"===o()(t)&&0===(null===(e=this.keys(t))||void 0===e?void 0:e.length));var e}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isPlainObject",value:function(t){return"object"===o()(t)&&"[object Object]"===Object.prototype.toString.call(t)}},{key:"isPromiseObject",value:function(t){return"object"===o()(t)&&"[object Promise]"===Object.prototype.toString.call(t)}},{key:"isPrototype",value:function(t){if("object"!==o()(t))return!1;var e=t.constructor;return t===("function"==typeof e?e.prototype:t.prototype)}},{key:"allNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||!n.some((function(e){return t.isNotNil(e)}))}},{key:"allNotNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&!n.some((function(e){return t.isNil(e)}))}},{key:"anyNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||n.some((function(e){return t.isNil(e)}))}},{key:"anyNotNil",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&n.some((function(e){return t.isNotNil(e)}))}},{key:"allEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||!n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&!n.some((function(e){return t.isEmpty(e)}))}},{key:"anyEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isEmpty(n)||n.some((function(e){return t.isEmpty(e)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.isNotEmpty(n)&&n.some((function(e){return t.isNotEmpty(e)}))}},{key:"firstNonNil",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(!e||0===e.length)return null;for(var r=0,u=e;r<u.length;r++){var o=u[r];if(this.isNotNil(o))return o}return null}},{key:"getProperty",value:function(t,e){if(!this.anyNil(t,e)&&"object"===o()(t)&&0!==(null==e?void 0:e.length)){var n=e.replace(/\[/g,".").replace(/]/g,"").split(".");if(n&&0!==(null==n?void 0:n.length))return 1===(null==n?void 0:n.length)?t[n[0]]:n.reduce((function(t,e){return(t||{})[e]}),t)}}},{key:"hasProperty",value:function(t,e){return this.allNotNil(t,e)&&"object"===o()(t)&&(null==e?void 0:e.length)>0&&Object.prototype.hasOwnProperty.call(t,e)}},{key:"keys",value:function(t){if(!t)return[];if(!this.isPrototype(t))return Object.keys(t);var e=[];for(var n in Object(t))"constructor"!==n&&this.hasProperty(t,n)&&e.push(n);return e}},{key:"toString",value:function(t,e){return t?t.toString():e}}]),t}(),c=function(){function t(){a()(this,t)}return s()(t,null,[{key:"extractWords",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;return t&&0!==t.length&&t.match(e)||void 0}}]),t}(),y=function(){function t(){a()(this,t)}return s()(t,null,[{key:"getLength",value:function(t){return t?t.length:0}},{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isBlank",value:function(t){return!t||0===(null==t?void 0:t.length)||/^\s*$/.test(t)}},{key:"isNotBlank",value:function(t){return!this.isBlank(t)}},{key:"allEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||!n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&!n.some((function(e){return t.isEmpty(e)}))}},{key:"anyEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||n.some((function(e){return t.isEmpty(e)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&(null==n?void 0:n.length)>0&&n.some((function(e){return t.isNotEmpty(e)}))}},{key:"allBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||!n.some((function(e){return t.isNotBlank(e)}))}},{key:"allNotBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&!n.some((function(e){return t.isBlank(e)}))}},{key:"anyBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return!n||0===n.length||n.some((function(e){return t.isBlank(e)}))}},{key:"anyNotBlank",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n&&n.length>0&&n.some((function(e){return t.isNotBlank(e)}))}},{key:"appendIfMissing",value:function(t,e){return!t||this.isEmpty(e)||this.endsWith(t,e)?t:t+e}},{key:"appendIfMissingIgnoreCase",value:function(t,e){return!t||this.isEmpty(e)||this.endsWithIgnoreCase(t,e)?t:t+e}},{key:"capitalizeFirst",value:function(t){return t&&0!==t.length?t.substring(0,1).toUpperCase()+t.substring(1):void 0}},{key:"defaultString",value:function(t){return t||""}},{key:"defaultIfEmpty",value:function(t,e){return this.isEmpty(t)?e:t}},{key:"defaultIfBlank",value:function(t,e){return this.isBlank(t)?e:t}},{key:"endsWith",value:function(t,e){return t&&e?!(t.length<e.length)&&t.endsWith(e):t===e}},{key:"endsWithIgnoreCase",value:function(t,e){return t&&e?!(t.length<e.length)&&t.toLowerCase().endsWith(e.toLowerCase()):t===e}},{key:"endsWithAny",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.endsWith(t,e)}))}},{key:"endsWithAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.endsWithIgnoreCase(t,e)}))}},{key:"equals",value:function(t,e){return t===e||!t&&!e||!(!t||!e||(null==t?void 0:t.length)!==(null==e?void 0:e.length))&&t===e}},{key:"equalsIgnoreCase",value:function(t,e){return t===e||!t&&!e||!(!t||!e||(null==t?void 0:t.length)!==(null==e?void 0:e.length))&&(null==t?void 0:t.toUpperCase())===(null==e?void 0:e.toUpperCase())}},{key:"equalsAny",value:function(t,e){return v.includes(e,t)}},{key:"equalsAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.equalsIgnoreCase(t,e)}))}},{key:"formatBrace",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(!t||t.length<=2||!n||0===n.length)return t;for(var u=t,o=0,i=n;o<i.length;o++){var a=i[o];u=u.replace("{}",f.toString(a,""))}return u}},{key:"formatPercent",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(!t||t.length<=2||!n||0===n.length)return t;var u=t.match(/%[bcdfjosxX]/g)||[],o=v.minLength(u,n);if(0===o)return t;for(var i=t,a=0;a<o;a++){var l=n[a],s=u[a].substring(1);switch(s){case"b":case"c":case"d":case"o":case"x":case"X":try{var c=void 0;"string"==typeof l?c=Number.parseInt(l):l instanceof String?c=Number.parseInt(l.toString()):"number"==typeof l&&(c=l),c&&("b"===s?i=i.replace("%".concat(s),c.toString(2)):"c"===s?i=i.replace("%".concat(s),String.fromCharCode(c)):"d"===s?i=i.replace("%".concat(s),c.toString(10)):"o"===s?i=i.replace("%".concat(s),"0"+c.toString(8)):"x"===s?i=i.replace("%".concat(s),"0x"+c.toString(16)):"X"===s&&(i=i.replace("%".concat(s),"0x"+c.toString(16).toUpperCase())))}catch(t){throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a))}break;case"f":try{var y=void 0;"string"==typeof l?y=Number.parseFloat(l):l instanceof String?y=Number.parseFloat(l.toString()):"number"==typeof l&&(y=l),y&&(i=i.replace("%".concat(s),"0x"+y.toString()))}catch(t){throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a))}break;case"j":if(null==l){i=i.replace("%".concat(s),"");break}if(f.isPlainObject(l)){i=i.replace("%".concat(s),JSON.stringify(l));break}throw new TypeError("Invalid parameter type of '".concat(l,"', index ").concat(a));case"s":i=i.replace("%".concat(s),f.toString(l,""))}}return i}},{key:"formatPlaceholder",value:function(t,e){if(!t||t.length<=2||!e)return t;var n=t;for(var r in e){var u=new RegExp("\\{".concat(r,"\\}"),"g"),o=e[r];n=n.replace(u,o?o.toString():"")}return n}},{key:"includes",value:function(t,e){return t===e||!!t&&!!e&&t.includes(e)}},{key:"includesIgnoreCase",value:function(t,e){var n;return t===e||!!t&&!!e&&(null==t||null===(n=t.toUpperCase())||void 0===n?void 0:n.includes(null==e?void 0:e.toUpperCase()))}},{key:"includesAny",value:function(t,e){var n=this;return!(!t||!e)&&(null==e?void 0:e.some((function(e){return n.includes(t,e)})))}},{key:"includesAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&(null==e?void 0:e.some((function(e){return n.includesIgnoreCase(t,e)})))}},{key:"prependIfMissing",value:function(t,e){return!t||this.isEmpty(e)||this.startsWith(t,e)?t:e+t}},{key:"prependIfMissingIgnoreCase",value:function(t,e){return!t||this.isEmpty(e)||this.startsWithIgnoreCase(t,e)?t:e+t}},{key:"startsWith",value:function(t,e){return t&&e?!(t.length<e.length)&&t.startsWith(e):t===e}},{key:"startsWithIgnoreCase",value:function(t,e){return t&&e?!(t.length<e.length)&&t.toLowerCase().startsWith(e.toLowerCase()):t===e}},{key:"startsWithAny",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.startsWith(t,e)}))}},{key:"startsWithAnyIgnoreCase",value:function(t,e){var n=this;return!(!t||!e||0===e.length)&&e.some((function(e){return n.startsWithIgnoreCase(t,e)}))}},{key:"substringAfter",value:function(t,e){if(t&&e&&0!==e.length){var n=t.indexOf(e);return-1===n?void 0:t.substring(n+e.length)}}},{key:"substringAfterLast",value:function(t,e){if(t&&e&&0!==e.length){var n=t.lastIndexOf(e);return-1===n?void 0:t.substring(n+e.length)}}},{key:"substringBefore",value:function(t,e){if(t&&e&&0!==e.length){var n=t.indexOf(e);return-1===n?void 0:t.substring(0,n)}}},{key:"substringBeforeLast",value:function(t,e){if(t&&e&&0!==e.length){var n=t.lastIndexOf(e);return-1===n?void 0:t.substring(0,n)}}},{key:"toCamelCase",value:function(t,e){var n=this;if(!t||0===t.length)return t;var r=c.extractWords(t,e);return r?r.reduce((function(t,e,r){return e=e.toLowerCase(),t+(r>0?n.capitalizeFirst(e):e)}),""):void 0}},{key:"toKebabCase",value:function(t,e){if(!t||0===t.length)return t;var n=c.extractWords(t,e);return n?n.reduce((function(t,e,n){return t+(n>0?"-":"")+e.toLowerCase()}),""):void 0}},{key:"trim",value:function(t,e){if(!t)return t;var n=t.trim();return e&&this.isEmpty(n)?null:n}}]),t}(),v=function(){function t(){a()(this,t)}return s()(t,null,[{key:"getLength",value:function(t){return t?t.length:0}},{key:"getTypeof",value:function(t){if(!this.isEmpty(t))return null==t?void 0:t.map((function(t){return Array.isArray(t)?"array":"object"===o()(t)?null===t?"null":"object":o()(t)}))}},{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isTypeof",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!this.isEmpty(t)&&!y.isBlank(e)&&(null==t?void 0:t.every((function(t){return o()(t)===e||n&&null===t&&y.equalsAny(e,["string","object"])})))}},{key:"includes",value:function(t,e){return f.allNotNil(t,e)&&t.includes(e)}},{key:"maxLength",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(this.isEmpty(e))return 0;for(var r=0,u=0,o=e;u<o.length;u++){var i=o[u];r=Math.max(r,this.getLength(i))}return r}},{key:"minLength",value:function(){for(var t,n=arguments.length,r=new Array(n),u=0;u<n;u++)r[u]=arguments[u];if(this.isEmpty(r))return 0;var o,i=null===(t=r[0])||void 0===t?void 0:t.length,a=e()(r.slice(1));try{for(a.s();!(o=a.n()).done;){var l=o.value;if(0===(i=Math.min(i,this.getLength(l))))break}}catch(t){a.e(t)}finally{a.f()}return i}},{key:"reverse",value:function(t,e,n){if(!this.isEmpty(t))for(var r=Math.max(e||0,0),u=Math.min(n||this.getLength(t),this.getLength(t))-1;t&&u>r;){var o=t[u];t[u]=t[r],t[r]=o,u--,r++}}}]),t}(),h=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isTrue",value:function(t){return"number"==typeof t?t>0:"string"==typeof t&&y.equalsAnyIgnoreCase(t,["true","yes","on","y","t","1"])}},{key:"isNotTrue",value:function(t){return null==t||this.isFalse(t)}},{key:"isFalse",value:function(t){return"number"==typeof t?t<=0:"string"==typeof t&&y.equalsAnyIgnoreCase(t,["false","no","off","n","f","0"])}},{key:"isNotFalse",value:function(t){return null==t||this.isTrue(t)}},{key:"toString",value:function(t,e,n,r){return f.isNil(t)?r:t?e:n}},{key:"toStringTrueFalse",value:function(t){return this.toString(t,"true","false",void 0)}},{key:"toStringOnOff",value:function(t){return this.toString(t,"on","off",void 0)}},{key:"toStringYesNo",value:function(t){return this.toString(t,"yes","no",void 0)}},{key:"toStringYN",value:function(t){return this.toString(t,"Y","N",void 0)}},{key:"toStringTF",value:function(t){return this.toString(t,"T","F",void 0)}},{key:"toString10",value:function(t){return this.toString(t,"1","0",void 0)}}]),t}(),g=function(){function t(){a()(this,t)}return s()(t,null,[{key:"addYear",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setFullYear(t.getFullYear()+e),n}},{key:"addMonth",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setMonth(t.getMonth()+e),n}},{key:"addDay",value:function(t,e){if(!e)return t;var n=new Date(t);return n.setDate(t.getDate()+e),n}},{key:"formatDateTime",value:function(t,e){if(!y.isBlank(e)){var n={"y+":t.getFullYear(),"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours()%12==0?12:t.getHours()%12,"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()},r=e;for(var u in n){var o=new RegExp("(".concat(u,")")).exec(r);o&&(r=/(y+)/.test(u)?r.replace(o[1],n[u].toString().substring(4-o[1].length)):r.replace(o[1],1===o[1].length?n[u].toString():n[u].toString().padStart(o[1].length,"0")))}return r}}},{key:"getCurrentDate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"yyyy-MM-dd";return this.formatDateTime(new Date,t)}},{key:"getCurrentDateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"yyyy-MM-dd hh:mm:ss";return this.formatDateTime(new Date,t)}},{key:"getCurrentTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hh:mm:ss";return this.formatDateTime(new Date,t)}},{key:"getStartOfYear",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear(),0,1),e.setHours(0,0,0,0),e}},{key:"getStartOfMonth",value:function(t){var e=new Date(t);return e.setDate(1),e.setHours(0,0,0,0),e}},{key:"getStartOfDay",value:function(t){var e=new Date(t);return e.setHours(0,0,0,0),e}},{key:"getEndOfYear",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear()+1,0,0),e.setHours(23,59,59,999),e}},{key:"getEndOfMonth",value:function(t){var e=new Date(t);return e.setFullYear(t.getFullYear(),t.getMonth()+1,0),e.setHours(23,59,59,999),e}},{key:"getEndOfDay",value:function(t){var e=new Date(t);return e.setHours(23,59,59,999),e}},{key:"getTimezone",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=t.getTimezoneOffset(),n=Math.abs(e),r=Math.floor(n/60),u=n%60,o=u>0?":"+("0"+u).slice(-2):"";return(e<0?"+":"-")+r+o}},{key:"isFirstDayOfMonth",value:function(t){return 1===t.getDate()}},{key:"isLastDayOfMonth",value:function(t){return this.isSameDay(this.getEndOfDay(t),this.getEndOfMonth(t))}},{key:"isLeapYear",value:function(t){var e=t instanceof Date?t.getFullYear():t;return!((e%4||!(e%100))&&e%400)}},{key:"isSameYear",value:function(t,e){return t.getFullYear()===e.getFullYear()}},{key:"isSameMonth",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.getMonth()===e.getMonth()&&(!n||t.getFullYear()===e.getFullYear())}},{key:"isSameDay",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.getDate()===e.getDate()&&(!n||t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth())}},{key:"isWeekend",value:function(t){return 0===t.getDay()||6===t.getDay()}},{key:"isYesterday",value:function(t){return this.isSameDay(new Date,this.addDay(t,1))}},{key:"isTomorrow",value:function(t){return this.isSameDay(new Date,this.addDay(t,-1))}}]),t}(),p=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isJsonString",value:function(t){if(y.isBlank(t))return!1;try{if("object"===o()(JSON.parse(t)))return!0}catch(t){}return!1}},{key:"toJsonString",value:function(t){if("string"==typeof t&&t.length>0)try{var e=JSON.parse(t);if("object"===o()(e))return JSON.stringify(e)}catch(t){}if(f.isPlainObject(t))return JSON.stringify(t)}}]),t}(),d=function(){function t(){a()(this,t)}return s()(t,null,[{key:"isInteger",value:function(t){return!!t&&Math.floor(t)===Math.ceil(t)}},{key:"toInteger",value:function(t){if(t)try{var e=Number.parseInt(t);return Number.isNaN(e)?void 0:e}catch(t){}}},{key:"toFloat",value:function(t){if(t)try{var e=Number.parseFloat(t);return Number.isNaN(e)?void 0:e}catch(t){}}},{key:"max",value:function(t){if(t&&0!==(null==t?void 0:t.length)){for(var e=t[0],n=1;n<t.length;n++)e<t[n]&&(e=t[n]);return e}}},{key:"min",value:function(t){if(t&&0!==(null==t?void 0:t.length)){for(var e=t[0],n=1;n<t.length;n++)e>t[n]&&(e=t[n]);return e}}},{key:"sum",value:function(t){return t.reduce((function(t,e){return t+e}))}},{key:"average",value:function(t){return this.sum(t)/t.length}}]),t}(),m=function(){function t(){a()(this,t)}return s()(t,null,[{key:"randomBoolean",value:function(){return Math.random()>=.5}},{key:"randomElement",value:function(t){return v.isNotEmpty(t)?t.at(this.randomInteger(0,t.length)):void 0}},{key:"randomElements",value:function(t,e){if(v.isEmpty(t)||e<=0)return[];if(v.getLength(t)<=e)return t;for(var n=new Set;n.size<e;)n.add(this.randomInteger(0,t.length));return t.filter((function(t,e){return n.has(e)}))}},{key:"randomInteger",value:function(t,e){return Math.floor(this.randomNumber(t,e))}},{key:"randomIntegers",value:function(t,e,n){if(t<=0)return[];for(var r=[],u=0;u<t;u++)r.push(this.randomInteger(e,n));return r}},{key:"randomNumber",value:function(t,e){var n=t||0,r=e||Number.MAX_SAFE_INTEGER-1;if(n>r)throw SyntaxError("The min value must not be greater than max value");return n===r?n:n+(r-n)*Math.random()}},{key:"randomNumbers",value:function(t,e,n){if(t<=0)return[];for(var r=[],u=0;u<t;u++)r.push(this.randomNumber(e,n));return r}}]),t}(),k=function(){function t(){a()(this,t)}return s()(t,null,[{key:"sleep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(e){setTimeout(e,t)}))}}]),t}()}(),r}()}));
{
"name": "@yookue/ts-lang-utils",
"version": "0.1.16",
"version": "0.1.17",
"title": "TsLangUtils",

@@ -5,0 +5,0 @@ "description": "Common Lang Utilities for TypeScript",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc