@kakasoo/proto-typescript
Advanced tools
Comparing version 1.24.0 to 1.25.0
import { ToPrimitive } from '../interfaces'; | ||
import { ReadonlyOrNot } from '../types'; | ||
import { Equal, ReadonlyOrNot } from '../types'; | ||
import { TypedObject } from './typed-object.class'; | ||
@@ -7,2 +7,16 @@ export declare class TypedBoolean<T extends boolean = false> extends TypedObject<T> implements ToPrimitive<T> { | ||
constructor(data?: T); | ||
/** | ||
* @example | ||
* ```ts | ||
* const yn = TypedBoolean.refine({ true: 'Y', false: 'N' }); | ||
* const t = yn('Y'); // true | ||
* const f = yn('N'); // false | ||
* ``` | ||
* @param map | ||
* @returns | ||
*/ | ||
static refine<T extends string, F extends string>(map: { | ||
true: T; | ||
false: F; | ||
}): <Choice extends T | F>(data: Choice) => Equal<Choice, T> extends true ? T : F; | ||
toPrimitive(): T; | ||
@@ -9,0 +23,0 @@ } |
@@ -11,2 +11,20 @@ "use strict"; | ||
} | ||
/** | ||
* @example | ||
* ```ts | ||
* const yn = TypedBoolean.refine({ true: 'Y', false: 'N' }); | ||
* const t = yn('Y'); // true | ||
* const f = yn('N'); // false | ||
* ``` | ||
* @param map | ||
* @returns | ||
*/ | ||
static refine(map) { | ||
return function (data) { | ||
if (data === map.true) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
} | ||
toPrimitive() { | ||
@@ -13,0 +31,0 @@ return this.boolean; |
@@ -9,5 +9,2 @@ import { ToPrimitive } from '../interfaces/to-primitive.interface'; | ||
import { TypedObject } from './typed-object.class'; | ||
/** | ||
* @todo support iterator. | ||
*/ | ||
export declare class TypedString<T extends string | number | boolean = ''> extends TypedObject<T> implements Pick<FunctionType.MethodsFrom<String>, 'split' | 'at' | 'concat' | 'trimStart' | 'trimEnd' | 'trim' | 'padEnd' | 'padStart' | 'toLowerCase' | 'toUpperCase' | 'includes' | 'substring' | 'startsWith' | 'endsWith' | 'repeat' | 'indexOf'>, ToPrimitive<T | `${T}`>, Iterable<ArrayType.ElementOf<StringType.Split<`${T}`>>> { | ||
@@ -14,0 +11,0 @@ [n: number]: ArrayType.At<StringType.Split<`${T}`>, number>; |
@@ -9,5 +9,2 @@ "use strict"; | ||
const typed_object_class_1 = require("./typed-object.class"); | ||
/** | ||
* @todo support iterator. | ||
*/ | ||
class TypedString extends typed_object_class_1.TypedObject { | ||
@@ -14,0 +11,0 @@ string; |
{ | ||
"name": "@kakasoo/proto-typescript", | ||
"version": "1.24.0", | ||
"version": "1.25.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
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
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
179185
1796