@eslint-react/eff
Advanced tools
Comparing version 1.24.2-next.0 to 1.24.2-next.1
@@ -1,20 +0,12 @@ | ||
declare function zipWith<T, U, V>(arrayA: readonly T[], arrayB: readonly U[], callback: (a: T, b: U, index: number) => V): V[]; | ||
/** | ||
* Creates a new array with `element` interspersed in between each element of `input` | ||
* if there is more than 1 value in `input`. Otherwise, returns the existing array. | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output dts. | ||
*/ | ||
declare function intersperse<T>(input: T[], element: T): T[]; | ||
declare function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V; | ||
declare function tryAddToSet<T>(set: Set<T>, value: T): boolean; | ||
declare function concatenate<T>(array1: T[], array2: T[]): T[]; | ||
declare function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[]; | ||
declare function concatenate<T>(array1: T[], array2: T[] | undefined): T[]; | ||
declare function concatenate<T>(array1: T[] | undefined, array2: T[]): T[]; | ||
declare function concatenate<T>(array1: readonly T[], array2: readonly T[] | undefined): readonly T[]; | ||
declare function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[]): readonly T[]; | ||
declare function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[] | undefined; | ||
declare function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined; | ||
type _ = undefined; | ||
/** | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output js. | ||
*/ | ||
declare const _: undefined; | ||
/** | ||
* Returns its argument. | ||
* @param x - The value to return. | ||
*/ | ||
@@ -210,25 +202,3 @@ declare function identity<T>(x: T): T; | ||
declare function flow<A extends ReadonlyArray<unknown>, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): (...a: A) => J; | ||
/** | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output dts. | ||
*/ | ||
type _ = undefined; | ||
/** | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output js. | ||
*/ | ||
declare const _: undefined; | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
/** | ||
* An extension of Extract for type predicates which falls back to the base | ||
* in order to narrow the `unknown` case. | ||
* | ||
* @example | ||
* function isMyType<T>(data: T | MyType): data is NarrowedTo<T, MyType> { ... } | ||
*/ | ||
type NarrowedTo<T, Base> = Extract<T, Base> extends never ? Base : 0 extends 1 & NoInfer<T> ? Base : Extract<T, Base>; | ||
/** | ||
* A function that takes a guard function as predicate and returns a guard that negates it. | ||
@@ -241,2 +211,9 @@ * | ||
declare function not<T>(predicate: (data: T) => boolean): (data: T) => boolean; | ||
/** | ||
* A function that takes two guard functions as predicates and returns a guard that checks if either of them is true. | ||
* | ||
* @param a - The first guard function. | ||
* @param b - The second guard function. | ||
* @returns Function A guard function. | ||
*/ | ||
declare function or<T, S extends T, U extends T>(a: (data: T) => data is S, b: (data: T) => data is U): (data: T) => data is S | U; | ||
@@ -267,3 +244,41 @@ declare function or<T, S extends T>(a: (data: T) => data is S, b: (data: T) => boolean): (data: T) => data is S; | ||
declare function isTruthy<T>(data: T): data is Exclude<T, "" | 0 | false | null | undefined>; | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
/** | ||
* An extension of Extract for type predicates which falls back to the base | ||
* in order to narrow the `unknown` case. | ||
* | ||
* @example | ||
* function isMyType<T>(data: T | MyType): data is NarrowedTo<T, MyType> { ... } | ||
*/ | ||
type NarrowedTo<T, Base> = Extract<T, Base> extends never ? Base : 0 extends 1 & NoInfer<T> ? Base : Extract<T, Base>; | ||
/** | ||
* Creates a new array from two supplied arrays by calling the supplied function | ||
* with the same-positioned element from each array. | ||
* @param arrayA - The first input array. | ||
* @param arrayB - The second input array. | ||
* @param callback - The function applied to each position of the arrays. | ||
* @returns A new array with the results of the function. | ||
*/ | ||
declare function zipWith<T, U, V>(arrayA: readonly T[], arrayB: readonly U[], callback: (a: T, b: U, index: number) => V): V[]; | ||
/** | ||
* Creates a new array with `element` interspersed in between each element of `input` | ||
* if there is more than 1 value in `input`. Otherwise, returns the existing array. | ||
* @param input - The input array. | ||
* @param element - The element to intersperse. | ||
* @returns A new array with the element interspersed. | ||
*/ | ||
declare function intersperse<T>(input: T[], element: T): T[]; | ||
declare function concatenate<T>(array1: T[], array2: T[]): T[]; | ||
declare function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[]; | ||
declare function concatenate<T>(array1: T[], array2: T[] | undefined): T[]; | ||
declare function concatenate<T>(array1: T[] | undefined, array2: T[]): T[]; | ||
declare function concatenate<T>(array1: readonly T[], array2: readonly T[] | undefined): readonly T[]; | ||
declare function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[]): readonly T[]; | ||
declare function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[] | undefined; | ||
declare function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined; | ||
declare function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V; | ||
declare function tryAddToSet<T>(set: Set<T>, value: T): boolean; | ||
export { type NarrowedTo, type Pretty, _, concatenate, dual, flip, flow, getOrUpdate, identity, intersperse, isArray, isObject, isTruthy, not, or, pipe, returnFalse, returnTrue, returnUndefined, returnVoid, tryAddToSet, zipWith }; |
'use strict'; | ||
// src/collection.ts | ||
function zipWith(arrayA, arrayB, callback) { | ||
const result = []; | ||
for (let i = 0; i < arrayA.length; i++) { | ||
result.push(callback(arrayA[i], arrayB[i], i)); | ||
} | ||
return result; | ||
} | ||
function intersperse(input, element) { | ||
if (input.length <= 1) { | ||
return input; | ||
} | ||
const result = []; | ||
for (let i = 0, n = input.length; i < n; i++) { | ||
if (i !== 0) result.push(element); | ||
result.push(input[i]); | ||
} | ||
return result; | ||
} | ||
function getOrUpdate(map, key, callback) { | ||
if (map.has(key)) { | ||
return map.get(key); | ||
} | ||
const value = callback(); | ||
map.set(key, value); | ||
return value; | ||
} | ||
function tryAddToSet(set, value) { | ||
if (!set.has(value)) { | ||
set.add(value); | ||
return true; | ||
} | ||
return false; | ||
} | ||
function concatenate(array1, array2) { | ||
if (array2 === undefined || array2.length === 0) return array1; | ||
if (array1 === undefined || array1.length === 0) return array2; | ||
return [...array1, ...array2]; | ||
} | ||
// src/function.ts | ||
// src/index.ts | ||
var _ = undefined; | ||
function identity(x) { | ||
@@ -188,7 +149,2 @@ return x; | ||
} | ||
// src/js.ts | ||
var _ = undefined; | ||
// src/predicate.ts | ||
function not(predicate) { | ||
@@ -209,2 +165,40 @@ return (data) => !predicate(data); | ||
} | ||
function zipWith(arrayA, arrayB, callback) { | ||
const result = []; | ||
for (let i = 0; i < arrayA.length; i++) { | ||
result.push(callback(arrayA[i], arrayB[i], i)); | ||
} | ||
return result; | ||
} | ||
function intersperse(input, element) { | ||
if (input.length <= 1) { | ||
return input; | ||
} | ||
const result = []; | ||
for (let i = 0, n = input.length; i < n; i++) { | ||
if (i !== 0) result.push(element); | ||
result.push(input[i]); | ||
} | ||
return result; | ||
} | ||
function concatenate(array1, array2) { | ||
if (array2 === undefined || array2.length === 0) return array1; | ||
if (array1 === undefined || array1.length === 0) return array2; | ||
return [...array1, ...array2]; | ||
} | ||
function getOrUpdate(map, key, callback) { | ||
if (map.has(key)) { | ||
return map.get(key); | ||
} | ||
const value = callback(); | ||
map.set(key, value); | ||
return value; | ||
} | ||
function tryAddToSet(set, value) { | ||
if (!set.has(value)) { | ||
set.add(value); | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -211,0 +205,0 @@ exports._ = _; |
{ | ||
"name": "@eslint-react/eff", | ||
"version": "1.24.2-next.0", | ||
"version": "1.24.2-next.1", | ||
"description": "JavaScript and TypeScript utilities (previously some re-exports of the effect library).", | ||
@@ -36,3 +36,3 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"devDependencies": { | ||
"tsup": "^8.3.5", | ||
"tsup": "^8.3.6", | ||
"@workspace/configs": "0.0.0" | ||
@@ -39,0 +39,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
48551
708