@eslint-react/eff
Advanced tools
Comparing version 1.24.0-next.5 to 1.24.0-next.6
@@ -0,14 +1,17 @@ | ||
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. | ||
*/ | ||
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; | ||
type Reverse<T extends Record<any, any>> = { | ||
[U in keyof T as T[U]]: U; | ||
}; | ||
declare function birecord<const T extends Record<any, any>>(original: T): BiRecord<T>; | ||
declare class BiRecord<const T extends Record<any, any>> { | ||
original: T; | ||
reversed: Reverse<T>; | ||
constructor(original: T, reversed?: Reverse<T>); | ||
get<U extends keyof T | T[keyof T]>(key: U): U extends keyof T ? T[U] : U extends T[keyof T] ? Reverse<T>[U] : unknown; | ||
has(key: any): key is keyof T | T[keyof 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; | ||
@@ -20,5 +23,5 @@ /** | ||
/** | ||
* Do nothing and return false | ||
* Do nothing and return void | ||
*/ | ||
declare function returnFalse(): false; | ||
declare function returnVoid(): void; | ||
/** | ||
@@ -29,5 +32,9 @@ * Do nothing and return true | ||
/** | ||
* Do nothing and return false | ||
*/ | ||
declare function returnFalse(): false; | ||
/** | ||
* Do nothing and return undefined | ||
*/ | ||
declare function returnVoid(): undefined; | ||
declare function returnUndefined(): undefined; | ||
/** | ||
@@ -206,2 +213,11 @@ * Creates a function that can be used in a data-last (aka `pipe`able) or | ||
/** | ||
* 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> = { | ||
@@ -253,11 +269,2 @@ [P in keyof T]: T[P]; | ||
/** | ||
* 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; | ||
export { BiRecord, type NarrowedTo, type Pretty, _, birecord, dual, flip, flow, getOrUpdate, identity, isArray, isObject, isTruthy, not, or, pipe, returnFalse, returnTrue, returnVoid, tryAddToSet }; | ||
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) { | ||
@@ -19,22 +37,7 @@ if (map.has(key)) { | ||
} | ||
function reverse(record) { | ||
return Object.fromEntries( | ||
Object.entries(record).map(([key, value]) => [value, key]) | ||
); | ||
function concatenate(array1, array2) { | ||
if (array2 === undefined || array2.length === 0) return array1; | ||
if (array1 === undefined || array1.length === 0) return array2; | ||
return [...array1, ...array2]; | ||
} | ||
function birecord(original) { | ||
return new BiRecord(original); | ||
} | ||
var BiRecord = class { | ||
constructor(original, reversed = reverse(original)) { | ||
this.original = original; | ||
this.reversed = reversed; | ||
} | ||
get(key) { | ||
return this.original[key] ?? this.reversed[key]; | ||
} | ||
has(key) { | ||
return key in this.original || key in this.reversed; | ||
} | ||
}; | ||
@@ -45,4 +48,3 @@ // src/function.ts | ||
} | ||
function returnFalse() { | ||
return false; | ||
function returnVoid() { | ||
} | ||
@@ -52,3 +54,6 @@ function returnTrue() { | ||
} | ||
function returnVoid() { | ||
function returnFalse() { | ||
return false; | ||
} | ||
function returnUndefined() { | ||
return undefined; | ||
@@ -187,2 +192,5 @@ } | ||
// src/js.ts | ||
var _ = undefined; | ||
// src/predicate.ts | ||
@@ -205,8 +213,4 @@ function not(predicate) { | ||
// src/index.ts | ||
var _ = undefined; | ||
exports.BiRecord = BiRecord; | ||
exports._ = _; | ||
exports.birecord = birecord; | ||
exports.concatenate = concatenate; | ||
exports.dual = dual; | ||
@@ -217,2 +221,3 @@ exports.flip = flip; | ||
exports.identity = identity; | ||
exports.intersperse = intersperse; | ||
exports.isArray = isArray; | ||
@@ -226,3 +231,5 @@ exports.isObject = isObject; | ||
exports.returnTrue = returnTrue; | ||
exports.returnUndefined = returnUndefined; | ||
exports.returnVoid = returnVoid; | ||
exports.tryAddToSet = tryAddToSet; | ||
exports.zipWith = zipWith; |
{ | ||
"name": "@eslint-react/eff", | ||
"version": "1.24.0-next.5", | ||
"version": "1.24.0-next.6", | ||
"description": "JavaScript and TypeScript utilities (previously some re-exports of the effect library).", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Rel1cx/eslint-react", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47146
695