ts-commons
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -66,5 +66,3 @@ export declare class ObjectUtils { | ||
*/ | ||
static createObject<T>(type: { | ||
new (): T; | ||
}): T; | ||
static createObject<T>(type: new () => T): T; | ||
/** | ||
@@ -76,2 +74,8 @@ * get name of property. | ||
static values(obj: any): any[]; | ||
/** | ||
* if value is null or undefined return default value, else return value. | ||
* @param value | ||
* @param defaultValue | ||
*/ | ||
static getOrDefault<T>(value: T, defaultValue: NonNullable<T>): NonNullable<T>; | ||
} |
@@ -117,2 +117,15 @@ "use strict"; | ||
}; | ||
/** | ||
* if value is null or undefined return default value, else return value. | ||
* @param value | ||
* @param defaultValue | ||
*/ | ||
ObjectUtils.getOrDefault = function (value, defaultValue) { | ||
if (ObjectUtils.isNullOrUndefined(value)) { | ||
return defaultValue; | ||
} | ||
else { | ||
return value; | ||
} | ||
}; | ||
return ObjectUtils; | ||
@@ -119,0 +132,0 @@ }()); |
@@ -18,8 +18,8 @@ export declare class StringUtils { | ||
* @param str | ||
* @example StringUtils.isNotEmpty(null) = false | ||
* @example StringUtils.isNotEmpty(undefined) = false | ||
* @example StringUtils.isNotEmpty("") = false | ||
* @example StringUtils.isNotEmpty(" ") = true | ||
* @example StringUtils.isNotEmpty("bob") = true | ||
* @example StringUtils.isNotEmpty(" bob ") = true | ||
* @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 | ||
*/ | ||
@@ -30,8 +30,8 @@ static isNotEmpty(str: string | undefined | null): boolean; | ||
* @param str | ||
* @example StringUtils.isBlank(null) = true | ||
* @example StringUtils.isBlank(undefined) = true | ||
* @example StringUtils.isBlank("") = true | ||
* @example StringUtils.isBlank(" ") = true | ||
* @example StringUtils.isBlank("bob") = false | ||
* @example StringUtils.isBlank(" bob ") = false | ||
* @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 | ||
*/ | ||
@@ -42,8 +42,8 @@ static isBlank(str: string | undefined | null): boolean; | ||
* @param str | ||
* @example StringUtils.isNotBlank(null) = false | ||
* @example StringUtils.isNotBlank(undefined) = false | ||
* @example StringUtils.isNotBlank("") = false | ||
* @example StringUtils.isNotBlank(" ") = false | ||
* @example StringUtils.isNotBlank("bob") = true | ||
* @example StringUtils.isNotBlank(" bob ") = true | ||
* @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 | ||
*/ | ||
@@ -50,0 +50,0 @@ static isNotBlank(str: string | undefined | null): boolean; |
@@ -24,8 +24,8 @@ "use strict"; | ||
* @param str | ||
* @example StringUtils.isNotEmpty(null) = false | ||
* @example StringUtils.isNotEmpty(undefined) = false | ||
* @example StringUtils.isNotEmpty("") = false | ||
* @example StringUtils.isNotEmpty(" ") = true | ||
* @example StringUtils.isNotEmpty("bob") = true | ||
* @example StringUtils.isNotEmpty(" bob ") = true | ||
* @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 | ||
*/ | ||
@@ -38,8 +38,8 @@ StringUtils.isNotEmpty = function (str) { | ||
* @param str | ||
* @example StringUtils.isBlank(null) = true | ||
* @example StringUtils.isBlank(undefined) = true | ||
* @example StringUtils.isBlank("") = true | ||
* @example StringUtils.isBlank(" ") = true | ||
* @example StringUtils.isBlank("bob") = false | ||
* @example StringUtils.isBlank(" bob ") = false | ||
* @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 | ||
*/ | ||
@@ -52,8 +52,8 @@ StringUtils.isBlank = function (str) { | ||
* @param str | ||
* @example StringUtils.isNotBlank(null) = false | ||
* @example StringUtils.isNotBlank(undefined) = false | ||
* @example StringUtils.isNotBlank("") = false | ||
* @example StringUtils.isNotBlank(" ") = false | ||
* @example StringUtils.isNotBlank("bob") = true | ||
* @example StringUtils.isNotBlank(" bob ") = true | ||
* @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 | ||
*/ | ||
@@ -60,0 +60,0 @@ StringUtils.isNotBlank = function (str) { |
{ | ||
"name": "ts-commons", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "common methods for typescript", | ||
@@ -8,5 +8,6 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"lint": "tslint src/**/*", | ||
"pretest": "npm run deletedist && tsc -p tsconfig.test.json", | ||
"test": "nyc mocha dist/test --recursive", | ||
"posttest": "npm run removenyc && del-cli coverage", | ||
"posttest": "karma start && npm run removenyc && del-cli coverage", | ||
"prepublish": "tsc", | ||
@@ -43,3 +44,20 @@ "cover": "tsc -p tsconfig.test.json && istanbul cover ./node_modules/mocha/bin/_mocha dist/test/**/*.test.js --recursive", | ||
"dts-generator": "^2.1.0", | ||
"gulp": "^3.9.1", | ||
"gulp-browserify": "^0.5.1", | ||
"gulp-clean": "^0.4.0", | ||
"gulp-cli": "^2.0.1", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-sourcemaps": "^2.6.4", | ||
"gulp-typescript": "^5.0.0-alpha.3", | ||
"gulp-uglify": "^3.0.1", | ||
"gulp-util": "^3.0.8", | ||
"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-firefox-launcher": "^1.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"merge-stream": "^1.0.1", | ||
@@ -46,0 +64,0 @@ "mocha": "~5.2.0", |
@@ -33,7 +33,2 @@ # ts-commons | ||
you can run test on [RunKit](https://runkit.com/wz2cool/5b952e2dbdc3c3001270457b) | ||
asdfasdf | ||
asdfasdf | ||
asdfadf | ||
you can run test on [RunKit](https://runkit.com/wz2cool/5b952e2dbdc3c3001270457b) |
Sorry, the diff of this file is not supported yet
102493
1895
45
35
33