@eslint-react/tools
Advanced tools
Comparing version 1.5.1 to 1.5.2-beta.0
@@ -1,124 +0,108 @@ | ||
declare namespace Helper { | ||
/** | ||
* @param a | ||
* @since 0.0.1 | ||
*/ | ||
const id: <T>(a: T) => T; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
const noop: () => void; | ||
/** | ||
* @param a | ||
* @since 0.0.1 | ||
*/ | ||
const constant: <T>(a: T) => () => T; | ||
/** | ||
* @since 0.4.0 | ||
*/ | ||
type Cast<X, Y> = X extends Y ? X : Y; | ||
/** | ||
* Infers embedded primitive type of any type | ||
* @since 0.0.1 | ||
* @param T Type to infer | ||
* @returns Embedded type of {@link TType} | ||
* @example | ||
* type Result = Narrow<['foo', 'bar', 1]> | ||
* @see https://twitter.com/hd_nvim/status/1578567206190780417 | ||
*/ | ||
type Narrow<TType> = { | ||
[K in keyof TType]: Narrow<TType[K]>; | ||
} | (TType extends [] ? [] : never) | (TType extends Function ? TType : never) | (TType extends bigint | boolean | number | string ? TType : never); | ||
/** | ||
* Infers embedded primitive type of any type | ||
* Same as `as const` but without setting the object as readonly and without needing the user to use it. | ||
* @since 0.0.1 | ||
* @param a Value to infer | ||
* @returns Value with embedded type inferred | ||
* @example | ||
* const result = narrow(['foo', 'bar', 1]) | ||
*/ | ||
const narrow: <TType>(a: Narrow<TType>) => Narrow<TType>; | ||
/** | ||
* @param a The value to infer. | ||
* @since 0.0.1 | ||
*/ | ||
const asConst: <const T>(a: T) => T; | ||
/** | ||
* @since 0.0.1 | ||
* @template T The type to get the union from | ||
* @example | ||
* type Result = UnionFromTuple<['foo', 'bar', 1]> | ||
* // Result = 'foo' | 'bar' | 1 | ||
*/ | ||
type UnionFromTuple<T> = T extends (infer U)[] ? U : never; | ||
/** | ||
* @since 0.0.1 | ||
* @template T The type to get the intersection from | ||
* @example | ||
* type Result = IntersectionFromTuple<['foo', 'bar', 1]> | ||
* // Result = 'foo' & 'bar' & 1 | ||
*/ | ||
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
type Remap<T> = { | ||
[P in keyof T]: T[P]; | ||
}; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
/** | ||
* Returns the element type of an array. | ||
* @since 0.4.0 | ||
* @template T type of the array elements. | ||
* @param arr The array to get the element type from. | ||
* @returns The element type of the array. | ||
*/ | ||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never; | ||
/** | ||
* A record with loose keys. | ||
* @template T The type of the values. | ||
* @since 0.4.0 | ||
*/ | ||
type LooseRecord<T> = Record<PropertyKey, T>; | ||
type FromEntries<T> = T extends [infer Key, unknown][] ? { | ||
[K in Cast<Key, string>]: Extract<ArrayElement<T>, [K, unknown]>[1]; | ||
} : { | ||
[key in string]: unknown; | ||
}; | ||
/** | ||
* type-safe version of Object.fromEntries | ||
* @param entries The entries to create the object from. | ||
* @returns The object created from the entries. | ||
* @since 0.4.0 | ||
*/ | ||
const fromEntries: <T extends [PropertyKey, unknown][]>(entries: T) => FromEntries<T>; | ||
/** | ||
* type-safe version of Object.entries | ||
* @param value The value to get the entries from. | ||
* @returns The entries of the value. | ||
* @since 0.4.0 | ||
*/ | ||
const entries: <T extends LooseRecord<unknown>>(value: T) => { [K in keyof T]-?: [K, T[K]]; }[keyof T][]; | ||
/** | ||
* type-safe version of Object.keys | ||
* @param value The value to get the keys from. | ||
* @returns The keys of the value. | ||
* @since 0.4.0 | ||
*/ | ||
const keys: <T extends LooseRecord<unknown>>(value: T) => (keyof T)[]; | ||
/** | ||
* type-safe version of Object.values | ||
* @param value The value to get the values from. | ||
* @returns The values of the value. | ||
* @since 0.4.0 | ||
*/ | ||
const values: <T extends LooseRecord<unknown>>(value: T) => T[keyof T][]; | ||
} | ||
/** | ||
* @since 0.4.0 | ||
*/ | ||
type Cast<X, Y> = X extends Y ? X : Y; | ||
/** | ||
* Infers embedded primitive type of any type | ||
* @since 0.0.1 | ||
* @param T Type to infer | ||
* @returns Embedded type of {@link TType} | ||
* @example | ||
* type Result = Narrow<['foo', 'bar', 1]> | ||
* @see https://twitter.com/hd_nvim/status/1578567206190780417 | ||
*/ | ||
type Narrow<TType> = { | ||
[K in keyof TType]: Narrow<TType[K]>; | ||
} | (TType extends [] ? [] : never) | (TType extends Function ? TType : never) | (TType extends bigint | boolean | number | string ? TType : never); | ||
/** | ||
* Infers embedded primitive type of any type | ||
* Same as `as const` but without setting the object as readonly and without needing the user to use it. | ||
* @since 0.0.1 | ||
* @param a Value to infer | ||
* @returns Value with embedded type inferred | ||
* @example | ||
* const result = narrow(['foo', 'bar', 1]) | ||
*/ | ||
declare const narrow: <TType>(a: Narrow<TType>) => Narrow<TType>; | ||
/** | ||
* @param a The value to infer. | ||
* @since 0.0.1 | ||
*/ | ||
declare const asConst: <const T>(a: T) => T; | ||
/** | ||
* @since 0.0.1 | ||
* @template T The type to get the union from | ||
* @example | ||
* type Result = UnionFromTuple<['foo', 'bar', 1]> | ||
* // Result = 'foo' | 'bar' | 1 | ||
*/ | ||
type UnionFromTuple<T> = T extends (infer U)[] ? U : never; | ||
/** | ||
* @since 0.0.1 | ||
* @template T The type to get the intersection from | ||
* @example | ||
* type Result = IntersectionFromTuple<['foo', 'bar', 1]> | ||
* // Result = 'foo' & 'bar' & 1 | ||
*/ | ||
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
type Remap<T> = { | ||
[P in keyof T]: T[P]; | ||
}; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
type Pretty<T> = { | ||
[P in keyof T]: T[P]; | ||
} & {}; | ||
/** | ||
* Returns the element type of an array. | ||
* @since 0.4.0 | ||
* @template T type of the array elements. | ||
* @param arr The array to get the element type from. | ||
* @returns The element type of the array. | ||
*/ | ||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never; | ||
/** | ||
* A record with loose keys. | ||
* @template T The type of the values. | ||
* @since 0.4.0 | ||
*/ | ||
type LooseRecord<T> = Record<PropertyKey, T>; | ||
type FromEntries<T> = T extends [infer Key, unknown][] ? { | ||
[K in Cast<Key, string>]: Extract<ArrayElement<T>, [K, unknown]>[1]; | ||
} : { | ||
[key in string]: unknown; | ||
}; | ||
/** | ||
* type-safe version of Object.fromEntries | ||
* @param entries The entries to create the object from. | ||
* @returns The object created from the entries. | ||
* @since 0.4.0 | ||
*/ | ||
declare const fromEntries: <T extends [PropertyKey, unknown][]>(entries: T) => FromEntries<T>; | ||
/** | ||
* type-safe version of Object.entries | ||
* @param value The value to get the entries from. | ||
* @returns The entries of the value. | ||
* @since 0.4.0 | ||
*/ | ||
declare const entries: <T extends LooseRecord<unknown>>(value: T) => { [K in keyof T]-?: [K, T[K]]; }[keyof T][]; | ||
/** | ||
* type-safe version of Object.keys | ||
* @param value The value to get the keys from. | ||
* @returns The keys of the value. | ||
* @since 0.4.0 | ||
*/ | ||
declare const keys: <T extends LooseRecord<unknown>>(value: T) => (keyof T)[]; | ||
/** | ||
* type-safe version of Object.values | ||
* @param value The value to get the values from. | ||
* @returns The values of the value. | ||
* @since 0.4.0 | ||
*/ | ||
declare const values: <T extends LooseRecord<unknown>>(value: T) => T[keyof T][]; | ||
export { Helper }; | ||
export { type ArrayElement, type Cast, type FromEntries, type LooseRecord, type Narrow, type Pretty, type Remap, type UnionFromTuple, type UnionToIntersection, asConst, entries, fromEntries, keys, narrow, values }; |
'use strict'; | ||
exports.Helper = void 0; | ||
(function(Helper) { | ||
/** | ||
* @param a | ||
* @since 0.0.1 | ||
*/ Helper.id = (a)=>a; | ||
/** | ||
* @since 0.0.1 | ||
*/ // eslint-disable-next-line @typescript-eslint/no-empty-function | ||
Helper.noop = ()=>{}; | ||
/** | ||
* @param a | ||
* @since 0.0.1 | ||
*/ Helper.constant = (a)=>()=>a; | ||
/** | ||
* Infers embedded primitive type of any type | ||
* Same as `as const` but without setting the object as readonly and without needing the user to use it. | ||
* @since 0.0.1 | ||
* @param a Value to infer | ||
* @returns Value with embedded type inferred | ||
* @example | ||
* const result = narrow(['foo', 'bar', 1]) | ||
*/ Helper.narrow = (a)=>a; | ||
/** | ||
* @param a The value to infer. | ||
* @since 0.0.1 | ||
*/ Helper.asConst = (a)=>a; | ||
// fromEntries<T>(obj: T): FromEntriesWithReadOnly<T> | ||
/* eslint-disable @susisu/safe-typescript/no-type-assertion */ /** | ||
* type-safe version of Object.fromEntries | ||
* @param entries The entries to create the object from. | ||
* @returns The object created from the entries. | ||
* @since 0.4.0 | ||
*/ Helper.fromEntries = (entries)=>{ | ||
return Object.fromEntries(entries); | ||
}; | ||
/** | ||
* type-safe version of Object.entries | ||
* @param value The value to get the entries from. | ||
* @returns The entries of the value. | ||
* @since 0.4.0 | ||
*/ Helper.entries = (value)=>{ | ||
return Object.entries(value); | ||
}; | ||
/** | ||
* type-safe version of Object.keys | ||
* @param value The value to get the keys from. | ||
* @returns The keys of the value. | ||
* @since 0.4.0 | ||
*/ Helper.keys = (value)=>Object.keys(value); | ||
/** | ||
* type-safe version of Object.values | ||
* @param value The value to get the values from. | ||
* @returns The values of the value. | ||
* @since 0.4.0 | ||
*/ Helper.values = (value)=>Object.values(value); | ||
/* eslint-enable @susisu/safe-typescript/no-type-assertion */ })(exports.Helper || (exports.Helper = {})); | ||
/** | ||
* @since 0.4.0 | ||
*/ /** | ||
* Infers embedded primitive type of any type | ||
* Same as `as const` but without setting the object as readonly and without needing the user to use it. | ||
* @since 0.0.1 | ||
* @param a Value to infer | ||
* @returns Value with embedded type inferred | ||
* @example | ||
* const result = narrow(['foo', 'bar', 1]) | ||
*/ const narrow = (a)=>a; | ||
/** | ||
* @param a The value to infer. | ||
* @since 0.0.1 | ||
*/ const asConst = (a)=>a; | ||
// fromEntries<T>(obj: T): FromEntriesWithReadOnly<T> | ||
/* eslint-disable @susisu/safe-typescript/no-type-assertion */ /** | ||
* type-safe version of Object.fromEntries | ||
* @param entries The entries to create the object from. | ||
* @returns The object created from the entries. | ||
* @since 0.4.0 | ||
*/ const fromEntries = (entries)=>{ | ||
return Object.fromEntries(entries); | ||
}; | ||
/** | ||
* type-safe version of Object.entries | ||
* @param value The value to get the entries from. | ||
* @returns The entries of the value. | ||
* @since 0.4.0 | ||
*/ const entries = (value)=>{ | ||
return Object.entries(value); | ||
}; | ||
/** | ||
* type-safe version of Object.keys | ||
* @param value The value to get the keys from. | ||
* @returns The keys of the value. | ||
* @since 0.4.0 | ||
*/ const keys = (value)=>Object.keys(value); | ||
/** | ||
* type-safe version of Object.values | ||
* @param value The value to get the values from. | ||
* @returns The values of the value. | ||
* @since 0.4.0 | ||
*/ const values = (value)=>Object.values(value); /* eslint-enable @susisu/safe-typescript/no-type-assertion */ | ||
exports.asConst = asConst; | ||
exports.entries = entries; | ||
exports.fromEntries = fromEntries; | ||
exports.keys = keys; | ||
exports.narrow = narrow; | ||
exports.values = values; |
{ | ||
"name": "@eslint-react/tools", | ||
"version": "1.5.1", | ||
"version": "1.5.2-beta.0", | ||
"description": "ESLint React's std library and primitives.", | ||
@@ -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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
13867
254
1