configchecker
Advanced tools
Comparing version 0.4.0 to 0.4.1
import { IConfigValueProfile } from '../interfaces/IConfigValueProfile'; | ||
export declare class ConfigValue<T> { | ||
value: T; | ||
export declare class ConfigValue<TValue> { | ||
value: TValue; | ||
protected profile: IConfigValueProfile; | ||
private canBeUndefined; | ||
constructor(value: T, profile: IConfigValueProfile, canBeUndefined?: boolean); | ||
constructor(value: TValue, profile: IConfigValueProfile, canBeUndefined?: boolean); | ||
readonly about: string; | ||
required(): ConfigValue<NonNullable<T>>; | ||
default(value: NonNullable<T>): ConfigValue<T>; | ||
custom<TC>(conversionType: string, convert: (value: NonNullable<T>) => TC): ConfigValue<TC | undefined>; | ||
asType<T>(): ConfigValue<T>; | ||
required(): ConfigValue<NonNullable<TValue>>; | ||
default(value: NonNullable<TValue>): ConfigValue<TValue>; | ||
custom<TvalueCustom>(conversionType: string, convert: (value: NonNullable<TValue>) => TvalueCustom): ConfigValue<TvalueCustom | undefined>; | ||
readonly object: { | ||
[k: string]: TValue; | ||
}; | ||
asType<TvalueCustom>(): ConfigValue<TvalueCustom>; | ||
private checkThatValueCanBeUndefinedToPreventMultipleUsageOfRequiredOrDefault; | ||
} |
@@ -27,2 +27,3 @@ "use strict"; | ||
this.checkThatValueCanBeUndefinedToPreventMultipleUsageOfRequiredOrDefault(); | ||
// TODO: ... it is saying on next line: "Type 'ConfigValue<T>' is not assignable to type 'ConfigValue<NonNullable<T>>'. Type 'T' is not assignable to type 'NonNullable<T>': | ||
return new ConfigValue(this.value || value, this.profile, false); | ||
@@ -41,2 +42,12 @@ }; | ||
}; | ||
Object.defineProperty(ConfigValue.prototype, "object", { | ||
get: function () { | ||
var object = {}; | ||
object[this.profile.key] = this.value; | ||
// TODO: Here is not used the full potencial of the typescript | ||
return object; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/* tslint:disable */ | ||
@@ -43,0 +54,0 @@ // TODO: Strange ts-lint warning Shadowed name: 'T' |
@@ -8,3 +8,3 @@ export declare function decapitalize<T>(mixedObject: { | ||
[key: string]: T; | ||
}): { | ||
}, valueIsNotEmpty?: (value: T) => boolean): { | ||
[key: string]: T; | ||
@@ -11,0 +11,0 @@ }; |
@@ -13,7 +13,8 @@ "use strict"; | ||
exports.decapitalize = decapitalize; | ||
function emptyKeysAsUndefined(mixedObject) { | ||
function emptyKeysAsUndefined(mixedObject, valueIsNotEmpty) { | ||
if (valueIsNotEmpty === void 0) { valueIsNotEmpty = function (value) { return !!value; }; } | ||
var purgedObject = {}; | ||
for (var _i = 0, _a = Object.keys(mixedObject); _i < _a.length; _i++) { | ||
var mixedKey = _a[_i]; | ||
if (mixedObject[mixedKey]) { | ||
if (valueIsNotEmpty(mixedObject[mixedKey])) { | ||
purgedObject[mixedKey] = mixedObject[mixedKey]; | ||
@@ -20,0 +21,0 @@ } |
{ | ||
"name": "configchecker", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Awesome checker of config - fully support typescript, fluent API,...", | ||
@@ -16,3 +16,3 @@ "main": "lib/index.js", | ||
"lint": "tslint -p tsconfig.json", | ||
"prepublish": "npm test && npm run lint", | ||
"prepublish": "npm test && npm run lint && npm run build", | ||
"preversion": "npm run lint", | ||
@@ -19,0 +19,0 @@ "postversion": "git push && git push --tags" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14739
283