Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@kakasoo/proto-typescript

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kakasoo/proto-typescript - npm Package Compare versions

Comparing version 1.27.0 to 1.27.1

23

dist/prototypes/array.prototype.d.ts
import { ArrayType, NumberType } from '../types';
import { ReadonlyOrNot } from '../types/primitive.type';
declare function filter<Container extends ReadonlyOrNot<any[]>>(conatiner: Container, predicate: <Index extends number>(value: ArrayType.At<Container, Index>, index?: Index, array?: Container) => boolean): Partial<Container>;
declare function filter<Container extends ReadonlyOrNot<any[]>, FilterNull extends boolean, FilterUndefined extends boolean>(container: Container, predicate: {
filterNull: FilterNull;
filterUndefined: FilterUndefined;
}): ArrayType.Filter<Container, FilterNull, FilterUndefined>;
type TypePredicate<Container extends ReadonlyOrNot<any[]>, Target> = {
<Index extends number, __Target extends Target = Target>(value: ArrayType.At<Container, Index>, index?: Index, array?: Container): value is Target;
};
export declare const ArrayPrototype: {
/**
* Filter `null` or `undefined` element of Array Container.
* @param container
* @param options filtering options
* @param predicate
* @example
* ```ts
* const answer = ArrayPrototype.filter<[1, 2, 3, 4, 5], 2>([1, 2, 3, 4, 5] as const, (el: any): el is 2 => el === 2);
* ```
* @returns
*/
filter: typeof filter;
filter<Container extends ReadonlyOrNot<any[]>, Target = any>(container: Container, predicate: TypePredicate<Container, Target>): ArrayType.Filter<Container, Target>;
/**

@@ -41,3 +42,3 @@ * It only returns the 0th index without subtracting the elements inside the actual container.

*/
some<Target, Conatiner_3 extends ReadonlyOrNot<any[]>>(container: Conatiner_3, predicate: <INNER_TARGET = Target, Index extends number = number>(value: ArrayType.At<Conatiner_3, Index>, index: Index, array: Conatiner_3) => ArrayType.Some<INNER_TARGET, Conatiner_3>): boolean;
some<Target_1, Conatiner_3 extends ReadonlyOrNot<any[]>>(container: Conatiner_3, predicate: <INNER_TARGET = Target_1, Index extends number = number>(value: ArrayType.At<Conatiner_3, Index>, index: Index, array: Conatiner_3) => ArrayType.Some<INNER_TARGET, Conatiner_3>): boolean;
/**

@@ -53,3 +54,3 @@ * @param container

*/
at<Container extends ReadonlyOrNot<any[]>, Index_1 extends number>(container: Container, index: Index_1): ArrayType.At<Container, Index_1>;
at<Container_1 extends ReadonlyOrNot<any[]>, Index_1 extends number>(container: Container_1, index: Index_1): ArrayType.At<Container_1, Index_1>;
/**

@@ -66,5 +67,5 @@ * type-safe join.

*/
join<Container_1 extends ReadonlyOrNot<(string | number | bigint | boolean | null | undefined)[]>, Separator extends string = ",">(container: Container_1, separator?: Separator): ArrayType.Join<Container_1, Separator>;
join<Container_2 extends ReadonlyOrNot<(string | number | bigint | boolean | null | undefined)[]>, Separator extends string = ",">(container: Container_2, separator?: Separator): ArrayType.Join<Container_2, Separator>;
};
export {};
//# sourceMappingURL=array.prototype.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayPrototype = void 0;
function filter(container, predicate) {
return (predicate instanceof Function
? container.filter(predicate)
: typeof predicate === 'object' &&
typeof predicate.filterNull === 'boolean' &&
typeof predicate.filterUndefined === 'boolean'
? container.filter((element) => {
if (predicate.filterNull === true) {
return element !== null;
}
if (predicate.filterUndefined === true) {
return element !== undefined;
}
return true;
})
: container);
/**
* Filter `null` or `undefined` element of Array Container.
* @param container
* @param predicate filtering options
* @returns
*/
function filterNullish(container, predicate) {
return container.filter((element) => {
if (predicate.filterNull === true) {
return element !== null;
}
if (predicate.filterUndefined === true) {
return element !== undefined;
}
return true;
});
}
exports.ArrayPrototype = {
/**
* Filter `null` or `undefined` element of Array Container.
* @param container
* @param options filtering options
* @param predicate
* @example
* ```ts
* const answer = ArrayPrototype.filter<[1, 2, 3, 4, 5], 2>([1, 2, 3, 4, 5] as const, (el: any): el is 2 => el === 2);
* ```
* @returns
*/
filter: filter,
filter(container, predicate) {
return container.filter(predicate);
},
/**

@@ -30,0 +35,0 @@ * It only returns the 0th index without subtracting the elements inside the actual container.

@@ -6,2 +6,6 @@ import { NeverType } from './never.type';

export declare namespace ArrayType {
/**
* @todo don't use `Equal` type and use `includes` of `union types` ( make `union incldues` type )
*/
export type Filter<T extends ReadonlyOrNot<any[]>, Target> = T extends [infer First, ...infer Rest] ? Equal<First, Target> extends true ? [First, ...Filter<Rest, Target>] : Filter<Rest, Target> : [];
type _FilterNull<FilterNull extends boolean, Target> = FilterNull extends true ? Equal<Target, null> extends true ? never : Target : Target;

@@ -12,3 +16,3 @@ type _FilterUndefined<FilterUndefined extends boolean, Target> = FilterUndefined extends true ? Equal<Target, undefined> extends true ? never : Target : Target;

*/
export type Filter<T extends ReadonlyOrNot<any[]>, AllowNull extends boolean, AllowUndefined extends boolean> = T extends [infer First, ...infer Rest] ? NeverType.IsNever<_FilterNull<AllowNull, First>> extends true ? Filter<Rest, AllowNull, AllowUndefined> : NeverType.IsNever<_FilterUndefined<AllowUndefined, First>> extends true ? Filter<Rest, AllowNull, AllowUndefined> : [First, ...Filter<Rest, AllowNull, AllowUndefined>] : [];
export type FilterNullish<T extends ReadonlyOrNot<any[]>, AllowNull extends boolean, AllowUndefined extends boolean> = T extends [infer First, ...infer Rest] ? NeverType.IsNever<_FilterNull<AllowNull, First>> extends true ? FilterNullish<Rest, AllowNull, AllowUndefined> : NeverType.IsNever<_FilterUndefined<AllowUndefined, First>> extends true ? FilterNullish<Rest, AllowNull, AllowUndefined> : [First, ...FilterNullish<Rest, AllowNull, AllowUndefined>] : [];
/**

@@ -15,0 +19,0 @@ * Get length of tuple or string literal type.

{
"name": "@kakasoo/proto-typescript",
"version": "1.27.0",
"version": "1.27.1",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc