@fgv/ts-utils
Advanced tools
Comparing version 0.1.0 to 0.1.3
{ | ||
"name": "@fgv/ts-utils", | ||
"version": "0.1.0", | ||
"version": "0.1.3", | ||
"description": "Assorted Typescript Utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,12 @@ import { Result } from './result'; | ||
} | ||
export interface RangeOfFormats { | ||
minOnly: string; | ||
maxOnly: string; | ||
minMax: string; | ||
} | ||
export declare const DEFAULT_RANGEOF_FORMATS: { | ||
minOnly: string; | ||
maxOnly: string; | ||
minMax: string; | ||
}; | ||
export declare class RangeOf<T> implements RangeOfProperties<T> { | ||
@@ -12,2 +22,3 @@ readonly min?: T; | ||
static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>>; | ||
static propertiesToString<T>(range: RangeOfProperties<T>, formats?: RangeOfFormats, emptyValue?: T): string | undefined; | ||
protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater'; | ||
@@ -17,3 +28,5 @@ check(t: T): 'less' | 'included' | 'greater'; | ||
findTransition(t: T): T | undefined; | ||
toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string>; | ||
format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined; | ||
protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater'; | ||
} |
@@ -23,5 +23,15 @@ "use strict"; | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RangeOf = void 0; | ||
exports.RangeOf = exports.DEFAULT_RANGEOF_FORMATS = void 0; | ||
const result_1 = require("./result"); | ||
const mustache_1 = __importDefault(require("mustache")); | ||
; | ||
exports.DEFAULT_RANGEOF_FORMATS = { | ||
minOnly: '{{min}}-', | ||
maxOnly: '-{{max}}', | ||
minMax: '{{min}}-{{max}}', | ||
}; | ||
class RangeOf { | ||
@@ -39,2 +49,17 @@ constructor(min, max) { | ||
} | ||
static propertiesToString(range, formats, emptyValue) { | ||
formats = formats !== null && formats !== void 0 ? formats : exports.DEFAULT_RANGEOF_FORMATS; | ||
if ((range.min !== undefined) && (range.min !== emptyValue)) { | ||
if ((range.max !== undefined) && (range.max !== emptyValue)) { | ||
return mustache_1.default.render(formats.minMax, range); | ||
} | ||
else { | ||
return mustache_1.default.render(formats.minOnly, range); | ||
} | ||
} | ||
else if ((range.max !== undefined) && (range.max !== emptyValue)) { | ||
return mustache_1.default.render(formats.maxOnly, range); | ||
} | ||
return undefined; | ||
} | ||
static _defaultCompare(t1, t2) { | ||
@@ -70,2 +95,11 @@ if (t1 < t2) { | ||
} | ||
toFormattedProperties(format) { | ||
return { | ||
min: (this.min !== undefined) ? format(this.min) : undefined, | ||
max: (this.max !== undefined) ? format(this.max) : undefined, | ||
}; | ||
} | ||
format(format, formats) { | ||
return RangeOf.propertiesToString(this.toFormattedProperties(format), formats); | ||
} | ||
_compare(t1, t2) { | ||
@@ -76,2 +110,2 @@ return RangeOf._defaultCompare(t1, t2); | ||
exports.RangeOf = RangeOf; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmFuZ2VPZi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yYW5nZU9mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FvQkc7OztBQUVILHFDQUFpRDtBQU9qRCxNQUFhLE9BQU87SUFJaEIsWUFBbUIsR0FBTyxFQUFFLEdBQU87UUFDL0IsSUFBSSxDQUFDLENBQUMsR0FBRyxLQUFLLFNBQVMsQ0FBQyxJQUFJLENBQUMsR0FBRyxLQUFLLFNBQVMsQ0FBQyxDQUFDO1lBQzVDLElBQUksQ0FBQyxRQUFRLENBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxLQUFLLFNBQVMsRUFBR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ZWZpbmVkKSAmJiAodGhpcy5fY29tcGFyZSh0LCB0aGlzLm1pbikgPT09ICdsZXNzJykpIHtcbiAgICAgICAgICAgIHJldHVybiAnbGVzcyc7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCh0aGlzLm1heCAhPT0gdW5kZWZpbmVkKSAmJiAodGhpcy5fY29tcGFyZSh0LCB0aGlzLm1heCkgIT09ICdsZXNzJykpIHtcbiAgICAgICAgICAgIHJldHVybiAnZ3JlYXRlcic7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuICdpbmNsdWRlZCc7XG4gICAgfVxuXG4gICAgcHVibGljIGluY2x1ZGVzKHQ6IFQpOiBib29sZWFuIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuY2hlY2sodCkgPT09ICdpbmNsdWRlZCc7XG4gICAgfVxuXG4gICAgcHVibGljIGZpbmRUcmFuc2l0aW9uKHQ6IFQpOiBUfHVuZGVmaW5lZCB7XG4gICAgICAgIHN3aXRjaCAodGhpcy5jaGVjayh0KSkge1xuICAgICAgICAgICAgY2FzZSAnbGVzcyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWluO1xuICAgICAgICAgICAgY2FzZSAnaW5jbHVkZWQnOlxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1heDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH1cblxuICAgIHB1YmxpYyB0b0Zvcm1hdHRlZFByb3BlcnRpZXMoZm9ybWF0OiAodmFsdWU6IFQpID0+IHN0cmluZ3x1bmRlZmluZWQpOiBSYW5nZU9mUHJvcGVydGllczxzdHJpbmc+IHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIG1pbjogKHRoaXMubWluICE9PSB1bmRlZmluZWQpID8gZm9ybWF0KHRoaXMubWluKSA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIG1heDogKHRoaXMubWF4ICE9PSB1bmRlZmluZWQpID8gZm9ybW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