@kakasoo/proto-typescript
Advanced tools
Comparing version 1.18.0 to 1.19.0
@@ -6,2 +6,3 @@ import { ToPrimitive } from '../interfaces/to-primitive.interface'; | ||
import { TypedArray } from './typed-array.class'; | ||
import { TypedBoolean } from './typed-boolean.class'; | ||
import { TypedNumber } from './typed-number.class'; | ||
@@ -12,3 +13,3 @@ import { TypedObject } from './typed-object.class'; | ||
*/ | ||
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'>, ToPrimitive<T | `${T}`> { | ||
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'>, ToPrimitive<T | `${T}`> { | ||
private readonly string; | ||
@@ -19,2 +20,10 @@ constructor(data?: T); | ||
*/ | ||
concat<Strings extends ReadonlyOrNot<(string | TypedString<string>)[]>>(...strings: Strings): TypedString<ReturnType<typeof StringPrototype.concat<`${T}`, TypedString.ValueTypes<Strings>>>>; | ||
/** | ||
* @inheritdoc | ||
*/ | ||
includes<SearchString extends string, Position extends number>(searchString: SearchString, position?: Position): TypedBoolean<ReturnType<typeof StringPrototype.includes<`${T}`, SearchString, Position>>>; | ||
/** | ||
* @inheritdoc | ||
*/ | ||
toLowerCase(): TypedString<ReturnType<typeof StringPrototype.toLowerCase<`${T}`>>>; | ||
@@ -45,6 +54,2 @@ /** | ||
trimStart(): TypedString<ReturnType<typeof StringPrototype.trimStart<`${T}`>>>; | ||
/** | ||
* @inheritdoc | ||
*/ | ||
concat<Strings extends ReadonlyOrNot<(string | TypedString<string>)[]>>(...strings: Strings): TypedString<ReturnType<typeof StringPrototype.concat<`${T}`, TypedString.ValueTypes<Strings>>>>; | ||
typedLength(): TypedNumber<StringType.Length<`${T}`>>; | ||
@@ -51,0 +56,0 @@ get length(): StringType.Length<`${T}`>; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const typed_array_class_1 = require("./typed-array.class"); | ||
const typed_boolean_class_1 = require("./typed-boolean.class"); | ||
const typed_number_class_1 = require("./typed-number.class"); | ||
@@ -21,2 +22,17 @@ const typed_object_class_1 = require("./typed-object.class"); | ||
*/ | ||
concat(...strings) { | ||
const primitiveStrs = strings.map((el) => (this.isTypedClass(el) ? el.toPrimitive() : el)); | ||
const initialValue = prototypes_1.ArrayPrototype.join([this.string, ...primitiveStrs], ''); | ||
return new TypedString(initialValue); | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
includes(searchString, position) { | ||
const initialValue = prototypes_1.StringPrototype.includes(this.string, searchString, position); | ||
return new typed_boolean_class_1.TypedBoolean(initialValue); | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
toLowerCase() { | ||
@@ -68,10 +84,2 @@ const initialValue = prototypes_1.StringPrototype.toLowerCase(this.string); | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
concat(...strings) { | ||
const primitiveStrs = strings.map((el) => (this.isTypedClass(el) ? el.toPrimitive() : el)); | ||
const initialValue = prototypes_1.ArrayPrototype.join([this.string, ...primitiveStrs], ''); | ||
return new TypedString(initialValue); | ||
} | ||
typedLength() { | ||
@@ -78,0 +86,0 @@ return new typed_number_class_1.TypedNumber(this.length); |
@@ -45,3 +45,3 @@ import { ArrayType, StringType } from '../types'; | ||
*/ | ||
includes<Container extends string, SearchString extends string, Position extends number>(container: Container, searchString: SearchString, position?: Position | undefined): StringType.Includes<Container, SearchString, 0>; | ||
includes<Container extends string, SearchString extends string, Position extends number>(container: Container, searchString: SearchString, position?: Position | undefined): StringType.Includes<Container, SearchString, Position>; | ||
/** | ||
@@ -48,0 +48,0 @@ * Removes the leading white space and line terminator characters from a string. |
@@ -55,3 +55,3 @@ "use strict"; | ||
includes(container, searchString, position) { | ||
return container.includes(searchString); | ||
return container.includes(searchString, position); | ||
}, | ||
@@ -58,0 +58,0 @@ /** |
@@ -67,3 +67,3 @@ import { ArrayType } from './array.type'; | ||
infer Last extends keyof CeilingMap | ||
] ? CeilingMap[BeforeLast] extends '0' ? _Ceil<StringType.ThrowAway<N, _FindLastCeilTarget<StringType.Split<N>>>> : ArrayType.Join<[...Rest, CeilingMap[BeforeLast]], ''> : ''; | ||
] ? CeilingMap[BeforeLast] extends '0' ? _Ceil<StringType.ThrowRight<N, _FindLastCeilTarget<StringType.Split<N>>>> : ArrayType.Join<[...Rest, CeilingMap[BeforeLast]], ''> : ''; | ||
/** | ||
@@ -77,3 +77,3 @@ * 여기서 말하는 N은 소숫점 이하의 숫자들임에 주의하라. | ||
*/ | ||
export type _Round<N extends number, TargetDigit extends number> = N extends StringType.IsDecimal<N, number, number> ? StringType.InsertedFractional<N> extends string ? StringType.At<StringType.InsertedFractional<N>, TargetDigit> extends '5' | '6' | '7' | '8' | '9' ? `${StringType.InsertedInteger<N>}.${CeilFractional<StringType.InsertedFractional<N>, TargetDigit>}` : `${StringType.InsertedInteger<N>}.${StringType.ThrowAway<StringType.InsertedFractional<N>, NumberType.Sub<TargetDigit, 2>>}` : N : N; | ||
export type _Round<N extends number, TargetDigit extends number> = N extends StringType.IsDecimal<N, number, number> ? StringType.InsertedFractional<N> extends string ? StringType.At<StringType.InsertedFractional<N>, TargetDigit> extends '5' | '6' | '7' | '8' | '9' ? `${StringType.InsertedInteger<N>}.${CeilFractional<StringType.InsertedFractional<N>, TargetDigit>}` : `${StringType.InsertedInteger<N>}.${StringType.ThrowRight<StringType.InsertedFractional<N>, NumberType.Sub<TargetDigit, 2>>}` : N : N; | ||
export type Round<N extends number, TargetDigit extends number> = _Round<StringType.ToNumber<StringType.Take<`${N}`, NumberType.Add<TargetDigit, 3>>>, TargetDigit>; | ||
@@ -80,0 +80,0 @@ export {}; |
@@ -32,3 +32,3 @@ import { Conditional } from './arithmetic.type'; | ||
*/ | ||
export type Includes<Conatiner extends string, SearchString extends string, Position extends number = 0> = Conatiner extends `${string}${SearchString}${string}` ? true : false; | ||
export type Includes<Conatiner extends string, SearchString extends string, Position extends number = 0> = ThrowLeft<Conatiner, Position> extends `${string}${SearchString}${string}` ? true : false; | ||
/** | ||
@@ -70,5 +70,7 @@ * It refers to a substitute string, and if there is an un substitute key-value pair, it is inferred as `never`. | ||
export type Take<T extends string, P extends number> = ArrayType.Join<Split<T, '', P>, ''>; | ||
export type ThrowAway<T extends string, P extends number> = ArrayType.Join<Split<T, '', NumberType.Sub<StringType.Length<T>, P>>, ''>; | ||
export type ThrowRight<T extends string, P extends number> = ArrayType.Join<Split<T, '', NumberType.Sub<StringType.Length<T>, P>>, ''>; | ||
export type Reverse<T extends string> = ArrayType.Join<ArrayType.Reverse<Split<T>>, ''>; | ||
export type ThrowLeft<T extends string, P extends number> = Reverse<ArrayType.Join<Split<Reverse<T>, '', NumberType.Sub<StringType.Length<T>, P>>, ''>>; | ||
export {}; | ||
} | ||
//# sourceMappingURL=string.type.d.ts.map |
{ | ||
"name": "@kakasoo/proto-typescript", | ||
"version": "1.18.0", | ||
"version": "1.19.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
131463
1500