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

ts-commons

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-commons - npm Package Compare versions

Comparing version 0.0.39 to 1.0.0

karma.conf.js

0

.vscode/launch.json

@@ -0,0 +0,0 @@ {

export declare class ArrayUtils {
/**
* check whether current array is empty.
* eg: ArrayUtils.isEmpty([]) = true;
* eg: ArrayUtils.isEmpty(null) = true;
* eg: ArrayUtils.isEmpty(underfind) = true;
* eg: ArrayUtils.isEmtpy([1]) = fase;
* eg: ArrayUtils.isEmtpy("string") = fase;
* eg: ArrayUtils.isEmtpy(123) = fase;
* check whether current array is empty or null/undefined.
* @param array
* @returns true if array is empty or null/undefined; otherwise, false.
* @throws if input parameter is not array type or null/undefined
* @example ArrayUtils.isEmpty([]) = true;
* @example ArrayUtils.isEmpty(null) = true;
* @example ArrayUtils.isEmpty(undefined) = true;
* @example ArrayUtils.isEmtpy([1]) = false;
* @example ArrayUtils.isEmtpy("string") throw error;
* @example ArrayUtils.isEmtpy(123) throw error;
*/

@@ -16,6 +18,35 @@ static isEmpty<T>(array: T[]): boolean;

* @param array
* @param obj
* @param item
* @returns true if item is in the array; otherwise, false.
* @example ArrayUtils.contains(null, 1) = false
* @example ArrayUtils.contains(undefined, 1) = false
* @example ArrayUtils.contains([], 1) = false
* @example ArrayUtils.contains([1,2,3], 1) = true
* @example ArrayUtils.contains([1,2,3], 5) = false
* @example ArrayUtils.contains([1,2,3], null) = false
* @example ArrayUtils.contains([1,2,3], undefined) = false
*/
static contains<T>(array: T[], obj: T): boolean;
static contains<T>(array: T[], item: T): boolean;
/**
* Determines whether any of candidates is in the array.
* @param array
* @param candidates
* @returns true if item is in the array; otherwise, false.
* @example ArrayUtils.containsAny(null, [1, 2]) = false
* @example ArrayUtils.containsAny(undefined, [1, 2]) = false
* @example ArrayUtils.containsAny([1, 3, 5], [1, 2]) = true
* @example ArrayUtils.containsAny([1, 3, 5], [2, 4, 6]) = false
* @example ArrayUtils.containsAny([1, 3, 5], null) = false
* @example ArrayUtils.containsAny([1, 3, 5], undefined) = false
*/
static containsAny<T>(array: T[], candidates: T[]): boolean;
/**
* Inserts an element into the array at the specified index.
* @param array
* @param index The zero-based index at which item should be inserted.
* @param item The object to insert. The value can be null for reference types.
* @returns true if insert successfully, otherwise false.
* @example ArrayUtils.insert([1, 3], 1, 2) ==> [1, 2, 3]
* @example ArrayUtils.insert([1, 2], 100, 4) = false // greater than array.length.
*/
static insert<T>(array: T[], index: number, item: T): boolean;

@@ -27,4 +58,6 @@ /**

* @returns true if item is successfully removed; otherwise, false.
* @example ArrayUtils.remove([1, 2, 3], 2) = true
* @example ArrayUtils.remove([1, 2, 3], 5) = false
*/
static remove<T>(array: T[], item: T): boolean;
}

57

dist/utils/array.utils.js

@@ -9,10 +9,12 @@ "use strict";

/**
* check whether current array is empty.
* eg: ArrayUtils.isEmpty([]) = true;
* eg: ArrayUtils.isEmpty(null) = true;
* eg: ArrayUtils.isEmpty(underfind) = true;
* eg: ArrayUtils.isEmtpy([1]) = fase;
* eg: ArrayUtils.isEmtpy("string") = fase;
* eg: ArrayUtils.isEmtpy(123) = fase;
* check whether current array is empty or null/undefined.
* @param array
* @returns true if array is empty or null/undefined; otherwise, false.
* @throws if input parameter is not array type or null/undefined
* @example ArrayUtils.isEmpty([]) = true;
* @example ArrayUtils.isEmpty(null) = true;
* @example ArrayUtils.isEmpty(undefined) = true;
* @example ArrayUtils.isEmtpy([1]) = false;
* @example ArrayUtils.isEmtpy("string") throw error;
* @example ArrayUtils.isEmtpy(123) throw error;
*/

@@ -24,3 +26,3 @@ ArrayUtils.isEmpty = function (array) {

if (!object_utils_1.ObjectUtils.isArray(array)) {
return true;
throw new Error("input parameter is not a array or null/undefined");
}

@@ -32,10 +34,30 @@ return array.length === 0;

* @param array
* @param obj
* @param item
* @returns true if item is in the array; otherwise, false.
* @example ArrayUtils.contains(null, 1) = false
* @example ArrayUtils.contains(undefined, 1) = false
* @example ArrayUtils.contains([], 1) = false
* @example ArrayUtils.contains([1,2,3], 1) = true
* @example ArrayUtils.contains([1,2,3], 5) = false
* @example ArrayUtils.contains([1,2,3], null) = false
* @example ArrayUtils.contains([1,2,3], undefined) = false
*/
ArrayUtils.contains = function (array, obj) {
if (this.isEmpty(array) || object_utils_1.ObjectUtils.isNullOrUndefined(obj)) {
ArrayUtils.contains = function (array, item) {
if (this.isEmpty(array) || object_utils_1.ObjectUtils.isNullOrUndefined(item)) {
return false;
}
return array.indexOf(obj) !== -1;
return array.indexOf(item) !== -1;
};
/**
* Determines whether any of candidates is in the array.
* @param array
* @param candidates
* @returns true if item is in the array; otherwise, false.
* @example ArrayUtils.containsAny(null, [1, 2]) = false
* @example ArrayUtils.containsAny(undefined, [1, 2]) = false
* @example ArrayUtils.containsAny([1, 3, 5], [1, 2]) = true
* @example ArrayUtils.containsAny([1, 3, 5], [2, 4, 6]) = false
* @example ArrayUtils.containsAny([1, 3, 5], null) = false
* @example ArrayUtils.containsAny([1, 3, 5], undefined) = false
*/
ArrayUtils.containsAny = function (array, candidates) {

@@ -53,2 +75,11 @@ if (this.isEmpty(array) || this.isEmpty(candidates)) {

};
/**
* Inserts an element into the array at the specified index.
* @param array
* @param index The zero-based index at which item should be inserted.
* @param item The object to insert. The value can be null for reference types.
* @returns true if insert successfully, otherwise false.
* @example ArrayUtils.insert([1, 3], 1, 2) ==> [1, 2, 3]
* @example ArrayUtils.insert([1, 2], 100, 4) = false // greater than array.length.
*/
ArrayUtils.insert = function (array, index, item) {

@@ -69,2 +100,4 @@ if (!object_utils_1.ObjectUtils.isArray(array) ||

* @returns true if item is successfully removed; otherwise, false.
* @example ArrayUtils.remove([1, 2, 3], 2) = true
* @example ArrayUtils.remove([1, 2, 3], 5) = false
*/

@@ -71,0 +104,0 @@ ArrayUtils.remove = function (array, item) {

export declare class DateUtils {
private static timeFormatRegex;
/**
* Returns the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.
* @param date
* @example DateUtils.dateToTimestamp(null) = 0
* @example DateUtils.dateToTimestamp(undefined) = 0
* @example DateUtils.dateToTimestamp(new Date("Tue, 19 Jun 2018 00:00:00 GMT")) = 1529366400000
*/
static dateToTimestamp(date: Date): number;
/**
* Get date from the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.
* @param timestamp
* @example DateUtils.timestampToDate(1529366400) = new Date("Tue, 19 Jun 2018 00:00:00 GMT")
*/
static timestampToDate(timestamp: number): Date;
/**
* Converts the value of the current date to its equivalent string representation
* using the specified format.
* @param date
* @param format
* "yyyy" Year represented by four digits.
* "yy" Year as last two digits; leading zero for years less than 10.
* "MM" Month as digits; leading zero for single-digit months.
* "M" Month as digits; no leading zero for single-digit months.
* "dd" Day of the month as digits; leading zero for single-digit days.
* "d" Day of the month as digits; no leading zero for single-digit days.
* "HH" Hours; leading zero for single-digit hours (24-hour clock).
* "H" Hours; no leading zero for single-digit hours (24-hour clock).
* "mm" Minutes; leading zero for single-digit minutes.
* "m" Minutes; no leading zero for single-digit minutes.
* "ss" Seconds; leading zero for single-digit seconds.
* "s" Seconds; no leading zero for single-digit seconds.
* "SSS" Milliseconds; leading zero for single-digit seconds.
* "S" Milliseconds; no leading zero for single-digit seconds.
*/
static toString(date: Date, format: string): string;
/**
* Converts the value of the current UTC date to its equivalent string representation
* using the specified format.
* @param date
* @param format
* "yyyy" Year represented by four digits.
* "yy" Year as last two digits; leading zero for years less than 10.
* "MM" Month as digits; leading zero for single-digit months.
* "M" Month as digits; no leading zero for single-digit months.
* "dd" Day of the month as digits; leading zero for single-digit days.
* "d" Day of the month as digits; no leading zero for single-digit days.
* "HH" Hours; leading zero for single-digit hours (24-hour clock).
* "H" Hours; no leading zero for single-digit hours (24-hour clock).
* "mm" Minutes; leading zero for single-digit minutes.
* "m" Minutes; no leading zero for single-digit minutes.
* "ss" Seconds; leading zero for single-digit seconds.
* "s" Seconds; no leading zero for single-digit seconds.
* "SSS" Milliseconds; leading zero for single-digit seconds.
* "S" Milliseconds; no leading zero for single-digit seconds.
*/
static toUTCString(date: Date, format: string): string;
private static getTimeFormat;
}

@@ -8,2 +8,9 @@ "use strict";

}
/**
* Returns the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.
* @param date
* @example DateUtils.dateToTimestamp(null) = 0
* @example DateUtils.dateToTimestamp(undefined) = 0
* @example DateUtils.dateToTimestamp(new Date("Tue, 19 Jun 2018 00:00:00 GMT")) = 1529366400000
*/
DateUtils.dateToTimestamp = function (date) {

@@ -13,4 +20,9 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(date)) {

}
return Math.round(date.getTime() / 1000);
return date.getTime();
};
/**
* Get date from the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.
* @param timestamp
* @example DateUtils.timestampToDate(1529366400) = new Date("Tue, 19 Jun 2018 00:00:00 GMT")
*/
DateUtils.timestampToDate = function (timestamp) {

@@ -27,2 +39,109 @@ if (!number_utils_1.NumberUtils.isSafeInteger(timestamp)) {

};
/**
* Converts the value of the current date to its equivalent string representation
* using the specified format.
* @param date
* @param format
* "yyyy" Year represented by four digits.
* "yy" Year as last two digits; leading zero for years less than 10.
* "MM" Month as digits; leading zero for single-digit months.
* "M" Month as digits; no leading zero for single-digit months.
* "dd" Day of the month as digits; leading zero for single-digit days.
* "d" Day of the month as digits; no leading zero for single-digit days.
* "HH" Hours; leading zero for single-digit hours (24-hour clock).
* "H" Hours; no leading zero for single-digit hours (24-hour clock).
* "mm" Minutes; leading zero for single-digit minutes.
* "m" Minutes; no leading zero for single-digit minutes.
* "ss" Seconds; leading zero for single-digit seconds.
* "s" Seconds; no leading zero for single-digit seconds.
* "SSS" Milliseconds; leading zero for single-digit seconds.
* "S" Milliseconds; no leading zero for single-digit seconds.
*/
DateUtils.toString = function (date, format) {
var _this = this;
var result = format.replace(this.timeFormatRegex, function (matched) {
return _this.getTimeFormat(false, date, matched);
});
return result;
};
/**
* Converts the value of the current UTC date to its equivalent string representation
* using the specified format.
* @param date
* @param format
* "yyyy" Year represented by four digits.
* "yy" Year as last two digits; leading zero for years less than 10.
* "MM" Month as digits; leading zero for single-digit months.
* "M" Month as digits; no leading zero for single-digit months.
* "dd" Day of the month as digits; leading zero for single-digit days.
* "d" Day of the month as digits; no leading zero for single-digit days.
* "HH" Hours; leading zero for single-digit hours (24-hour clock).
* "H" Hours; no leading zero for single-digit hours (24-hour clock).
* "mm" Minutes; leading zero for single-digit minutes.
* "m" Minutes; no leading zero for single-digit minutes.
* "ss" Seconds; leading zero for single-digit seconds.
* "s" Seconds; no leading zero for single-digit seconds.
* "SSS" Milliseconds; leading zero for single-digit seconds.
* "S" Milliseconds; no leading zero for single-digit seconds.
*/
DateUtils.toUTCString = function (date, format) {
var _this = this;
var result = format.replace(this.timeFormatRegex, function (matched) {
return _this.getTimeFormat(true, date, matched);
});
return result;
};
DateUtils.getTimeFormat = function (isUTC, date, formatKey) {
switch (formatKey) {
case "yyyy":
return (isUTC ? date.getUTCFullYear() : date.getFullYear()).toString();
case "yy":
return (isUTC ? date.getUTCFullYear() : date.getFullYear())
.toString()
.substr(2);
case "MM":
var month = isUTC ? date.getUTCMonth() + 1 : date.getMonth() + 1;
return month >= 10 ? month.toString() : "0" + month;
case "M":
return (isUTC
? date.getUTCMonth() + 1
: date.getMonth() + 1).toString();
case "dd":
var day = isUTC ? date.getUTCDate() : date.getDate();
return day >= 10 ? day.toString() : "0" + day;
case "d":
return (isUTC ? date.getUTCDate() : date.getDate()).toString();
case "HH":
var hour = isUTC ? date.getUTCHours() : date.getHours();
return hour >= 10 ? hour.toString() : "0" + hour;
case "H":
return (isUTC ? date.getUTCHours() : date.getHours()).toString();
case "mm":
var min = isUTC ? date.getUTCMinutes() : date.getMinutes();
return min >= 10 ? min.toString() : "0" + min;
case "m":
return (isUTC ? date.getUTCMinutes() : date.getMinutes()).toString();
case "ss":
var seconds = isUTC ? date.getUTCSeconds() : date.getSeconds();
return seconds >= 10 ? seconds.toString() : "0" + seconds;
case "s":
return (isUTC ? date.getUTCSeconds() : date.getSeconds()).toString();
case "SSS":
var milliseconds = isUTC
? date.getUTCMilliseconds()
: date.getMilliseconds();
return milliseconds >= 100
? milliseconds.toString()
: milliseconds >= 10
? "0" + milliseconds
: "00" + milliseconds;
case "S":
return (isUTC
? date.getUTCMilliseconds()
: date.getMilliseconds()).toString();
default:
return "";
}
};
DateUtils.timeFormatRegex = /yyyy|yy|MM|M|dd|d|HH|H|mm|m|ss|s|SSS|S/g;
return DateUtils;

@@ -29,0 +148,0 @@ }());

export declare class HttpUtils {
/**
* Get all cookie values from cookie string;
* @param cookie
* @example HttpUtils.getCookies(document.cookie)
*/
static getCookies(cookie: string): {
[key: string]: string;
};
/**
* Get all query values from url;
* @param cookie
* @example HttpUtils.getQueryParams("http://www.google.com/?search=test&id=123")
*/
static getQueryParams(url: string): {

@@ -6,0 +16,0 @@ [key: string]: string;

@@ -7,5 +7,15 @@ "use strict";

}
/**
* Get all cookie values from cookie string;
* @param cookie
* @example HttpUtils.getCookies(document.cookie)
*/
HttpUtils.getCookies = function (cookie) {
return this.getParams(cookie, "; ");
};
/**
* Get all query values from url;
* @param cookie
* @example HttpUtils.getQueryParams("http://www.google.com/?search=test&id=123")
*/
HttpUtils.getQueryParams = function (url) {

@@ -20,5 +30,3 @@ if (!object_utils_1.ObjectUtils.isString(url)) {

// solve a=1[;|&]b=2[;|&]c=3
HttpUtils.getParams = function (paramStr,
// tslint:disable-next-line:trailing-comma
splitChar) {
HttpUtils.getParams = function (paramStr, splitChar) {
var result = {};

@@ -25,0 +33,0 @@ if (!object_utils_1.ObjectUtils.isString(paramStr) || !object_utils_1.ObjectUtils.isString(splitChar)) {

@@ -5,30 +5,32 @@ export declare class NumberUtils {

/**
* Number.isInteger(0); // true
* Number.isInteger(1); // true
* Number.isInteger(-100000); // true
* Number.isInteger(99999999999999999999999); // true
*
* Number.isInteger(0.1); // false
* Number.isInteger(Math.PI); // false
*
* Number.isInteger(NaN); // false
* Number.isInteger(Infinity); // false
* Number.isInteger(-Infinity); // false
* Number.isInteger('10'); // false
* Number.isInteger(true); // false
* Number.isInteger(false); // false
* Number.isInteger([1]); // false
* check whether current value is integer
* @param value
* @example Number.isInteger(0); // true
* @example Number.isInteger(1); // true
* @example Number.isInteger(-100000); // true
* @example Number.isInteger(99999999999999999999999); // true
* @example Number.isInteger(0.1); // false
* @example Number.isInteger(Math.PI); // false
* @example Number.isInteger(NaN); // false
* @example Number.isInteger(Infinity); // false
* @example Number.isInteger(-Infinity); // false
* @example Number.isInteger('10'); // false
* @example Number.isInteger(true); // false
* @example Number.isInteger(false); // false
* @example Number.isInteger([1]); // false
*/
static isInteger(value: any): boolean;
/**
* Number.isSafeInteger(3); // true
* Number.isSafeInteger(Math.pow(2, 53)); // false
* Number.isSafeInteger(Math.pow(2, 53) - 1); // true
* Number.isSafeInteger(NaN); // false
* Number.isSafeInteger(Infinity); // false
* Number.isSafeInteger('3'); // false
* Number.isSafeInteger(3.1); // false
* Number.isSafeInteger(3.0); // true
* check whether current value is safe integer
* @param value
* @example Number.isSafeInteger(3); // true
* @example Number.isSafeInteger(Math.pow(2, 53)); // false
* @example Number.isSafeInteger(Math.pow(2, 53) - 1); // true
* @example Number.isSafeInteger(NaN); // false
* @example Number.isSafeInteger(Infinity); // false
* @example Number.isSafeInteger('3'); // false
* @example Number.isSafeInteger(3.1); // false
* @example Number.isSafeInteger(3.0); // true
*/
static isSafeInteger(value: any): boolean;
}

@@ -9,17 +9,17 @@ "use strict";

/**
* Number.isInteger(0); // true
* Number.isInteger(1); // true
* Number.isInteger(-100000); // true
* Number.isInteger(99999999999999999999999); // true
*
* Number.isInteger(0.1); // false
* Number.isInteger(Math.PI); // false
*
* Number.isInteger(NaN); // false
* Number.isInteger(Infinity); // false
* Number.isInteger(-Infinity); // false
* Number.isInteger('10'); // false
* Number.isInteger(true); // false
* Number.isInteger(false); // false
* Number.isInteger([1]); // false
* check whether current value is integer
* @param value
* @example Number.isInteger(0); // true
* @example Number.isInteger(1); // true
* @example Number.isInteger(-100000); // true
* @example Number.isInteger(99999999999999999999999); // true
* @example Number.isInteger(0.1); // false
* @example Number.isInteger(Math.PI); // false
* @example Number.isInteger(NaN); // false
* @example Number.isInteger(Infinity); // false
* @example Number.isInteger(-Infinity); // false
* @example Number.isInteger('10'); // false
* @example Number.isInteger(true); // false
* @example Number.isInteger(false); // false
* @example Number.isInteger([1]); // false
*/

@@ -32,10 +32,12 @@ NumberUtils.isInteger = function (value) {

/**
* Number.isSafeInteger(3); // true
* Number.isSafeInteger(Math.pow(2, 53)); // false
* Number.isSafeInteger(Math.pow(2, 53) - 1); // true
* Number.isSafeInteger(NaN); // false
* Number.isSafeInteger(Infinity); // false
* Number.isSafeInteger('3'); // false
* Number.isSafeInteger(3.1); // false
* Number.isSafeInteger(3.0); // true
* check whether current value is safe integer
* @param value
* @example Number.isSafeInteger(3); // true
* @example Number.isSafeInteger(Math.pow(2, 53)); // false
* @example Number.isSafeInteger(Math.pow(2, 53) - 1); // true
* @example Number.isSafeInteger(NaN); // false
* @example Number.isSafeInteger(Infinity); // false
* @example Number.isSafeInteger('3'); // false
* @example Number.isSafeInteger(3.1); // false
* @example Number.isSafeInteger(3.0); // true
*/

@@ -42,0 +44,0 @@ NumberUtils.isSafeInteger = function (value) {

export declare class ObjectUtils {
/**
* check whether value is null.
* @param value
*/
static isNull(value: any): boolean;
/**
* check whether value is undefined.
* @param value
*/
static isUndefinend(value: any): boolean;
/**
* check whether value is null or undefined.
* @param value
*/
static isNullOrUndefined(value: any): boolean;
/**
* check whether value is array.
* @param value
*/
static isArray(value: any): boolean;
/**
* check whether value is date.
* @param value
*/
static isDate(value: any): boolean;
/**
* check whether value is string.
* @param value
*/
static isString(value: any): boolean;
/**
* check whether value is number.
* @param value
*/
static isNumber(value: any): boolean;
/**
* check whether value is boolean.
* @param value
*/
static isBoolean(value: any): boolean;
/**
* Returns a string representation of an object even if value is null or undefined.
* @param value
* @example ObjectUtils.toSafeString(null) = ""
* @example ObjectUtils.toSafeString(undefined) = ""
*/
static toSafeString(value: any): string;
static getProperty<T, K extends keyof T>(obj: T, key: K): T[K];
/**
* get property value of object by key.
* @param obj
* @param key
*/
static getProperty<T, K extends keyof T>(obj: T, key: K): any;
/**
* set property to object.
* @param obj
* @param key
* @param value
*/
static setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]): void;
static getClassName<T>(o: T | {
new (): T;
}): string;
/**
* create object by type.
* @param type
*/
static createObject<T>(type: {
new (): T;
}): T;
static getPropertyName<T>(fn: (o: T) => any): string;
/**
* get name of property.
* @param key
*/
static getPropertyName<T>(key: keyof T): any;
}

@@ -6,28 +6,64 @@ "use strict";

}
/**
* check whether value is null.
* @param value
*/
ObjectUtils.isNull = function (value) {
return value === null;
};
/**
* check whether value is undefined.
* @param value
*/
ObjectUtils.isUndefinend = function (value) {
return typeof value === "undefined";
};
/**
* check whether value is null or undefined.
* @param value
*/
ObjectUtils.isNullOrUndefined = function (value) {
return this.isNull(value) || this.isUndefinend(value);
};
/**
* check whether value is array.
* @param value
*/
ObjectUtils.isArray = function (value) {
return value instanceof Array;
};
/**
* check whether value is date.
* @param value
*/
ObjectUtils.isDate = function (value) {
return value instanceof Date;
};
/**
* check whether value is string.
* @param value
*/
ObjectUtils.isString = function (value) {
return typeof value === "string";
};
/**
* check whether value is number.
* @param value
*/
ObjectUtils.isNumber = function (value) {
return typeof value === "number";
};
/**
* check whether value is boolean.
* @param value
*/
ObjectUtils.isBoolean = function (value) {
return typeof value === "boolean";
};
// return "" if value is null or undefined.
// from C# https://docs.microsoft.com/en-us/dotnet/api/microsoft.toolkit.extensions.stringextensions.tosafestring?view=uwp-toolkit-dotnet
/**
* Returns a string representation of an object even if value is null or undefined.
* @param value
* @example ObjectUtils.toSafeString(null) = ""
* @example ObjectUtils.toSafeString(undefined) = ""
*/
ObjectUtils.toSafeString = function (value) {

@@ -41,15 +77,23 @@ if (this.isNullOrUndefined(value)) {

};
/**
* get property value of object by key.
* @param obj
* @param key
*/
ObjectUtils.getProperty = function (obj, key) {
return obj[key]; // Inferred type is T[K]
};
/**
* set property to object.
* @param obj
* @param key
* @param value
*/
ObjectUtils.setProperty = function (obj, key, value) {
obj[key] = value;
};
ObjectUtils.getClassName = function (o) {
if (this.isNullOrUndefined(o)) {
return "";
}
var testObj = typeof o === "function" ? new o() : o;
return testObj.constructor.name;
};
/**
* create object by type.
* @param type
*/
ObjectUtils.createObject = function (type) {

@@ -61,17 +105,8 @@ if (this.isNullOrUndefined(type)) {

};
// getPropertyName<Student>((student) => student.name) return name
// getPropertyName<Student>((student) => student.age) return age
ObjectUtils.getPropertyName = function (fn) {
if (this.isNullOrUndefined(fn)) {
return "";
}
// ES5: function (name) { return student.name; }
// ES6: (student) => student.name;
var expression = fn.toString();
var returnIndex = expression.indexOf("return");
var regexp = returnIndex > -1
? new RegExp("^.*return\\s+\\w+.(\\w+)\\s*;\\s*\\}\\s*$")
: RegExp("^\\s*\\(?\\w+\\)?\\s*=>\\s*\\w+\\.(\\w+)\\s*$");
var match = regexp.exec(expression);
return !this.isNullOrUndefined(match) && match.length === 2 ? match[1] : "";
/**
* get name of property.
* @param key
*/
ObjectUtils.getPropertyName = function (key) {
return key.toString();
};

@@ -78,0 +113,0 @@ return ObjectUtils;

export declare class RegexUtils {
/**
* * => \*
* ? => \?
* { => \{
* } => \}
* Escapes all reserved characters for regular expressions by preceding them with a backslash.
* @param str target string
* @example * => \*
* @example ? => \?
* @example { => \{
* @example } => \}
*/

@@ -20,3 +21,6 @@ static escapeRegExp(str: string): string;

static validatePassword(password: string): boolean;
/**
* valid current input is email format.
*/
static validateEmail(email: string): boolean;
}

@@ -7,7 +7,8 @@ "use strict";

/**
* * => \*
* ? => \?
* { => \{
* } => \}
* Escapes all reserved characters for regular expressions by preceding them with a backslash.
* @param str target string
* @example * => \*
* @example ? => \?
* @example { => \{
* @example } => \}
*/

@@ -33,2 +34,5 @@ RegexUtils.escapeRegExp = function (str) {

};
/**
* valid current input is email format.
*/
RegexUtils.validateEmail = function (email) {

@@ -35,0 +39,0 @@ // from: https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript

@@ -5,95 +5,215 @@ export declare class StringUtils {

/**
* StringUtils.isEmpty(null) = true
* StringUtils.isEmpty(undefined) = true
* StringUtils.isEmpty("") = true
* StringUtils.isEmpty(" ") = false
* StringUtils.isEmpty("bob") = false
* StringUtils.isEmpty(" bob ") = false
* check current string is empty.
* @param str
* @example StringUtils.isEmpty(null) = true
* @example StringUtils.isEmpty(undefined) = true
* @example StringUtils.isEmpty("") = true
* @example StringUtils.isEmpty(" ") = false
* @example StringUtils.isEmpty("bob") = false
* @example StringUtils.isEmpty(" bob ") = false
*/
static isEmpty(str: string): boolean;
/**
* check current string is not empty.
* @param str
* @example StringUtils.isEmpty(null) = false
* @example StringUtils.isEmpty(undefined) = false
* @example StringUtils.isEmpty("") = false
* @example StringUtils.isEmpty(" ") = true
* @example StringUtils.isEmpty("bob") = true
* @example StringUtils.isEmpty(" bob ") = true
*/
static isNotEmpty(str: string): boolean;
/**
* check current string is blank.
* @param str
* @example StringUtils.isEmpty(null) = true
* @example StringUtils.isEmpty(undefined) = true
* @example StringUtils.isEmpty("") = true
* @example StringUtils.isEmpty(" ") = true
* @example StringUtils.isEmpty("bob") = false
* @example StringUtils.isEmpty(" bob ") = false
*/
static isBlank(str: string): boolean;
/**
* check current string is not blank.
* @param str
* @example StringUtils.isEmpty(null) = false
* @example StringUtils.isEmpty(undefined) = false
* @example StringUtils.isEmpty("") = false
* @example StringUtils.isEmpty(" ") = false
* @example StringUtils.isEmpty("bob") = true
* @example StringUtils.isEmpty(" bob ") = true
*/
static isNotBlank(str: string): boolean;
/**
* Removes all leading and trailing white-space characters from the current string.
* @param str
*/
static trim(str: string): string;
/**
* Removes all leading and trailing white-space characters from the current string to null.
* @param str
*/
static trimToNull(str: string): string;
/**
* Removes all leading and trailing white-space characters from the current string to "".
* @param str
*/
static trimToEmpty(str: string): string;
/**
* Strips any of a set of characters from the start and end of a String.
* @param str
* @param stripChars
*/
static strip(str: string, stripChars?: string): string;
/**
* Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.
* @param str
*/
static stripToNull(str: string): string;
/**
* Strips whitespace from the start and end of a String returning an empty String if null input.
* @param str
*/
static stripToEmpty(str: string): string;
/**
* StringUtils.stripStart(null, *) = null
* StringUtils.stripStart("", *) = ""
* StringUtils.stripStart("abc", "") = "abc"
* StringUtils.stripStart("abc", null) = "abc"
* StringUtils.stripStart(" abc", null) = "abc"
* StringUtils.stripStart("abc ", null) = "abc "
* StringUtils.stripStart(" abc ", null) = "abc "
* StringUtils.stripStart("yxabc ", "xyz") = "abc "
* Strips any of a set of characters from the start of a String.
* @param str
* @param stripChars
* @example StringUtils.stripStart(null, *) = null
* @example StringUtils.stripStart("", *) = ""
* @example StringUtils.stripStart("abc", "") = "abc"
* @example StringUtils.stripStart("abc", null) = "abc"
* @example StringUtils.stripStart(" abc", null) = "abc"
* @example StringUtils.stripStart("abc ", null) = "abc "
* @example StringUtils.stripStart(" abc ", null) = "abc "
* @example StringUtils.stripStart("yxabc ", "xyz") = "abc "
*/
static stripStart(str: string, stripChars: string): string;
/**
* StringUtils.stripEnd(null, *) = null
* StringUtils.stripEnd("", *) = ""
* StringUtils.stripEnd("abc", "") = "abc"
* StringUtils.stripEnd("abc", null) = "abc"
* StringUtils.stripEnd(" abc", null) = " abc"
* StringUtils.stripEnd("abc ", null) = "abc"
* StringUtils.stripEnd(" abc ", null) = " abc"
* StringUtils.stripEnd(" abcyx", "xyz") = " abc"
* Strips any of a set of characters from the end of a String.
* @param str
* @param stripChars
* @example StringUtils.stripEnd(null, *) = null
* @example StringUtils.stripEnd("", *) = ""
* @example StringUtils.stripEnd("abc", "") = "abc"
* @example StringUtils.stripEnd("abc", null) = "abc"
* @example StringUtils.stripEnd(" abc", null) = " abc"
* @example StringUtils.stripEnd("abc ", null) = "abc"
* @example StringUtils.stripEnd(" abc ", null) = " abc"
* @example StringUtils.stripEnd(" abcyx", "xyz") = " abc"
*/
static stripEnd(str: string, stripChars: string): string;
/**
* StringUtils.equal(null, null) = true
* StringUtils.equal(undefined, undefined) = true
* StringUtils.equal(undefined, null) = false
* StringUtils.equal(null, undefined) = false
* StringUtils.equal(null, "abc") = false
* StringUtils.equal("abc", null) = false
* StringUtils.equal("abc", undefined) = false
* StringUtils.equal(undefined, "abc") = false
* StringUtils.equal("abc", "def") = false
* StringUtils.equal("abc", "abc") = true
* Compares two CharSequences, returning true if they represent equal sequences of characters.
* @param str1
* @param str2
* @example StringUtils.equal(null, null) = true
* @example StringUtils.equal(undefined, undefined) = true
* @example StringUtils.equal(undefined, null) = false
* @example StringUtils.equal(null, undefined) = false
* @example StringUtils.equal(null, "abc") = false
* @example StringUtils.equal("abc", null) = false
* @example StringUtils.equal("abc", undefined) = false
* @example StringUtils.equal(undefined, "abc") = false
* @example StringUtils.equal("abc", "def") = false
* @example StringUtils.equal("abc", "abc") = true
*/
static equals(str1: string, str2: string): boolean;
/**
* StringUtils.equal(null, null) = true
* StringUtils.equal(undefined, undefined) = true
* StringUtils.equal(undefined, null) = false
* StringUtils.equal(null, undefined) = false
* StringUtils.equal(null, "abc") = false
* StringUtils.equal("abc", null) = false
* StringUtils.equal("abc", undefined) = false
* StringUtils.equal(undefined, "abc") = false
* StringUtils.equal("abc", "def") = false
* StringUtils.equal("abc", "abc") = true
* StringUtils.equal("abc", "AbC") = true
* Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
* @param str1
* @param str2
* @example StringUtils.equal(null, null) = true
* @example StringUtils.equal(undefined, undefined) = true
* @example StringUtils.equal(undefined, null) = false
* @example StringUtils.equal(null, undefined) = false
* @example StringUtils.equal(null, "abc") = false
* @example StringUtils.equal("abc", null) = false
* @example StringUtils.equal("abc", undefined) = false
* @example StringUtils.equal(undefined, "abc") = false
* @example StringUtils.equal("abc", "def") = false
* @example StringUtils.equal("abc", "abc") = true
* @example StringUtils.equal("abc", "AbC") = true
*/
static equalsIgnoreCase(str1: string, str2: string): boolean;
/**
* StringUtils.indexOf(null, *) = -1
* StringUtils.indexOf(undefined, *) = -1
* StringUtils.indexOf("", *) = -1
* StringUtils.indexOf("aabaabaa", 'a') = 0
* StringUtils.indexOf("aabaabaa", 'b') = 2
* StringUtils.indexOf("aabaabaa", 'b', 3) = 5
* StringUtils.indexOf("aabaabaa", '') = 0
* Finds the first index within a CharSequence, handling null.
* @param str
* @param searchStr
* @param startPos
* @example StringUtils.indexOf(null, *) = -1
* @example StringUtils.indexOf(undefined, *) = -1
* @example StringUtils.indexOf("", *) = -1
* @example StringUtils.indexOf("aabaabaa", 'a') = 0
* @example StringUtils.indexOf("aabaabaa", 'b') = 2
* @example StringUtils.indexOf("aabaabaa", 'b', 3) = 5
* @example StringUtils.indexOf("aabaabaa", '') = 0
*/
static indexOf(str: string, searchStr: string, startPos?: number): number;
/**
* StringUtils.lastIndexOf("aFkyk", "k") =4
* StringUtils.lastIndexOf("a Fkyk", " "); =1
* StringUtils.lastIndexOf("aabaabaa", "b"); =5
* StringUtils.lastIndexOf("aabaabaa", "b", 4); =2
* Returns the index within seq of the first occurrence of the specified character, starting the search at the specified index.
* @param str
* @param searchStr
* @param position
* @example StringUtils.lastIndexOf("aFkyk", "k") =4
* @example StringUtils.lastIndexOf("a Fkyk", " "); =1
* @example StringUtils.lastIndexOf("aabaabaa", "b"); =5
* @example StringUtils.lastIndexOf("aabaabaa", "b", 4); =2
*/
static lastIndexOf(str: string, searchStr: string, position?: number): number;
/**
* Checks if CharSequence contains a search character, handling null.
* @param str
* @param searchStr
*/
static contains(str: string, searchStr: string): boolean;
/**
* Checks if CharSequence contains a search CharSequence irrespective of case, handling null.
* @param str
* @param searchStr
*/
static containsIgnoreCase(str: string, searchStr: string): boolean;
/**
* Gets a substring from the specified String avoiding exceptions.
* @param str
* @param start
* @param end
*/
static subString(str: string, start: number, end?: number): string;
/**
* Determines whether the beginning of this string instance matches the specified string.
* @param str
* @param prefix
*/
static startWith(str: string, prefix: string): boolean;
/**
* Determines whether the beginning of this string instance matches the specified string irrespective of case.
* @param str
* @param prefix
*/
static startWithIgnoreCase(str: string, prefix: string): boolean;
/**
* Determines whether the end of this string instance matches the specified string.
* @param str
* @param suffix
*/
static endWith(str: string, suffix: string): boolean;
/**
* Determines whether the end of this string instance matches the specified string irrespective of case.
* @param str
* @param suffix
*/
static endWithIgnoreCase(str: string, suffix: string): boolean;
/**
* check if current char is whitespace
* @param ch
*/
static isWhitespace(ch: string): boolean;
/**
* Initializes a new string of the guid structure.
*/
static newGuid(): string;
private static S4;
}

@@ -9,8 +9,10 @@ "use strict";

/**
* StringUtils.isEmpty(null) = true
* StringUtils.isEmpty(undefined) = true
* StringUtils.isEmpty("") = true
* StringUtils.isEmpty(" ") = false
* StringUtils.isEmpty("bob") = false
* StringUtils.isEmpty(" bob ") = false
* check current string is empty.
* @param str
* @example StringUtils.isEmpty(null) = true
* @example StringUtils.isEmpty(undefined) = true
* @example StringUtils.isEmpty("") = true
* @example StringUtils.isEmpty(" ") = false
* @example StringUtils.isEmpty("bob") = false
* @example StringUtils.isEmpty(" bob ") = false
*/

@@ -20,11 +22,45 @@ StringUtils.isEmpty = function (str) {

};
/**
* check current string is not empty.
* @param str
* @example StringUtils.isEmpty(null) = false
* @example StringUtils.isEmpty(undefined) = false
* @example StringUtils.isEmpty("") = false
* @example StringUtils.isEmpty(" ") = true
* @example StringUtils.isEmpty("bob") = true
* @example StringUtils.isEmpty(" bob ") = true
*/
StringUtils.isNotEmpty = function (str) {
return !this.isEmpty(str);
};
/**
* check current string is blank.
* @param str
* @example StringUtils.isEmpty(null) = true
* @example StringUtils.isEmpty(undefined) = true
* @example StringUtils.isEmpty("") = true
* @example StringUtils.isEmpty(" ") = true
* @example StringUtils.isEmpty("bob") = false
* @example StringUtils.isEmpty(" bob ") = false
*/
StringUtils.isBlank = function (str) {
return object_utils_1.ObjectUtils.isNullOrUndefined(str) || str.trim() === this.EMPTY;
};
/**
* check current string is not blank.
* @param str
* @example StringUtils.isEmpty(null) = false
* @example StringUtils.isEmpty(undefined) = false
* @example StringUtils.isEmpty("") = false
* @example StringUtils.isEmpty(" ") = false
* @example StringUtils.isEmpty("bob") = true
* @example StringUtils.isEmpty(" bob ") = true
*/
StringUtils.isNotBlank = function (str) {
return !this.isBlank(str);
};
/**
* Removes all leading and trailing white-space characters from the current string.
* @param str
*/
StringUtils.trim = function (str) {

@@ -38,2 +74,6 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(str)) {

};
/**
* Removes all leading and trailing white-space characters from the current string to null.
* @param str
*/
StringUtils.trimToNull = function (str) {

@@ -46,2 +86,6 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(str)) {

};
/**
* Removes all leading and trailing white-space characters from the current string to "".
* @param str
*/
StringUtils.trimToEmpty = function (str) {

@@ -54,2 +98,7 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(str)) {

};
/**
* Strips any of a set of characters from the start and end of a String.
* @param str
* @param stripChars
*/
StringUtils.strip = function (str, stripChars) {

@@ -59,2 +108,6 @@ var tmp = this.stripStart(str, stripChars);

};
/**
* Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.
* @param str
*/
StringUtils.stripToNull = function (str) {

@@ -67,2 +120,6 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(str)) {

};
/**
* Strips whitespace from the start and end of a String returning an empty String if null input.
* @param str
*/
StringUtils.stripToEmpty = function (str) {

@@ -76,10 +133,13 @@ if (object_utils_1.ObjectUtils.isNullOrUndefined(str)) {

/**
* StringUtils.stripStart(null, *) = null
* StringUtils.stripStart("", *) = ""
* StringUtils.stripStart("abc", "") = "abc"
* StringUtils.stripStart("abc", null) = "abc"
* StringUtils.stripStart(" abc", null) = "abc"
* StringUtils.stripStart("abc ", null) = "abc "
* StringUtils.stripStart(" abc ", null) = "abc "
* StringUtils.stripStart("yxabc ", "xyz") = "abc "
* Strips any of a set of characters from the start of a String.
* @param str
* @param stripChars
* @example StringUtils.stripStart(null, *) = null
* @example StringUtils.stripStart("", *) = ""
* @example StringUtils.stripStart("abc", "") = "abc"
* @example StringUtils.stripStart("abc", null) = "abc"
* @example StringUtils.stripStart(" abc", null) = "abc"
* @example StringUtils.stripStart("abc ", null) = "abc "
* @example StringUtils.stripStart(" abc ", null) = "abc "
* @example StringUtils.stripStart("yxabc ", "xyz") = "abc "
*/

@@ -108,10 +168,13 @@ StringUtils.stripStart = function (str, stripChars) {

/**
* StringUtils.stripEnd(null, *) = null
* StringUtils.stripEnd("", *) = ""
* StringUtils.stripEnd("abc", "") = "abc"
* StringUtils.stripEnd("abc", null) = "abc"
* StringUtils.stripEnd(" abc", null) = " abc"
* StringUtils.stripEnd("abc ", null) = "abc"
* StringUtils.stripEnd(" abc ", null) = " abc"
* StringUtils.stripEnd(" abcyx", "xyz") = " abc"
* Strips any of a set of characters from the end of a String.
* @param str
* @param stripChars
* @example StringUtils.stripEnd(null, *) = null
* @example StringUtils.stripEnd("", *) = ""
* @example StringUtils.stripEnd("abc", "") = "abc"
* @example StringUtils.stripEnd("abc", null) = "abc"
* @example StringUtils.stripEnd(" abc", null) = " abc"
* @example StringUtils.stripEnd("abc ", null) = "abc"
* @example StringUtils.stripEnd(" abc ", null) = " abc"
* @example StringUtils.stripEnd(" abcyx", "xyz") = " abc"
*/

@@ -139,12 +202,15 @@ StringUtils.stripEnd = function (str, stripChars) {

/**
* StringUtils.equal(null, null) = true
* StringUtils.equal(undefined, undefined) = true
* StringUtils.equal(undefined, null) = false
* StringUtils.equal(null, undefined) = false
* StringUtils.equal(null, "abc") = false
* StringUtils.equal("abc", null) = false
* StringUtils.equal("abc", undefined) = false
* StringUtils.equal(undefined, "abc") = false
* StringUtils.equal("abc", "def") = false
* StringUtils.equal("abc", "abc") = true
* Compares two CharSequences, returning true if they represent equal sequences of characters.
* @param str1
* @param str2
* @example StringUtils.equal(null, null) = true
* @example StringUtils.equal(undefined, undefined) = true
* @example StringUtils.equal(undefined, null) = false
* @example StringUtils.equal(null, undefined) = false
* @example StringUtils.equal(null, "abc") = false
* @example StringUtils.equal("abc", null) = false
* @example StringUtils.equal("abc", undefined) = false
* @example StringUtils.equal(undefined, "abc") = false
* @example StringUtils.equal("abc", "def") = false
* @example StringUtils.equal("abc", "abc") = true
*/

@@ -165,13 +231,16 @@ StringUtils.equals = function (str1, str2) {

/**
* StringUtils.equal(null, null) = true
* StringUtils.equal(undefined, undefined) = true
* StringUtils.equal(undefined, null) = false
* StringUtils.equal(null, undefined) = false
* StringUtils.equal(null, "abc") = false
* StringUtils.equal("abc", null) = false
* StringUtils.equal("abc", undefined) = false
* StringUtils.equal(undefined, "abc") = false
* StringUtils.equal("abc", "def") = false
* StringUtils.equal("abc", "abc") = true
* StringUtils.equal("abc", "AbC") = true
* Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
* @param str1
* @param str2
* @example StringUtils.equal(null, null) = true
* @example StringUtils.equal(undefined, undefined) = true
* @example StringUtils.equal(undefined, null) = false
* @example StringUtils.equal(null, undefined) = false
* @example StringUtils.equal(null, "abc") = false
* @example StringUtils.equal("abc", null) = false
* @example StringUtils.equal("abc", undefined) = false
* @example StringUtils.equal(undefined, "abc") = false
* @example StringUtils.equal("abc", "def") = false
* @example StringUtils.equal("abc", "abc") = true
* @example StringUtils.equal("abc", "AbC") = true
*/

@@ -192,9 +261,13 @@ StringUtils.equalsIgnoreCase = function (str1, str2) {

/**
* StringUtils.indexOf(null, *) = -1
* StringUtils.indexOf(undefined, *) = -1
* StringUtils.indexOf("", *) = -1
* StringUtils.indexOf("aabaabaa", 'a') = 0
* StringUtils.indexOf("aabaabaa", 'b') = 2
* StringUtils.indexOf("aabaabaa", 'b', 3) = 5
* StringUtils.indexOf("aabaabaa", '') = 0
* Finds the first index within a CharSequence, handling null.
* @param str
* @param searchStr
* @param startPos
* @example StringUtils.indexOf(null, *) = -1
* @example StringUtils.indexOf(undefined, *) = -1
* @example StringUtils.indexOf("", *) = -1
* @example StringUtils.indexOf("aabaabaa", 'a') = 0
* @example StringUtils.indexOf("aabaabaa", 'b') = 2
* @example StringUtils.indexOf("aabaabaa", 'b', 3) = 5
* @example StringUtils.indexOf("aabaabaa", '') = 0
*/

@@ -212,10 +285,12 @@ StringUtils.indexOf = function (str, searchStr, startPos) {

/**
* StringUtils.lastIndexOf("aFkyk", "k") =4
* StringUtils.lastIndexOf("a Fkyk", " "); =1
* StringUtils.lastIndexOf("aabaabaa", "b"); =5
* StringUtils.lastIndexOf("aabaabaa", "b", 4); =2
* Returns the index within seq of the first occurrence of the specified character, starting the search at the specified index.
* @param str
* @param searchStr
* @param position
* @example StringUtils.lastIndexOf("aFkyk", "k") =4
* @example StringUtils.lastIndexOf("a Fkyk", " "); =1
* @example StringUtils.lastIndexOf("aabaabaa", "b"); =5
* @example StringUtils.lastIndexOf("aabaabaa", "b", 4); =2
*/
StringUtils.lastIndexOf = function (str, searchStr,
// tslint:disable-next-line:trailing-comma
position) {
StringUtils.lastIndexOf = function (str, searchStr, position) {
if (object_utils_1.ObjectUtils.isNullOrUndefined(str) ||

@@ -232,2 +307,7 @@ object_utils_1.ObjectUtils.isNullOrUndefined(searchStr) ||

};
/**
* Checks if CharSequence contains a search character, handling null.
* @param str
* @param searchStr
*/
StringUtils.contains = function (str, searchStr) {

@@ -241,2 +321,7 @@ if (object_utils_1.ObjectUtils.isString(str) && object_utils_1.ObjectUtils.isString(searchStr)) {

};
/**
* Checks if CharSequence contains a search CharSequence irrespective of case, handling null.
* @param str
* @param searchStr
*/
StringUtils.containsIgnoreCase = function (str, searchStr) {

@@ -250,2 +335,8 @@ if (object_utils_1.ObjectUtils.isString(str) && object_utils_1.ObjectUtils.isString(searchStr)) {

};
/**
* Gets a substring from the specified String avoiding exceptions.
* @param str
* @param start
* @param end
*/
StringUtils.subString = function (str, start, end) {

@@ -267,2 +358,7 @@ if (!object_utils_1.ObjectUtils.isString(str) ||

};
/**
* Determines whether the beginning of this string instance matches the specified string.
* @param str
* @param prefix
*/
StringUtils.startWith = function (str, prefix) {

@@ -276,2 +372,7 @@ if (!object_utils_1.ObjectUtils.isString(str) || !object_utils_1.ObjectUtils.isString(prefix)) {

};
/**
* Determines whether the beginning of this string instance matches the specified string irrespective of case.
* @param str
* @param prefix
*/
StringUtils.startWithIgnoreCase = function (str, prefix) {

@@ -285,2 +386,7 @@ if (!object_utils_1.ObjectUtils.isString(str) || !object_utils_1.ObjectUtils.isString(prefix)) {

};
/**
* Determines whether the end of this string instance matches the specified string.
* @param str
* @param suffix
*/
StringUtils.endWith = function (str, suffix) {

@@ -292,2 +398,7 @@ if (!object_utils_1.ObjectUtils.isString(str) || !object_utils_1.ObjectUtils.isString(suffix)) {

};
/**
* Determines whether the end of this string instance matches the specified string irrespective of case.
* @param str
* @param suffix
*/
StringUtils.endWithIgnoreCase = function (str, suffix) {

@@ -301,5 +412,12 @@ if (!object_utils_1.ObjectUtils.isString(str) || !object_utils_1.ObjectUtils.isString(suffix)) {

};
/**
* check if current char is whitespace
* @param ch
*/
StringUtils.isWhitespace = function (ch) {
return " \f\n\r\t\v\u00A0\u2028\u2029".indexOf(ch) > -1;
};
/**
* Initializes a new string of the guid structure.
*/
StringUtils.newGuid = function () {

@@ -306,0 +424,0 @@ return (this.S4() +

{
"name": "ts-commons",
"version": "0.0.39",
"version": "1.0.0",
"description": "common methods for typescript",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"test": "nyc mocha dist/test --recursive",
"posttest": "npm run removenyc && del-cli coverage",
"posttest": "karma start && npm run removenyc && del-cli coverage",
"prepublish": "tsc",

@@ -32,2 +32,3 @@ "cover": "tsc -p tsconfig.test.json && istanbul cover ./node_modules/mocha/bin/_mocha dist/test/**/*.test.js --recursive",

"@types/chai": "~4.1.3",
"@types/dateformat": "^1.0.1",
"@types/mocha": "~5.2.1",

@@ -40,2 +41,3 @@ "awesome-typescript-loader": "~5.2.0",

"cross-env": "~5.2.0",
"dateformat": "^3.0.3",
"del-cli": "~1.1.0",

@@ -53,2 +55,9 @@ "dts-generator": "^2.1.0",

"istanbul": "~0.4.5",
"karma": "^3.0.0",
"karma-browserify": "^5.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"merge-stream": "^1.0.1",

@@ -55,0 +64,0 @@ "mocha": "~5.2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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