Comparing version 0.2.1 to 0.2.2
@@ -1,5 +0,5 @@ | ||
import type { Guardable } from "./functions.js"; | ||
import type { anyOrNever } from "./generics.js"; | ||
import type { isDisjoint } from "./intersections.js"; | ||
import type { parseNonNegativeInteger } from "./numericLiterals.js"; | ||
import type { Guardable } from "./functions.ts"; | ||
import type { anyOrNever } from "./generics.ts"; | ||
import type { isDisjoint } from "./intersections.ts"; | ||
import type { parseNonNegativeInteger } from "./numericLiterals.ts"; | ||
export type pathToString<segments extends string[], delimiter extends string = "/"> = segments extends [] ? "/" : join<segments, delimiter>; | ||
@@ -6,0 +6,0 @@ export declare const join: <segments extends array<string>, delimiter extends string>(segments: segments, delimiter: delimiter) => join<segments, delimiter>; |
@@ -47,6 +47,14 @@ export const join = (segments, delimiter) => segments.join(delimiter); | ||
} | ||
if (opts?.prepend) | ||
Array.isArray(value) ? to.unshift(...value) : to.unshift(value); | ||
else | ||
Array.isArray(value) ? to.push(...value) : to.push(value); | ||
if (opts?.prepend) { | ||
if (Array.isArray(value)) | ||
to.unshift(...value); | ||
else | ||
to.unshift(value); | ||
} | ||
else { | ||
if (Array.isArray(value)) | ||
to.push(...value); | ||
else | ||
to.push(value); | ||
} | ||
return to; | ||
@@ -53,0 +61,0 @@ }; |
@@ -1,6 +0,6 @@ | ||
import type { array } from "./arrays.js"; | ||
import type { describeDomainOf, domainOf, inferDomain } from "./domain.js"; | ||
import type { anyOrNever, satisfy, Stringifiable } from "./generics.js"; | ||
import type { describeObject } from "./objectKinds.js"; | ||
import type { stringifyUnion } from "./unionToTuple.js"; | ||
import type { array } from "./arrays.ts"; | ||
import type { describeDomainOf, domainOf, inferDomain } from "./domain.ts"; | ||
import type { anyOrNever, satisfy, Stringifiable } from "./generics.ts"; | ||
import type { describeObject } from "./objectKinds.ts"; | ||
import type { stringifyUnion } from "./unionToTuple.ts"; | ||
export type DescribeOptions = { | ||
@@ -7,0 +7,0 @@ includeArticles?: boolean; |
@@ -1,4 +0,4 @@ | ||
import type { describeDefaults, DescribeOptions } from "./describe.js"; | ||
import type { show } from "./generics.js"; | ||
import type { stringifyUnion } from "./unionToTuple.js"; | ||
import type { describeDefaults, DescribeOptions } from "./describe.ts"; | ||
import type { show } from "./generics.ts"; | ||
import type { stringifyUnion } from "./unionToTuple.ts"; | ||
export declare const hasDomain: <data, domain extends Domain>(data: data, kind: domain) => data is data & inferDomain<domain>; | ||
@@ -5,0 +5,0 @@ type TypesByDomain = { |
@@ -1,2 +0,2 @@ | ||
import type { keyNonimal } from "./generics.js"; | ||
import type { keyNonimal } from "./generics.ts"; | ||
export declare class InternalArktypeError extends Error { | ||
@@ -3,0 +3,0 @@ } |
@@ -1,5 +0,5 @@ | ||
import type { array, listable } from "./arrays.js"; | ||
import type { show } from "./generics.js"; | ||
import type { Entry, Key, entryOf, fromEntries } from "./records.js"; | ||
import type { intersectUnion } from "./unionToTuple.js"; | ||
import type { array, listable } from "./arrays.ts"; | ||
import type { show } from "./generics.ts"; | ||
import type { Entry, Key, entryOf, fromEntries } from "./records.ts"; | ||
import type { intersectUnion } from "./unionToTuple.ts"; | ||
type objectFromListableEntries<transformed extends readonly Entry[]> = show<intersectUnion<fromEntries<transformed>>>; | ||
@@ -27,5 +27,8 @@ type arrayFromListableEntries<transformed extends Entry> = Entry<number, never> extends transformed ? transformed[1][] : _arrayFromListableEntries<transformed, []>; | ||
] extends [listable<Entry<number>>] ? arrayFromListableEntries<extractEntries<transformed>> : objectFromListableEntries<extractEntrySets<transformed>>; | ||
export declare function flatMorph<const o extends array, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: numericArrayEntry<o>) => transformed): fromMappedEntries<transformed>; | ||
export declare function flatMorph<const o extends object, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: entryOf<o>) => transformed): fromMappedEntries<transformed>; | ||
export declare function flatMorph<const o extends object, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: entryArgsWithIndex<o>) => transformed): fromMappedEntries<transformed>; | ||
export type FlatMorph = { | ||
<const o extends array, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: numericArrayEntry<o>) => transformed): fromMappedEntries<transformed>; | ||
<const o extends object, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: entryOf<o>) => transformed): fromMappedEntries<transformed>; | ||
<const o extends object, transformed extends MappedEntry>(o: o, flatMapEntry: (...args: entryArgsWithIndex<o>) => transformed): fromMappedEntries<transformed>; | ||
}; | ||
export declare const flatMorph: FlatMorph; | ||
export {}; |
@@ -1,3 +0,2 @@ | ||
// eslint-disable-next-line prefer-arrow-functions/prefer-arrow-functions | ||
export function flatMorph(o, flatMapEntry) { | ||
export const flatMorph = (o, flatMapEntry) => { | ||
const inputIsArray = Array.isArray(o); | ||
@@ -19,2 +18,2 @@ const entries = Object.entries(o).flatMap((entry, i) => { | ||
: objectResult; | ||
} | ||
}; |
@@ -1,5 +0,3 @@ | ||
import { NoopBase } from "./records.js"; | ||
export declare const bound: (target: Function, ctx: ClassMemberDecoratorContext) => void; | ||
export declare const cached: <self>(target: (this: self) => any, context: ClassGetterDecoratorContext<self, any> | ClassMethodDecoratorContext<self, (this: self) => any>) => (this: self) => any; | ||
export declare const cachedThunk: <t>(thunk: () => t) => (() => t); | ||
export type Fn<in args extends readonly never[] = readonly never[], out returns = unknown> = (...args: args) => returns; | ||
export declare const cached: <t>(thunk: () => t) => (() => t); | ||
export declare const isThunk: <value>(value: value) => value is Extract<value, Thunk> extends never ? value & Thunk : Extract<value, Thunk>; | ||
@@ -10,5 +8,5 @@ export type Thunk<ret = unknown> = () => ret; | ||
export declare const DynamicFunction: DynamicFunction; | ||
export type DynamicFunction = new <f extends (...args: never[]) => unknown>(...args: ConstructorParameters<typeof Function>) => f & { | ||
apply(thisArg: null, args: Parameters<f>): ReturnType<f>; | ||
call(thisArg: null, ...args: Parameters<f>): ReturnType<f>; | ||
export type DynamicFunction = new <fn extends Fn>(...args: ConstructorParameters<typeof Function>) => fn & { | ||
apply(thisArg: null, args: Parameters<fn>): ReturnType<fn>; | ||
call(thisArg: null, ...args: Parameters<fn>): ReturnType<fn>; | ||
}; | ||
@@ -20,5 +18,7 @@ export type CallableOptions<attachments extends object> = { | ||
/** @ts-ignore required to cast function type */ | ||
export declare class Callable<f extends (...args: never[]) => unknown, attachments extends object = {}> extends NoopBase<f & attachments> { | ||
constructor(f: f, ...[opts]: {} extends attachments ? [opts?: CallableOptions<attachments>] : [opts: CallableOptions<attachments>]); | ||
export interface Callable<fn extends Fn, attachments extends object> extends fn, attachments { | ||
} | ||
export declare class Callable<fn extends Fn, attachments extends object = {}> { | ||
constructor(fn: fn, ...[opts]: {} extends attachments ? [opts?: CallableOptions<attachments>] : [opts: CallableOptions<attachments>]); | ||
} | ||
export type Guardable<input = unknown, narrowed extends input = input> = ((In: input) => In is narrowed) | ((In: input) => boolean); | ||
@@ -25,0 +25,0 @@ export type TypeGuard<input = unknown, narrowed extends input = input> = (In: input) => In is narrowed; |
import { throwInternalError } from "./errors.js"; | ||
import { NoopBase, unset } from "./records.js"; | ||
export const bound = (target, ctx) => { | ||
ctx.addInitializer(function () { | ||
this[ctx.name] = this[ctx.name].bind(this); | ||
}); | ||
}; | ||
export const cached = (target, context) => function () { | ||
const value = target.call(this); | ||
Object.defineProperty(this, context.name, context.kind === "getter" ? | ||
{ value } | ||
: { | ||
value: () => value, | ||
enumerable: false | ||
}); | ||
return value; | ||
}; | ||
export const cachedThunk = (thunk) => { | ||
import { unset } from "./records.js"; | ||
export const cached = (thunk) => { | ||
let result = unset; | ||
@@ -47,7 +32,6 @@ return () => (result === unset ? (result = thunk()) : result); | ||
}; | ||
/** @ts-ignore required to cast function type */ | ||
export class Callable extends NoopBase { | ||
constructor(f, ...[opts]) { | ||
super(); | ||
return Object.assign(Object.setPrototypeOf(f.bind(opts?.bind ?? this), this.constructor.prototype), opts?.attach); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
export class Callable { | ||
constructor(fn, ...[opts]) { | ||
return Object.assign(Object.setPrototypeOf(fn.bind(opts?.bind ?? this), this.constructor.prototype), opts?.attach); | ||
} | ||
@@ -64,9 +48,9 @@ } | ||
*/ | ||
export const envHasCsp = cachedThunk(() => { | ||
export const envHasCsp = cached(() => { | ||
try { | ||
return new Function("return false")(); | ||
} | ||
catch (e) { | ||
catch { | ||
return true; | ||
} | ||
}); |
@@ -1,4 +0,4 @@ | ||
import type { Primitive } from "./domain.js"; | ||
import type { ErrorMessage } from "./errors.js"; | ||
import type { unionToTuple } from "./unionToTuple.js"; | ||
import type { Primitive } from "./domain.ts"; | ||
import { type ErrorMessage } from "./errors.ts"; | ||
import type { unionToTuple } from "./unionToTuple.ts"; | ||
export type Stringifiable = string | boolean | number | bigint | null | undefined; | ||
@@ -56,2 +56,6 @@ /** Force an operation like `{ a: 0 } & { b: 1 }` to be computed so that it displays `{ a: 0; b: 1 }`. */ | ||
export declare const narrow: <t>(t: narrow<t>) => t; | ||
/** primitive key used to represent an inferred type at compile-time */ | ||
export declare const inferred: " arkInferred"; | ||
/** primitive key used to represent an inferred type at compile-time */ | ||
export type inferred = typeof inferred; | ||
export {}; |
@@ -0,1 +1,2 @@ | ||
import { noSuggest } from "./errors.js"; | ||
/** You can avoid suggesting completions by prefixing a string key with whitespace. | ||
@@ -6,1 +7,3 @@ * Isn't that keyNominal? | ||
export const narrow = (t) => t; | ||
/** primitive key used to represent an inferred type at compile-time */ | ||
export const inferred = noSuggest("arkInferred"); |
@@ -1,3 +0,3 @@ | ||
import type { conform } from "./generics.js"; | ||
import type { keyOf } from "./records.js"; | ||
import type { conform } from "./generics.ts"; | ||
import type { keyOf } from "./records.ts"; | ||
type getKey<o, k> = k extends keyof o ? o[k] : k extends `${infer n extends number & keyof o}` ? o[n] : never; | ||
@@ -4,0 +4,0 @@ type getPath<o, path extends string> = path extends `${infer head}.${infer tail}` ? getPath<getKey<o, head>, tail> : getKey<o, path>; |
@@ -1,20 +0,20 @@ | ||
export * from "./arrays.js"; | ||
export * from "./clone.js"; | ||
export * from "./describe.js"; | ||
export * from "./domain.js"; | ||
export * from "./errors.js"; | ||
export * from "./flatMorph.js"; | ||
export * from "./functions.js"; | ||
export * from "./generics.js"; | ||
export * from "./hkt.js"; | ||
export * from "./intersections.js"; | ||
export * from "./lazily.js"; | ||
export * from "./numericLiterals.js"; | ||
export * from "./objectKinds.js"; | ||
export * from "./primitive.js"; | ||
export * from "./records.js"; | ||
export * from "./registry.js"; | ||
export * from "./serialize.js"; | ||
export * from "./strings.js"; | ||
export * from "./traits.js"; | ||
export * from "./unionToTuple.js"; | ||
export * from "./arrays.ts"; | ||
export * from "./clone.ts"; | ||
export * from "./describe.ts"; | ||
export * from "./domain.ts"; | ||
export * from "./errors.ts"; | ||
export * from "./flatMorph.ts"; | ||
export * from "./functions.ts"; | ||
export * from "./generics.ts"; | ||
export * from "./hkt.ts"; | ||
export * from "./intersections.ts"; | ||
export * from "./lazily.ts"; | ||
export * from "./numericLiterals.ts"; | ||
export * from "./objectKinds.ts"; | ||
export * from "./primitive.ts"; | ||
export * from "./records.ts"; | ||
export * from "./registry.ts"; | ||
export * from "./serialize.ts"; | ||
export * from "./strings.ts"; | ||
export * from "./traits.ts"; | ||
export * from "./unionToTuple.ts"; |
@@ -1,6 +0,6 @@ | ||
import type { array } from "./arrays.js"; | ||
import type { domainOf } from "./domain.js"; | ||
import type { andPreserveUnknown } from "./generics.js"; | ||
import type { Hkt } from "./hkt.js"; | ||
import type { propValueOf, requiredKeyOf } from "./records.js"; | ||
import type { array } from "./arrays.ts"; | ||
import type { domainOf } from "./domain.ts"; | ||
import type { andPreserveUnknown } from "./generics.ts"; | ||
import type { Hkt } from "./hkt.ts"; | ||
import type { propValueOf, requiredKeyOf } from "./records.ts"; | ||
export interface AndPreserveUnknown extends Hkt<[unknown, unknown]> { | ||
@@ -43,5 +43,6 @@ body: andPreserveUnknown<this[0], this[1]>; | ||
], operation, kind> : [...acc, ...Hkt.apply<operation, [lHead, rHead]>[], ...postfix] : never; | ||
export type isDisjoint<l, r> = l & r extends never ? true : domainOf<l> & domainOf<r> extends never ? true : [l, r] extends [object, object] ? true extends (propValueOf<{ | ||
[k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: isDisjoint<l[k], r[k]>; | ||
}>) ? true : false : false; | ||
export type isDisjoint<l, r> = overlaps<l, r> extends true ? false : true; | ||
export type overlaps<l, r> = l & r extends never ? false : domainOf<l> & domainOf<r> extends never ? false : [l, r] extends [object, object] ? false extends (propValueOf<{ | ||
[k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: overlaps<l[k], r[k]>; | ||
}>) ? false : true : true; | ||
export {}; |
@@ -1,5 +0,6 @@ | ||
import type { array } from "./arrays.js"; | ||
import type { DescribeOptions } from "./describe.js"; | ||
import { type Domain, type domainDescriptions, domainOf } from "./domain.js"; | ||
import { type Key } from "./records.js"; | ||
import type { array } from "./arrays.ts"; | ||
import type { DescribeOptions } from "./describe.ts"; | ||
import { type Domain, type domainDescriptions, domainOf } from "./domain.ts"; | ||
import type { Fn } from "./functions.ts"; | ||
import { type Key } from "./records.ts"; | ||
export type builtinConstructors = { | ||
@@ -26,3 +27,3 @@ Array: ArrayConstructor; | ||
}; | ||
export type objectKindOf<data extends object> = object extends data ? keyof builtinConstructors | undefined : data extends (...args: never[]) => unknown ? "Function" : instantiableObjectKind<data> extends never ? keyof builtinConstructors | undefined : instantiableObjectKind<data>; | ||
export type objectKindOf<data extends object> = object extends data ? keyof builtinConstructors | undefined : data extends Fn ? "Function" : instantiableObjectKind<data> extends never ? keyof builtinConstructors | undefined : instantiableObjectKind<data>; | ||
export type describeObject<o extends object, opts extends DescribeOptions = {}> = objectKindOf<o> extends string ? [ | ||
@@ -29,0 +30,0 @@ opts["includeArticles"] |
@@ -1,3 +0,3 @@ | ||
import type { inferDomain } from "./domain.js"; | ||
import type { BigintLiteral } from "./numericLiterals.js"; | ||
import type { inferDomain } from "./domain.ts"; | ||
import type { BigintLiteral } from "./numericLiterals.ts"; | ||
type SerializedString<value extends string = string> = `"${value}"`; | ||
@@ -4,0 +4,0 @@ export type SerializedPrimitives = { |
@@ -1,3 +0,4 @@ | ||
import type { array } from "./arrays.js"; | ||
import type { defined, show } from "./generics.js"; | ||
import type { array } from "./arrays.ts"; | ||
import type { Fn } from "./functions.ts"; | ||
import type { defined, show } from "./generics.ts"; | ||
export type Dict<k extends string = string, v = unknown> = { | ||
@@ -23,3 +24,3 @@ readonly [_ in k]: v; | ||
export type require<o, maxDepth extends number = 1> = _require<o, [], maxDepth>; | ||
type _require<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends (...args: never[]) => unknown ? o : { | ||
type _require<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends Fn ? o : { | ||
[k in keyof o]-?: _require<o[k], [...depth, 1], maxDepth>; | ||
@@ -35,3 +36,3 @@ } : o; | ||
export type mutable<o, maxDepth extends number = 1> = _mutable<o, [], maxDepth>; | ||
type _mutable<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends (...args: never[]) => unknown ? o : { | ||
type _mutable<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends Fn ? o : { | ||
-readonly [k in keyof o]: _mutable<o[k], [...depth, 1], maxDepth>; | ||
@@ -85,7 +86,10 @@ } : o; | ||
export declare const InnerDynamicBase: new <t extends object>(base: t) => t; | ||
/** @ts-ignore (needed to extend `t`, but safe given ShallowClone's implementation) **/ | ||
export declare class DynamicBase<t extends object> extends InnerDynamicBase<t> { | ||
/** @ts-ignore (needed to extend `t`) **/ | ||
export interface DynamicBase<t extends object> extends t { | ||
} | ||
export declare class DynamicBase<t extends object> { | ||
constructor(properties: object); | ||
} | ||
export declare const NoopBase: new <t extends object>() => t; | ||
/** @ts-ignore (see DynamicBase) **/ | ||
/** @ts-ignore (needed to extend `t`) **/ | ||
export declare class CastableBase<t extends object> extends NoopBase<t> { | ||
@@ -92,0 +96,0 @@ } |
@@ -10,12 +10,12 @@ import { flatMorph } from "./flatMorph.js"; | ||
export const InnerDynamicBase = class { | ||
}; | ||
// eslint-disable-next-line | ||
export class DynamicBase { | ||
constructor(properties) { | ||
Object.assign(this, properties); | ||
} | ||
}; | ||
/** @ts-ignore (needed to extend `t`, but safe given ShallowClone's implementation) **/ | ||
export class DynamicBase extends InnerDynamicBase { | ||
} | ||
export const NoopBase = class { | ||
}; | ||
/** @ts-ignore (see DynamicBase) **/ | ||
/** @ts-ignore (needed to extend `t`) **/ | ||
export class CastableBase extends NoopBase { | ||
@@ -22,0 +22,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare const arkUtilVersion = "0.2.1"; | ||
export declare const arkUtilVersion = "0.2.2"; | ||
export declare const initialRegistryContents: { | ||
@@ -3,0 +3,0 @@ version: string; |
@@ -8,3 +8,3 @@ import { domainOf } from "./domain.js"; | ||
// For now, we assert this matches the package.json version via a unit test. | ||
export const arkUtilVersion = "0.2.1"; | ||
export const arkUtilVersion = "0.2.2"; | ||
export const initialRegistryContents = { | ||
@@ -11,0 +11,0 @@ version: arkUtilVersion, |
@@ -1,3 +0,3 @@ | ||
import type { array } from "./arrays.js"; | ||
import { type Primitive } from "./domain.js"; | ||
import type { array } from "./arrays.ts"; | ||
import { type Primitive } from "./domain.ts"; | ||
export type SerializationOptions = { | ||
@@ -9,5 +9,7 @@ onCycle?: (value: object) => string; | ||
}; | ||
export type Json = { | ||
[k: string | number]: JsonData; | ||
} | JsonData[]; | ||
export type Json = JsonObject | JsonArray; | ||
export type JsonObject = { | ||
[k: string]: JsonData; | ||
}; | ||
export type JsonArray = JsonData[]; | ||
export type JsonPrimitive = string | boolean | number | null; | ||
@@ -22,2 +24,9 @@ export type JsonData = Json | JsonPrimitive; | ||
export declare const printable: (data: unknown, indent?: number) => string; | ||
/** | ||
* Converts a Date instance to a human-readable description relative to its precision | ||
* | ||
* @param {Date} date | ||
* @returns {string} - The generated description | ||
*/ | ||
export declare const describeCollapsibleDate: (date: Date) => string; | ||
export {}; |
@@ -13,3 +13,3 @@ import { domainOf } from "./domain.js"; | ||
JSON.stringify(_serialize(o, printableOpts, []), null, indent) | ||
: o instanceof Date ? o.toDateString() | ||
: o instanceof Date ? describeCollapsibleDate(o) | ||
: typeof o.expression === "string" ? o.expression | ||
@@ -55,1 +55,53 @@ : ctorName); | ||
}; | ||
/** | ||
* Converts a Date instance to a human-readable description relative to its precision | ||
* | ||
* @param {Date} date | ||
* @returns {string} - The generated description | ||
*/ | ||
export const describeCollapsibleDate = (date) => { | ||
const year = date.getFullYear(); | ||
const month = date.getMonth(); | ||
const dayOfMonth = date.getDate(); | ||
const hours = date.getHours(); | ||
const minutes = date.getMinutes(); | ||
const seconds = date.getSeconds(); | ||
const milliseconds = date.getMilliseconds(); | ||
if (month === 0 && | ||
dayOfMonth === 1 && | ||
hours === 0 && | ||
minutes === 0 && | ||
seconds === 0 && | ||
milliseconds === 0) | ||
return `${year}`; | ||
const datePortion = `${months[month]} ${dayOfMonth}, ${year}`; | ||
if (hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0) | ||
return datePortion; | ||
let timePortion = date.toLocaleTimeString(); | ||
const suffix = timePortion.endsWith(" AM") || timePortion.endsWith(" PM") ? | ||
timePortion.slice(-3) | ||
: ""; | ||
if (suffix) | ||
timePortion = timePortion.slice(0, -suffix.length); | ||
if (milliseconds) | ||
timePortion += `.${pad(milliseconds, 3)}`; | ||
else if (timeWithUnnecessarySeconds.test(timePortion)) | ||
timePortion = timePortion.slice(0, -3); | ||
return `${timePortion + suffix}, ${datePortion}`; | ||
}; | ||
const months = [ | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December" | ||
]; | ||
const timeWithUnnecessarySeconds = /:\d\d:00$/; | ||
const pad = (value, length) => String(value).padStart(length, "0"); |
@@ -1,6 +0,6 @@ | ||
import type { array } from "./arrays.js"; | ||
import type { conform, satisfy, show } from "./generics.js"; | ||
import type { intersectParameters } from "./intersections.js"; | ||
import { type Constructor } from "./objectKinds.js"; | ||
import { NoopBase } from "./records.js"; | ||
import type { array } from "./arrays.ts"; | ||
import type { conform, satisfy, show } from "./generics.ts"; | ||
import type { intersectParameters } from "./intersections.ts"; | ||
import { type Constructor } from "./objectKinds.ts"; | ||
import { NoopBase } from "./records.ts"; | ||
export type TraitImplementation = <traits extends TraitConstructor[], implementation extends implementationOf<s>, s extends CompositionState = composeTraits<[ | ||
@@ -7,0 +7,0 @@ ...traits, |
@@ -1,3 +0,4 @@ | ||
import type { array, join } from "./arrays.js"; | ||
import type { conform } from "./generics.js"; | ||
import type { array, join } from "./arrays.ts"; | ||
import type { Fn } from "./functions.ts"; | ||
import type { conform } from "./generics.ts"; | ||
export type stringifyUnion<t extends string, delimiter extends string = ", "> = join<unionToTuple<t>, delimiter>; | ||
@@ -10,5 +11,5 @@ export type unionToTuple<t> = _unionToTuple<t, []> extends infer result ? conform<result, t[]> : never; | ||
export type intersectUnion<t> = (t extends unknown ? (_: t) => void : never) extends ((_: infer intersection) => void) ? intersection : never; | ||
export type intersectOverloadReturns<f extends (...args: never[]) => unknown> = intersectUnion<ReturnType<overloadOf<f>>>; | ||
export type overloadOf<f extends (...args: never[]) => unknown, givenArgs extends array = array> = Exclude<collectSignatures<(() => never) & f, givenArgs, unknown>, f extends () => never ? never : () => never>; | ||
type collectSignatures<f, givenArgs extends array, result> = result & f extends (...args: infer args) => infer returns ? result extends f ? never : collectSignatures<f, givenArgs, Pick<f, keyof f> & result & ((...args: args) => returns)> | (args extends givenArgs ? (...args: args) => returns : never) : never; | ||
export type intersectOverloadReturns<fn extends Fn> = intersectUnion<ReturnType<overloadOf<fn>>>; | ||
export type overloadOf<fn extends Fn, givenArgs extends array = array> = Exclude<collectSignatures<(() => never) & fn, givenArgs, unknown>, fn extends () => never ? never : () => never>; | ||
type collectSignatures<fn, givenArgs extends array, result> = result & fn extends (...args: infer args) => infer returns ? result extends fn ? never : collectSignatures<fn, givenArgs, Pick<fn, keyof fn> & result & ((...args: args) => returns)> | (args extends givenArgs ? (...args: args) => returns : never) : never; | ||
export {}; |
{ | ||
"name": "@ark/util", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": { | ||
@@ -13,4 +13,10 @@ "name": "David Blass", | ||
"exports": { | ||
".": "./out/index.js", | ||
"./internal/*": "./out/*", | ||
".": { | ||
"ark-ts": "./index.ts", | ||
"default": "./out/index.js" | ||
}, | ||
"./internal/*": { | ||
"ark-ts": "./*", | ||
"default": "./out/*" | ||
}, | ||
"./tsconfig.base.json": "./tsconfig.base.json" | ||
@@ -26,5 +32,5 @@ }, | ||
"scripts": { | ||
"build": "tsx ../repo/build.ts", | ||
"test": "tsx ../repo/testPackage.ts" | ||
"build": "ts ../repo/build.ts", | ||
"test": "ts ../repo/testPackage.ts" | ||
} | ||
} |
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
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
81611
1698