@eslint-react/eff
Advanced tools
Comparing version 1.24.0-next.4 to 1.24.0-next.5
@@ -1,14 +0,1 @@ | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false; | ||
/** | ||
* 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 : IsAny<T> extends true ? Base : Extract<T, Base>; | ||
declare function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V; | ||
@@ -27,28 +14,20 @@ declare function tryAddToSet<T>(set: Set<T>, value: T): boolean; | ||
} | ||
type EntriesEntryForKey<T, Key extends keyof T> = Key extends number | string ? [key: `${Key}`, value: Required<T>[Key]] : never; | ||
type EntriesEntry<T> = Pretty<{ | ||
[P in keyof T]-?: EntriesEntryForKey<T, P>; | ||
}[keyof T]>; | ||
declare function entries<T extends {}>(data: T): Array<EntriesEntry<T>>; | ||
declare function entries(): <T extends {}>(data: T) => Array<EntriesEntry<T>>; | ||
type IterableContainer<T = unknown> = readonly [] | ReadonlyArray<T>; | ||
type FromEntriesEntry<Key extends PropertyKey = PropertyKey, Value = unknown> = readonly [ | ||
key: Key, | ||
value: Value | ||
]; | ||
type FromEntries<Entries> = Entries extends readonly [ | ||
infer First, | ||
...infer Tail | ||
] ? FromEntriesTuple<First, Tail> : Entries extends readonly [...infer Head, infer Last] ? FromEntriesTuple<Last, Head> : Entries extends IterableContainer<FromEntriesEntry> ? FromEntriesArray<Entries> : "ERROR: Entries array-like could not be inferred"; | ||
type FromEntriesTuple<E, Rest> = E extends FromEntriesEntry ? FromEntries<Rest> & Record<E[0], E[1]> : "ERROR: Array-like contains a non-entry element"; | ||
type FromEntriesArray<Entries extends IterableContainer<FromEntriesEntry>> = string extends AllKeys<Entries> ? Record<string, Entries[number][1]> : number extends AllKeys<Entries> ? Record<number, Entries[number][1]> : symbol extends AllKeys<Entries> ? Record<symbol, Entries[number][1]> : FromEntriesArrayWithLiteralKeys<Entries>; | ||
type FromEntriesArrayWithLiteralKeys<Entries extends IterableContainer<FromEntriesEntry>> = { | ||
[P in AllKeys<Entries>]?: ValueForKey<Entries, P>; | ||
}; | ||
type AllKeys<Entries extends IterableContainer<FromEntriesEntry>> = Extract<Entries[number], FromEntriesEntry>[0]; | ||
type ValueForKey<Entries extends IterableContainer<FromEntriesEntry>, K extends PropertyKey> = (Extract<Entries[number], FromEntriesEntry<K>> extends never ? Entries[number] : Extract<Entries[number], FromEntriesEntry<K>>)[1]; | ||
declare function fromEntries<Entries extends IterableContainer<FromEntriesEntry>>(entries: Entries): Pretty<FromEntries<Entries>>; | ||
declare function fromEntries(): <Entries extends IterableContainer<FromEntriesEntry>>(entries: Entries) => Pretty<FromEntries<Entries>>; | ||
/** | ||
* Returns its argument. | ||
*/ | ||
declare function identity<T>(x: T): T; | ||
/** | ||
* Do nothing and return false | ||
*/ | ||
declare function returnFalse(): false; | ||
/** | ||
* Do nothing and return true | ||
*/ | ||
declare function returnTrue(): true; | ||
/** | ||
* Do nothing and return undefined | ||
*/ | ||
declare function returnVoid(): undefined; | ||
/** | ||
* Creates a function that can be used in a data-last (aka `pipe`able) or | ||
@@ -226,27 +205,15 @@ * data-first style. | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
/** | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output dts. | ||
* 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 _ = undefined; | ||
type NarrowedTo<T, Base> = Extract<T, Base> extends never ? Base : 0 extends 1 & NoInfer<T> ? Base : Extract<T, Base>; | ||
/** | ||
* 1-byte version undefined, produces fewer bytes than `undefined` or `void 0` in the minified output js. | ||
*/ | ||
declare const _: undefined; | ||
/** | ||
* Do nothing and return false | ||
*/ | ||
declare function returnFalse(): false; | ||
/** | ||
* Do nothing and return true | ||
*/ | ||
declare function returnTrue(): true; | ||
/** | ||
* Do nothing and return undefined | ||
*/ | ||
declare function returnVoid(): undefined; | ||
/** | ||
* Returns its argument. | ||
*/ | ||
declare function identity<T>(x: T): T; | ||
/** | ||
* A function that takes a guard function as predicate and returns a guard that negates it. | ||
@@ -285,2 +252,11 @@ * | ||
export { BiRecord, type NarrowedTo, type Pretty, _, birecord, dual, entries, flip, flow, fromEntries, getOrUpdate, identity, isArray, isObject, isTruthy, not, or, pipe, returnFalse, returnTrue, returnVoid, tryAddToSet }; | ||
/** | ||
* 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 }; |
@@ -39,10 +39,16 @@ 'use strict'; | ||
}; | ||
function entries(...args) { | ||
return Object.entries(args); | ||
// src/function.ts | ||
function identity(x) { | ||
return x; | ||
} | ||
function fromEntries(...args) { | ||
return Object.fromEntries(args); | ||
function returnFalse() { | ||
return false; | ||
} | ||
// src/function.ts | ||
function returnTrue() { | ||
return true; | ||
} | ||
function returnVoid() { | ||
return undefined; | ||
} | ||
var dual = function(arity, body) { | ||
@@ -179,16 +185,3 @@ if (typeof arity === "function") { | ||
// src/lang.ts | ||
var _ = undefined; | ||
function returnFalse() { | ||
return false; | ||
} | ||
function returnTrue() { | ||
return true; | ||
} | ||
function returnVoid() { | ||
return undefined; | ||
} | ||
function identity(x) { | ||
return x; | ||
} | ||
// src/predicate.ts | ||
function not(predicate) { | ||
@@ -210,2 +203,5 @@ return (data) => !predicate(data); | ||
// src/index.ts | ||
var _ = undefined; | ||
exports.BiRecord = BiRecord; | ||
@@ -215,6 +211,4 @@ exports._ = _; | ||
exports.dual = dual; | ||
exports.entries = entries; | ||
exports.flip = flip; | ||
exports.flow = flow; | ||
exports.fromEntries = fromEntries; | ||
exports.getOrUpdate = getOrUpdate; | ||
@@ -221,0 +215,0 @@ exports.identity = identity; |
{ | ||
"name": "@eslint-react/eff", | ||
"version": "1.24.0-next.4", | ||
"version": "1.24.0-next.5", | ||
"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
45210
676