New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yookue/ts-lang-utils

Package Overview
Dependencies
Maintainers
1
Versions
79
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.0 to 0.1.1

14

dist/cjs/util/BooleanUtils.d.ts

@@ -31,3 +31,3 @@ /**

*/
static toString(value?: boolean, truthy?: string, falsy?: string, nil?: string): string | null | undefined;
static toString(value?: boolean, truthy?: string, falsy?: string, nil?: string): string | undefined;
/**

@@ -42,3 +42,3 @@ * Returns a string value of 'true'/'false' from the boolean value

*/
static toStringTrueFalse(value?: boolean): string | null | undefined;
static toStringTrueFalse(value?: boolean): string | undefined;
/**

@@ -53,3 +53,3 @@ * Returns a string value of 'on'/'off' from the boolean value

*/
static toStringOnOff(value?: boolean): string | null | undefined;
static toStringOnOff(value?: boolean): string | undefined;
/**

@@ -64,3 +64,3 @@ * Returns a string value of 'yes'/'no' from the boolean value

*/
static toStringYesNo(value?: boolean): string | null | undefined;
static toStringYesNo(value?: boolean): string | undefined;
/**

@@ -75,3 +75,3 @@ * Returns a string value of 'Y'/'N' from the boolean value

*/
static toStringYN(value?: boolean): string | null | undefined;
static toStringYN(value?: boolean): string | undefined;
/**

@@ -86,3 +86,3 @@ * Returns a string value of 'T'/'F' from the boolean value

*/
static toStringTF(value?: boolean): string | null | undefined;
static toStringTF(value?: boolean): string | undefined;
/**

@@ -97,3 +97,3 @@ * Returns a string value of '1'/'0' from the boolean value

*/
static toString10(value?: boolean): string | null | undefined;
static toString10(value?: boolean): string | undefined;
}

@@ -237,3 +237,3 @@ /**

*/
static toString(object?: any, nil?: string): string | null;
static toString(object?: any, nil?: string): string | undefined;
}

@@ -334,3 +334,3 @@ var __defProp = Object.defineProperty;

static toString(object, nil) {
return object ? object.toString() : nil ? nil : null;
return object ? object.toString() : nil;
}

@@ -337,0 +337,0 @@ };

@@ -27,23 +27,25 @@ /**

/**
* Returns a random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* Returns a random integer that between the min value (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* @return number the random integer that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomInteger(1, 100);
* RandomUtils.randomInteger(1, 10);
* RandomUtils.randomInteger(-6, 8);
*/
static randomInteger(minInclusive?: number, maxExclusive?: number): number;
/**
* Returns a random non-negative number that between the start min (inclusive) and the max value (exclusive)
* Returns a random number that between the min (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative number that between the min value (inclusive) and the max value (exclusive)
* @return number the random number that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomNumber(1.1, 1.2);
* RandomUtils.randomNumber(-3.6, 2.8);
*/
static randomNumber(minInclusive?: number, maxExclusive?: number): number;
}

@@ -36,3 +36,3 @@ var __defProp = Object.defineProperty;

static randomBoolean() {
return Math.random() > 0.5;
return Math.random() >= 0.5;
}

@@ -51,10 +51,11 @@ /**

/**
* Returns a random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* Returns a random integer that between the min value (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* @return number the random integer that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomInteger(1, 100);
* RandomUtils.randomInteger(1, 10);
* RandomUtils.randomInteger(-6, 8);
*/

@@ -65,21 +66,21 @@ static randomInteger(minInclusive, maxExclusive) {

/**
* Returns a random non-negative number that between the start min (inclusive) and the max value (exclusive)
* Returns a random number that between the min (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative number that between the min value (inclusive) and the max value (exclusive)
* @return number the random number that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomNumber(1.1, 1.2);
* RandomUtils.randomNumber(-3.6, 2.8);
*/
static randomNumber(minInclusive, maxExclusive) {
const start = minInclusive || 0;
const end = maxExclusive || Number.MAX_SAFE_INTEGER - 1;
if (start < 0) {
throw SyntaxError("The min value must not be negative");
}
if (start > end) {
const min = minInclusive || 0;
const max = maxExclusive || Number.MAX_SAFE_INTEGER - 1;
if (min > max) {
throw SyntaxError("The min value must not be greater than max value");
} else if (min === max) {
return min;
}
return start === end ? start : start + (end - start) * Math.random();
return min + (max - min) * Math.random();
}

@@ -86,0 +87,0 @@ };

@@ -31,3 +31,3 @@ /**

*/
static toString(value?: boolean, truthy?: string, falsy?: string, nil?: string): string | null | undefined;
static toString(value?: boolean, truthy?: string, falsy?: string, nil?: string): string | undefined;
/**

@@ -42,3 +42,3 @@ * Returns a string value of 'true'/'false' from the boolean value

*/
static toStringTrueFalse(value?: boolean): string | null | undefined;
static toStringTrueFalse(value?: boolean): string | undefined;
/**

@@ -53,3 +53,3 @@ * Returns a string value of 'on'/'off' from the boolean value

*/
static toStringOnOff(value?: boolean): string | null | undefined;
static toStringOnOff(value?: boolean): string | undefined;
/**

@@ -64,3 +64,3 @@ * Returns a string value of 'yes'/'no' from the boolean value

*/
static toStringYesNo(value?: boolean): string | null | undefined;
static toStringYesNo(value?: boolean): string | undefined;
/**

@@ -75,3 +75,3 @@ * Returns a string value of 'Y'/'N' from the boolean value

*/
static toStringYN(value?: boolean): string | null | undefined;
static toStringYN(value?: boolean): string | undefined;
/**

@@ -86,3 +86,3 @@ * Returns a string value of 'T'/'F' from the boolean value

*/
static toStringTF(value?: boolean): string | null | undefined;
static toStringTF(value?: boolean): string | undefined;
/**

@@ -97,3 +97,3 @@ * Returns a string value of '1'/'0' from the boolean value

*/
static toString10(value?: boolean): string | null | undefined;
static toString10(value?: boolean): string | undefined;
}

@@ -237,3 +237,3 @@ /**

*/
static toString(object?: any, nil?: string): string | null;
static toString(object?: any, nil?: string): string | undefined;
}

@@ -201,3 +201,3 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

value: function toString(object, nil) {
return object ? object.toString() : nil ? nil : null;
return object ? object.toString() : nil;
}

@@ -204,0 +204,0 @@ }]);

@@ -27,23 +27,25 @@ /**

/**
* Returns a random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* Returns a random integer that between the min value (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative integer that between the start value (inclusive) and the end value (exclusive)
* @return number the random integer that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomInteger(1, 100);
* RandomUtils.randomInteger(1, 10);
* RandomUtils.randomInteger(-6, 8);
*/
static randomInteger(minInclusive?: number, maxExclusive?: number): number;
/**
* Returns a random non-negative number that between the start min (inclusive) and the max value (exclusive)
* Returns a random number that between the min (inclusive) and the max value (exclusive)
*
* @param minInclusive the min value, inclusive
* @param maxExclusive the max value, exclusive
* @return number the random non-negative number that between the min value (inclusive) and the max value (exclusive)
* @return number the random number that between the min value (inclusive) and the max value (exclusive)
*
* @example
* RandomUtils.randomNumber(1.1, 1.2);
* RandomUtils.randomNumber(-3.6, 2.8);
*/
static randomNumber(minInclusive?: number, maxExclusive?: number): number;
}

@@ -11,3 +11,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

value: function randomBoolean() {
return Math.random() > 0.5;
return Math.random() >= 0.5;
}

@@ -27,11 +27,10 @@ }, {

value: function randomNumber(minInclusive, maxExclusive) {
var start = minInclusive || 0;
var end = maxExclusive || Number.MAX_SAFE_INTEGER - 1;
if (start < 0) {
throw SyntaxError('The min value must not be negative');
}
if (start > end) {
var min = minInclusive || 0;
var max = maxExclusive || Number.MAX_SAFE_INTEGER - 1;
if (min > max) {
throw SyntaxError('The min value must not be greater than max value');
} else if (min === max) {
return min;
}
return start === end ? start : start + (end - start) * Math.random();
return min + (max - min) * Math.random();
}

@@ -38,0 +37,0 @@ }]);

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

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TsLangUtils=n():t.TsLangUtils=n()}(self,(function(){return function(){var t={486:function(t){t.exports=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},702:function(t,n,e){var r=e(281);function o(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,r(o.key),o)}}t.exports=function(t,n,e){return n&&o(t.prototype,n),e&&o(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},224:function(t,n,e){var r=e(944).default;t.exports=function(t,n){if("object"!==r(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,n||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},281:function(t,n,e){var r=e(944).default,o=e(224);t.exports=function(t){var n=o(t,"string");return"symbol"===r(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports},944:function(t){function n(e){return t.exports=n="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,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}},n={};function e(r){var o=n[r];if(void 0!==o)return o.exports;var u=n[r]={exports:{}};return t[r](u,u.exports,e),u.exports}e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},e.d=function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.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";e.r(r),e.d(r,{ArrayUtils:function(){return s},BooleanUtils:function(){return y},ObjectUtils:function(){return a},RandomUtils:function(){return c},StringUtils:function(){return f},TimeUtils:function(){return v}});var t=e(486),n=e.n(t),o=e(702),u=e.n(o),i=e(944),l=e.n(i),a=function(){function t(){n()(this,t)}return u()(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!!this.isNil(t)||("string"==typeof t||Array.isArray(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"object"===l()(t)&&0===(null===(n=this.keys(t))||void 0===n?void 0:n.length));var n}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isPrototype",value:function(t){if("object"!==l()(t))return!1;var n=t.constructor;return t===("function"==typeof n?n.prototype:t.prototype)}},{key:"allNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||!e.some((function(n){return t.isNotNil(n)}))}},{key:"allNotNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&!e.some((function(n){return t.isNil(n)}))}},{key:"anyNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||e.some((function(n){return t.isNil(n)}))}},{key:"anyNotNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&e.some((function(n){return t.isNotNil(n)}))}},{key:"allEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||!e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&!e.some((function(n){return t.isEmpty(n)}))}},{key:"anyEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||e.some((function(n){return t.isEmpty(n)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&e.some((function(n){return t.isNotEmpty(n)}))}},{key:"firstNonNil",value:function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];if(!n||0===n.length)return null;for(var r=0,o=n;r<o.length;r++){var u=o[r];if(this.isNotNil(u))return u}return null}},{key:"hasProperty",value:function(t,n){return this.allNotNil(t,n)&&"object"===l()(t)&&(null==n?void 0:n.length)>0&&Object.prototype.hasOwnProperty.call(t,n)}},{key:"keys",value:function(t){if(this.isNil(t))return[];if(!this.isPrototype(t))return Object.keys(t);var n=[];for(var e in Object(t))"constructor"!==e&&this.hasProperty(t,e)&&n.push(e);return n}},{key:"toString",value:function(t,n){return t?t.toString():n||null}}]),t}(),s=function(){function t(){n()(this,t)}return u()(t,null,[{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"includes",value:function(t,n){return a.allNotNil(t,n)&&t.includes(n)}}]),t}(),f=function(){function t(){n()(this,t)}return u()(t,null,[{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isBlank",value:function(t){if(!t||0===t.length)return!0;for(var n=t.length,e=0;e<n;e++){var r=t.charAt(e);if(" "!==r&&"\\r"!==r&&"\\n"!==r)return!1}return!0}},{key:"isNotBlank",value:function(t){return!this.isBlank(t)}},{key:"isWhitespace",value:function(t){if(!t||0===t.length)return!1;for(var n=t.length,e=0;e<n;e++)if(" "!==t.charAt(e))return!1;return!0}},{key:"allEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||!e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&!e.some((function(n){return t.isEmpty(n)}))}},{key:"anyEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||e.some((function(n){return t.isEmpty(n)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||!e.some((function(n){return t.isNotBlank(n)}))}},{key:"allNotBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&!e.some((function(n){return t.isBlank(n)}))}},{key:"anyBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||e.some((function(n){return t.isBlank(n)}))}},{key:"anyNotBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&e.some((function(n){return t.isNotBlank(n)}))}},{key:"defaultIfEmpty",value:function(t,n){return this.isEmpty(t)?n:t}},{key:"defaultIfBlank",value:function(t,n){return this.isBlank(t)?n:t}},{key:"equals",value:function(t,n){return!(t!==n&&!a.allNil(t,n))||!a.anyNil(t,n)&&(null==t?void 0:t.length)===(null==n?void 0:n.length)&&t===n}},{key:"equalsIgnoreCase",value:function(t,n){return!(t!==n&&!a.allNil(t,n))||!a.anyNil(t,n)&&(null==t?void 0:t.length)===(null==n?void 0:n.length)&&(null==t?void 0:t.toUpperCase())===(null==n?void 0:n.toUpperCase())}},{key:"equalsAny",value:function(t,n){return s.includes(n,t)}},{key:"equalsAnyIgnoreCase",value:function(t,n){var e=this;return!a.isNil(t)&&!s.isEmpty(n)&&n.some((function(n){return e.equalsIgnoreCase(t,n)}))}},{key:"includes",value:function(t,n){return t===n||a.allNotNil(t,n)&&t.includes(n)}},{key:"includesIgnoreCase",value:function(t,n){var e;return t===n||a.allNotNil(t,n)&&(null==t||null===(e=t.toUpperCase())||void 0===e?void 0:e.includes(null==n?void 0:n.toUpperCase()))}},{key:"includesAny",value:function(t,n){var e=this;return a.allNotNil(t,n)&&(null==n?void 0:n.some((function(n){return e.includes(t,n)})))}},{key:"includesAnyIgnoreCase",value:function(t,n){var e=this;return a.allNotNil(t,n)&&(null==n?void 0:n.some((function(n){return e.includesIgnoreCase(t,n)})))}},{key:"trim",value:function(t,n){if(!t)return t;var e=t.trim();return n&&this.isEmpty(e)?null:e}}]),t}(),y=function(){function t(){n()(this,t)}return u()(t,null,[{key:"fromString",value:function(t){return!!f.equalsAnyIgnoreCase(t,["true","yes","on","y","t","1"])||!f.equalsAnyIgnoreCase(t,["false","no","off","n","f","0"])&&void 0}},{key:"toString",value:function(t,n,e,r){return a.isNil(t)?r:t?n:e}},{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}(),c=function(){function t(){n()(this,t)}return u()(t,null,[{key:"randomBoolean",value:function(){return Math.random()>.5}},{key:"randomElement",value:function(t){return s.isNotEmpty(t)?t.at(this.randomInteger(0,t.length)):void 0}},{key:"randomInteger",value:function(t,n){return Math.floor(this.randomNumber(t,n))}},{key:"randomNumber",value:function(t,n){var e=t||0,r=n||Number.MAX_SAFE_INTEGER-1;if(e<0)throw SyntaxError("The min value must not be negative");if(e>r)throw SyntaxError("The min value must not be greater than max value");return e===r?e:e+(r-e)*Math.random()}}]),t}(),v=function(){function t(){n()(this,t)}return u()(t,null,[{key:"sleep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(n){setTimeout(n,t)}))}}]),t}()}(),r}()}));
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TsLangUtils=n():t.TsLangUtils=n()}(self,(function(){return function(){var t={486:function(t){t.exports=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},702:function(t,n,e){var r=e(281);function o(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,r(o.key),o)}}t.exports=function(t,n,e){return n&&o(t.prototype,n),e&&o(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},224:function(t,n,e){var r=e(944).default;t.exports=function(t,n){if("object"!==r(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,n||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},281:function(t,n,e){var r=e(944).default,o=e(224);t.exports=function(t){var n=o(t,"string");return"symbol"===r(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports},944:function(t){function n(e){return t.exports=n="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,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}},n={};function e(r){var o=n[r];if(void 0!==o)return o.exports;var u=n[r]={exports:{}};return t[r](u,u.exports,e),u.exports}e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},e.d=function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.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";e.r(r),e.d(r,{ArrayUtils:function(){return s},BooleanUtils:function(){return y},ObjectUtils:function(){return a},RandomUtils:function(){return c},StringUtils:function(){return f},TimeUtils:function(){return v}});var t=e(486),n=e.n(t),o=e(702),u=e.n(o),i=e(944),l=e.n(i),a=function(){function t(){n()(this,t)}return u()(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!!this.isNil(t)||("string"==typeof t||Array.isArray(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"object"===l()(t)&&0===(null===(n=this.keys(t))||void 0===n?void 0:n.length));var n}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isPrototype",value:function(t){if("object"!==l()(t))return!1;var n=t.constructor;return t===("function"==typeof n?n.prototype:t.prototype)}},{key:"allNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||!e.some((function(n){return t.isNotNil(n)}))}},{key:"allNotNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&!e.some((function(n){return t.isNil(n)}))}},{key:"anyNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||e.some((function(n){return t.isNil(n)}))}},{key:"anyNotNil",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&e.some((function(n){return t.isNotNil(n)}))}},{key:"allEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||!e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&!e.some((function(n){return t.isEmpty(n)}))}},{key:"anyEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isEmpty(e)||e.some((function(n){return t.isEmpty(n)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return this.isNotEmpty(e)&&e.some((function(n){return t.isNotEmpty(n)}))}},{key:"firstNonNil",value:function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];if(!n||0===n.length)return null;for(var r=0,o=n;r<o.length;r++){var u=o[r];if(this.isNotNil(u))return u}return null}},{key:"hasProperty",value:function(t,n){return this.allNotNil(t,n)&&"object"===l()(t)&&(null==n?void 0:n.length)>0&&Object.prototype.hasOwnProperty.call(t,n)}},{key:"keys",value:function(t){if(this.isNil(t))return[];if(!this.isPrototype(t))return Object.keys(t);var n=[];for(var e in Object(t))"constructor"!==e&&this.hasProperty(t,e)&&n.push(e);return n}},{key:"toString",value:function(t,n){return t?t.toString():n}}]),t}(),s=function(){function t(){n()(this,t)}return u()(t,null,[{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"includes",value:function(t,n){return a.allNotNil(t,n)&&t.includes(n)}}]),t}(),f=function(){function t(){n()(this,t)}return u()(t,null,[{key:"isEmpty",value:function(t){return!t||0===t.length}},{key:"isNotEmpty",value:function(t){return!this.isEmpty(t)}},{key:"isBlank",value:function(t){if(!t||0===t.length)return!0;for(var n=t.length,e=0;e<n;e++){var r=t.charAt(e);if(" "!==r&&"\\r"!==r&&"\\n"!==r)return!1}return!0}},{key:"isNotBlank",value:function(t){return!this.isBlank(t)}},{key:"isWhitespace",value:function(t){if(!t||0===t.length)return!1;for(var n=t.length,e=0;e<n;e++)if(" "!==t.charAt(e))return!1;return!0}},{key:"allEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||!e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&!e.some((function(n){return t.isEmpty(n)}))}},{key:"anyEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||e.some((function(n){return t.isEmpty(n)}))}},{key:"anyNotEmpty",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&e.some((function(n){return t.isNotEmpty(n)}))}},{key:"allBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||!e.some((function(n){return t.isNotBlank(n)}))}},{key:"allNotBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&!e.some((function(n){return t.isBlank(n)}))}},{key:"anyBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return!e||0===e.length||e.some((function(n){return t.isBlank(n)}))}},{key:"anyNotBlank",value:function(){for(var t=this,n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return e&&e.length>0&&e.some((function(n){return t.isNotBlank(n)}))}},{key:"defaultIfEmpty",value:function(t,n){return this.isEmpty(t)?n:t}},{key:"defaultIfBlank",value:function(t,n){return this.isBlank(t)?n:t}},{key:"equals",value:function(t,n){return!(t!==n&&!a.allNil(t,n))||!a.anyNil(t,n)&&(null==t?void 0:t.length)===(null==n?void 0:n.length)&&t===n}},{key:"equalsIgnoreCase",value:function(t,n){return!(t!==n&&!a.allNil(t,n))||!a.anyNil(t,n)&&(null==t?void 0:t.length)===(null==n?void 0:n.length)&&(null==t?void 0:t.toUpperCase())===(null==n?void 0:n.toUpperCase())}},{key:"equalsAny",value:function(t,n){return s.includes(n,t)}},{key:"equalsAnyIgnoreCase",value:function(t,n){var e=this;return!a.isNil(t)&&!s.isEmpty(n)&&n.some((function(n){return e.equalsIgnoreCase(t,n)}))}},{key:"includes",value:function(t,n){return t===n||a.allNotNil(t,n)&&t.includes(n)}},{key:"includesIgnoreCase",value:function(t,n){var e;return t===n||a.allNotNil(t,n)&&(null==t||null===(e=t.toUpperCase())||void 0===e?void 0:e.includes(null==n?void 0:n.toUpperCase()))}},{key:"includesAny",value:function(t,n){var e=this;return a.allNotNil(t,n)&&(null==n?void 0:n.some((function(n){return e.includes(t,n)})))}},{key:"includesAnyIgnoreCase",value:function(t,n){var e=this;return a.allNotNil(t,n)&&(null==n?void 0:n.some((function(n){return e.includesIgnoreCase(t,n)})))}},{key:"trim",value:function(t,n){if(!t)return t;var e=t.trim();return n&&this.isEmpty(e)?null:e}}]),t}(),y=function(){function t(){n()(this,t)}return u()(t,null,[{key:"fromString",value:function(t){return!!f.equalsAnyIgnoreCase(t,["true","yes","on","y","t","1"])||!f.equalsAnyIgnoreCase(t,["false","no","off","n","f","0"])&&void 0}},{key:"toString",value:function(t,n,e,r){return a.isNil(t)?r:t?n:e}},{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}(),c=function(){function t(){n()(this,t)}return u()(t,null,[{key:"randomBoolean",value:function(){return Math.random()>=.5}},{key:"randomElement",value:function(t){return s.isNotEmpty(t)?t.at(this.randomInteger(0,t.length)):void 0}},{key:"randomInteger",value:function(t,n){return Math.floor(this.randomNumber(t,n))}},{key:"randomNumber",value:function(t,n){var e=t||0,r=n||Number.MAX_SAFE_INTEGER-1;if(e>r)throw SyntaxError("The min value must not be greater than max value");return e===r?e:e+(r-e)*Math.random()}}]),t}(),v=function(){function t(){n()(this,t)}return u()(t,null,[{key:"sleep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(n){setTimeout(n,t)}))}}]),t}()}(),r}()}));
{
"name": "@yookue/ts-lang-utils",
"version": "0.1.0",
"version": "0.1.1",
"title": "TsLangUtils",

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

"scripts": {
"build": "father build",
"build": "del-cli ./dist && father build",
"build:watch": "father dev",
"rebuild": "del-cli ./dist && father build",
"docs:build": "tsc --outDir ./docs-temp && jsdoc -c jsdoc.config.json && del-cli ./docs-temp",
"docs:rebuild": "del-cli ./docs-dist && npm run docs:build",
"docs:build": "del-cli ./docs-dist && tsc --outDir ./docs-temp && jsdoc -c jsdoc.config.json && del-cli ./docs-temp",
"docs:deploy": "gh-pages -d ./docs-dist",

@@ -45,14 +43,13 @@ "doctor": "father doctor",

"@types/jest": "^29.5.4",
"@types/object-hash": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"babel-plugin-comments": "^1.0.4",
"del-cli": "^5.0.0",
"docdash": "^2.0.1",
"del-cli": "^5.1.0",
"docdash": "^2.0.2",
"eslint": "^7.32.0",
"father": "^4.3.1",
"gh-pages": "^5.0.0",
"father": "^4.3.3",
"gh-pages": "^6.0.0",
"jsdoc": "^4.0.2",
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"ts-jest": "^29.1.1",
"typescript": "^4.9.5"

@@ -59,0 +56,0 @@ },

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