@kakasoo/proto-typescript
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -1,8 +0,7 @@ | ||
import { At, Join } from '../types'; | ||
import { At, Concat, Join } from '../types'; | ||
export declare const ArrayPrototype: { | ||
push<Conatiner extends any[] | readonly any[], Items extends any[] | readonly any[]>(container: Conatiner, ...items: Items): [...Conatiner, ...Items]; | ||
/** | ||
* Returns the item located at the specified index. | ||
* @inheritdoc | ||
* @param container | ||
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item. | ||
* @returns | ||
*/ | ||
@@ -9,0 +8,0 @@ at<Container extends any[] | readonly any[], Index extends number>(container: Container, index: Index): At<Container, Index>; |
@@ -5,7 +5,8 @@ "use strict"; | ||
exports.ArrayPrototype = { | ||
push(container, ...items) { | ||
return [...container, ...items]; | ||
}, | ||
/** | ||
* Returns the item located at the specified index. | ||
* @inheritdoc | ||
* @param container | ||
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item. | ||
* @returns | ||
*/ | ||
@@ -12,0 +13,0 @@ at(container, index) { |
@@ -6,3 +6,3 @@ import { toPrimitive } from './interfaces/to-primitive.interface'; | ||
import { MethodsFrom } from './types'; | ||
export declare class TypedArray<T extends any[] | readonly any[]> implements Pick<MethodsFrom<Array<any>>, 'join' | 'at'>, toPrimitive<[...T]> { | ||
export declare class TypedArray<T extends any[] | readonly any[]> implements Pick<MethodsFrom<Array<any>>, 'join' | 'at' | 'push'>, toPrimitive<[...T]> { | ||
private readonly data; | ||
@@ -12,2 +12,14 @@ constructor(data: T); | ||
/** | ||
* Appends new elements to the end of an array | ||
* | ||
* @example | ||
* ```ts | ||
* new TypedArray([1, 2, 3] as const).push(4 as const); // [1, 2, 3, 4] | ||
* ``` | ||
* | ||
* @param items | ||
* @returns Unlike JavaScript's Array.prototype.join, it returns a new TypeArray instance rather than the length of the inserted data. | ||
*/ | ||
push<Items extends any[] | readonly any[]>(...items: Items): TypedArray<ReturnType<typeof ArrayPrototype.push<T, Items>>>; | ||
/** | ||
* @inheritDoc | ||
@@ -18,3 +30,6 @@ */ | ||
* type-safe join. | ||
* @example new TypedArray([1, 2, 3] as const).join(','); | ||
* @example | ||
* ```ts | ||
* new TypedArray([1, 2, 3] as const).join(','); // '1,2,3' | ||
* ``` | ||
* | ||
@@ -21,0 +36,0 @@ * @inheritdoc |
@@ -13,2 +13,16 @@ "use strict"; | ||
/** | ||
* Appends new elements to the end of an array | ||
* | ||
* @example | ||
* ```ts | ||
* new TypedArray([1, 2, 3] as const).push(4 as const); // [1, 2, 3, 4] | ||
* ``` | ||
* | ||
* @param items | ||
* @returns Unlike JavaScript's Array.prototype.join, it returns a new TypeArray instance rather than the length of the inserted data. | ||
*/ | ||
push(...items) { | ||
return new TypedArray([...this.data, ...items]); | ||
} | ||
/** | ||
* @inheritDoc | ||
@@ -22,3 +36,6 @@ */ | ||
* type-safe join. | ||
* @example new TypedArray([1, 2, 3] as const).join(','); | ||
* @example | ||
* ```ts | ||
* new TypedArray([1, 2, 3] as const).join(','); // '1,2,3' | ||
* ``` | ||
* | ||
@@ -25,0 +42,0 @@ * @inheritdoc |
@@ -5,3 +5,4 @@ import { toPrimitive } from './interfaces/to-primitive.interface'; | ||
import { TypedNumber } from './typed-number.class'; | ||
export declare class TypedString<T extends string | number | boolean = ''> implements toPrimitive<`${T}`> { | ||
import { MethodsFrom } from './types'; | ||
export declare class TypedString<T extends string | number | boolean = ''> implements Pick<MethodsFrom<String>, 'split'>, toPrimitive<T | `${T}`> { | ||
private readonly data; | ||
@@ -8,0 +9,0 @@ constructor(data?: T); |
import { Add, Divide, Multiply, NToNumber, Remainder, Sub } from './number.type'; | ||
import { Equal, Merge } from './object.type'; | ||
export type ElementOf<Tuple extends readonly any[] | any[]> = [...Tuple] extends (infer E)[] ? E : never; | ||
export type Length<T extends any[]> = T['length']; | ||
export type Length<T extends any[] | readonly any[]> = T['length']; | ||
export type ArrayValues<T extends any[]> = T[number]; | ||
@@ -12,3 +12,4 @@ /** | ||
*/ | ||
export type Push<T extends any[], V> = [...T, V]; | ||
export type Push<T extends any[] | readonly any[], V extends any> = [...T, V]; | ||
export type Concat<T extends any[] | readonly any[], P extends any[] | readonly any[]> = [...T, ...P]; | ||
export type NTuple<N extends number, T extends any[] = []> = T['length'] extends N ? T : NTuple<N, Push<T, any>>; | ||
@@ -15,0 +16,0 @@ /** |
export type MethodsFrom<T> = { | ||
[K in keyof T as T[K] extends (...args: any[]) => any ? K : never]: Function; | ||
[K in keyof T as T[K] extends (...args: any[]) => any ? K : never]: (...args: any[]) => any; | ||
}; | ||
//# sourceMappingURL=function.type.d.ts.map |
{ | ||
"name": "@kakasoo/proto-typescript", | ||
"version": "1.6.1", | ||
"version": "1.7.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
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
58855
616