@kakasoo/proto-typescript
Advanced tools
Comparing version 1.2.0 to 1.3.0
import { Join } from '../types'; | ||
export declare namespace ArrayPrototype { | ||
export declare const ArrayPrototype: { | ||
/** | ||
@@ -12,4 +12,4 @@ * type-safe join. | ||
*/ | ||
function join<Container extends readonly (string | number)[] | (string | number)[], Separator extends string = ','>(arr: Container, separator?: Separator): Join<Container, Separator>; | ||
} | ||
join<Container extends readonly (string | number | boolean)[] | (string | number | boolean)[], Separator extends string = ",">(arr: Container, separator?: Separator): Join<Container, Separator>; | ||
}; | ||
//# sourceMappingURL=array.prototype.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ArrayPrototype = void 0; | ||
var ArrayPrototype; | ||
(function (ArrayPrototype) { | ||
exports.ArrayPrototype = { | ||
/** | ||
@@ -15,7 +14,6 @@ * type-safe join. | ||
*/ | ||
function join(arr, separator = ',') { | ||
join(arr, separator = ',') { | ||
return arr.join(separator); | ||
} | ||
ArrayPrototype.join = join; | ||
})(ArrayPrototype || (exports.ArrayPrototype = ArrayPrototype = {})); | ||
}, | ||
}; | ||
//# sourceMappingURL=array.prototype.js.map |
@@ -1,2 +0,5 @@ | ||
export declare namespace StringPrototype { } | ||
import { Split } from '../types'; | ||
export declare const StringPrototype: { | ||
split<Container extends string, Splitter extends string, Limit extends number>(container: Container, splitter: Splitter, limit?: Limit | undefined): Split<Container, Splitter, Limit>; | ||
}; | ||
//# sourceMappingURL=string.prototype.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StringPrototype = void 0; | ||
exports.StringPrototype = { | ||
split(container, splitter, limit) { | ||
return container.split(splitter, limit); | ||
}, | ||
}; | ||
//# sourceMappingURL=string.prototype.js.map |
import { toPrimitive } from './interfaces/to-primitive.interface'; | ||
import { ArrayPrototype } from './prototypes'; | ||
import { TypedString } from './types/typed-string.class'; | ||
import { TypedString } from './typed-string.class'; | ||
export declare class TypedArray<T extends any[] | readonly any[]> implements toPrimitive<[...T]> { | ||
@@ -12,5 +12,5 @@ private readonly data; | ||
*/ | ||
join<Separator extends string>(separator: Separator): TypedString<ReturnType<typeof ArrayPrototype.join<T, Separator>>>; | ||
join<Separator extends string>(separator?: Separator): TypedString<ReturnType<typeof ArrayPrototype.join<T, Separator>>>; | ||
toPrimitive(): [...T]; | ||
} | ||
//# sourceMappingURL=typed-array.class.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const prototypes_1 = require("./prototypes"); | ||
const typed_string_class_1 = require("./types/typed-string.class"); | ||
const typed_string_class_1 = require("./typed-string.class"); | ||
class TypedArray { | ||
@@ -16,3 +16,3 @@ constructor(data) { | ||
*/ | ||
join(separator) { | ||
join(separator = '') { | ||
const initalValue = prototypes_1.ArrayPrototype.join(this.data, separator); | ||
@@ -19,0 +19,0 @@ return new typed_string_class_1.TypedString(initalValue); |
@@ -30,2 +30,5 @@ import { Length } from './array.type'; | ||
export type StringToNumber<S extends string> = S extends NumberToString<infer P> ? P : never; | ||
export type Falsy = false | 0 | '' | null | undefined; | ||
export type Truthy<T> = T extends Falsy ? false : true; | ||
export type Conditional<Condition, T, F> = Truthy<Condition> extends true ? T : F; | ||
//# sourceMappingURL=arithmetic.type.d.ts.map |
@@ -45,4 +45,6 @@ import { Add, Divide, Multiply, NToNumber, Remainder, Sub } from './number.type'; | ||
* Join<string[], "-">; // string | ||
* Join<['a', 'b', 'c', true], '-'>; // 'a-b-c-true' | ||
* Join<['a', 'b', 'c', number], '-'>; // 'a-b-c-${number}' | ||
*/ | ||
export type Join<T extends readonly (string | number)[] | (string | number)[], U extends string = ','> = T extends readonly [infer F extends string | number, ...infer Rest extends (string | number)[]] ? Rest extends [] ? `${F}` : `${F}${U}${Join<Rest, U>}` : string; | ||
export type Join<T extends readonly (string | number | boolean)[] | (string | number | boolean)[], U extends string = ','> = T extends readonly [infer F extends string | number | boolean, ...infer Rest extends (string | number | boolean)[]] ? Rest extends [] ? `${F}` : `${F}${U}${Join<Rest, U>}` : string; | ||
export type IsTuple<T extends readonly any[] | { | ||
@@ -49,0 +51,0 @@ length: number; |
@@ -5,2 +5,5 @@ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <P>() => P extends Y ? 1 : 2 ? true : false; | ||
}; | ||
export type ToInterface<T> = { | ||
[key in keyof T]: T[key]; | ||
}; | ||
//# sourceMappingURL=object.type.d.ts.map |
@@ -0,1 +1,3 @@ | ||
import { Conditional } from './arithmetic.type'; | ||
import { Take } from './array.type'; | ||
import { Sub } from './number.type'; | ||
@@ -25,8 +27,10 @@ export type ToStringTuple<T> = T extends string[] ? T : never; | ||
export type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false; | ||
type _Split<Conatiner extends string, Splitter extends string = ''> = Conatiner extends `${infer FirstWord}${Splitter}${infer Rest}` ? [FirstWord, ...Split<Rest, Splitter>] : Conatiner extends '' ? [] : [Conatiner]; | ||
/** | ||
* 글자를 분리하여 튜플로 변경하는 타입 | ||
* | ||
* Split<"abcdefg"> // ["a", "b", "c", "d", "e", "f", "g"] | ||
* Split<"abcdefg", ""> // ["a", "b", "c", "d", "e", "f", "g"] | ||
* Split<"abcdefg", "", 3> // ["a", "b", "c"] | ||
*/ | ||
export type Split<T extends string> = T extends `${infer F}${infer Rest}` ? [F, ...Split<Rest>] : []; | ||
export type Split<Conatiner extends string, Splitter extends string = '', Limit extends number = 0> = Conditional<Limit extends 0 ? true : false, _Split<Conatiner, Splitter>, Take<_Split<Conatiner, Splitter>, Limit>>; | ||
export {}; | ||
//# sourceMappingURL=string.type.d.ts.map |
{ | ||
"name": "@kakasoo/proto-typescript", | ||
"version": "1.2.0", | ||
"version": "1.3.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
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
48236
103
467