packages/ui-components/tooltip

Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
Gabriel committed 2023-04-12 11:00:36 +02:00
1 parent 67fa57c15c
commit 6404993432
434 files changed
+45562 -38

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
export * from "./src/abort-controller";
export * from "./src/array";
export * from "./src/backoff-caller";
export * from "./src/base64";
export * from "./src/buildUrl";
export * from "./src/camelCase";
export * from "./src/collection-functions";
export * from "./src/computed-or";
export * from "./src/convertCpu";
export * from "./src/convertMemory";
export * from "./src/cssNames";
export * from "./src/cssVar";
export * from "./src/debouncePromise";
export * from "./src/delay";
export * from "./src/display-mode";
export * from "./src/disposer";
export * from "./src/formatDuration";
export * from "./src/hash-set";
export * from "./src/interval";
export * from "./src/is-node-falsy";
export * from "./src/isMiddleClick";
export * from "./src/isReactNode";
export * from "./src/iter";
export * from "./src/json";
export * from "./src/jsonPath";
export * from "./src/metricUnitsToNumber";
export * from "./src/name-parts";
export * from "./src/noop";
export * from "./src/object";
export * from "./src/observable-crate";
export * from "./src/on-keyboard-shortcut";
export * from "./src/prevDefault";
export * from "./src/readableStream";
export * from "./src/readonly";
export * from "./src/reject-promise";
export * from "./src/result";
export * from "./src/sort-compare";
export * from "./src/sort-function";
export * from "./src/tar";
export * from "./src/tuple";
export * from "./src/type-narrowing";
export * from "./src/types";
export * from "./src/union-env-path";
export * from "./src/wait";
export * from "./src/with-concurrency-limit";
+1
View File
@@ -0,0 +1 @@
(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{HashSet:()=>Ue,ObservableHashSet:()=>De,Ordering:()=>Tt,ReadableWebToNodeStream:()=>Et,WrappedAbortController:()=>r,array:()=>i,backoffCaller:()=>u,base64:()=>f,bindPredicate:()=>M,buildURL:()=>B,buildURLPositional:()=>I,byValue:()=>Rt,bytesToUnits:()=>Me,chainSignal:()=>o,computedOr:()=>ie,convertKubectlJsonPathToNodeJsonPath:()=>ct,cpuUnitsToNumber:()=>ce,cssNames:()=>xe,cssVar:()=>$e,debouncePromise:()=>Re,delay:()=>s,displayMode:()=>Ne,disposer:()=>_e,foldNodes:()=>Ve,formatDuration:()=>Fe,formatJSONValue:()=>ft,getConvertedParts:()=>mt,getOrInsert:()=>K,getOrInsertMap:()=>H,getOrInsertSet:()=>Q,getOrInsertSetFor:()=>Y,getOrInsertWith:()=>X,getOrInsertWithAsync:()=>Z,hasDefinedTupleValue:()=>j,hasDefiniteField:()=>x,hasOptionalTypedProperty:()=>g,hasOwnProperties:()=>p,hasOwnProperty:()=>h,hasStringProperty:()=>m,hasTypedProperty:()=>y,includes:()=>oe,interval:()=>Ge,isBoolean:()=>O,isBuffer:()=>S,isChildProcessError:()=>L,isDefined:()=>A,isErrnoException:()=>_,isExecException:()=>k,isExecFileException:()=>C,isFunction:()=>T,isMiddleClick:()=>He,isNodeFalsy:()=>We,isNodeRenderable:()=>Ke,isNumber:()=>E,isObject:()=>P,isPromiseLike:()=>$,isPromiseSettledFulfilled:()=>N,isPromiseSettledRejected:()=>R,isReactNode:()=>Xe,isRecord:()=>b,isRequestError:()=>q,isString:()=>w,isTypedArray:()=>v,iter:()=>Ee,json:()=>Ze,listTarEntries:()=>Lt,makeIterableIterator:()=>ze,metricUnitsToNumber:()=>yt,noop:()=>a,object:()=>U,observableCrate:()=>gt,onKeyboardShortcut:()=>bt,onceDefined:()=>Jt,prevDefault:()=>vt,put:()=>V,readFileFromTar:()=>Ft,readonly:()=>Ot,rectifyOrdering:()=>Mt,rejectPromiseBy:()=>Pt,safeJSONPathValue:()=>dt,setAndGet:()=>ee,setTimeoutFor:()=>n,sortBySemverVersion:()=>$t,sortCompare:()=>xt,stopPropagation:()=>wt,strictGet:()=>re,strictSet:()=>te,toCamelCase:()=>D,toggle:()=>ne,tuple:()=>qt,unionPATHs:()=>Bt,unitsToBytes:()=>je,urlBuilderFor:()=>J,waitUntilDefined:()=>It,withConcurrencyLimit:()=>Dt});class r extends AbortController{constructor(e){super(),null==e||e.signal.addEventListener("abort",(()=>{this.abort()}))}}function n(e,t){const r=setTimeout((()=>e.abort()),t);e.signal.addEventListener("abort",(()=>clearTimeout(r)))}function o(e,t){t.aborted?e.abort():t.addEventListener("abort",(t=>e.abort(t)))}const i={bifurcate:function(e,t){const r=[],n=[];for(const o of e)t(o)?r.push(o):n.push(o);return[n,r]},filled:function(e,t){return Array(e).fill(t)},split:function(e,t){const r=e.indexOf(t);return r<0?[e,[],!1]:[e.slice(0,r),e.slice(r+1,e.length),!0]}};function s(e=1e3,t){return new Promise((r=>{const n=setTimeout(r,e);null==t||t.addEventListener("abort",(()=>{clearTimeout(n),r()}))}))}function a(...e){}const u=async(e,t)=>{const{initialTimeout:r=1e3,maxAttempts:n=5,onIntermediateError:o=a,scaleFactor:i=2}=null!=t?t:{};let u,c=r,l=0;do{if(u=await e(),u.callWasSuccessful)return u;o(u.error,l+1),await s(c),c*=i}while(l+=1,l<n);return u},c=require("crypto-js/enc-base64"),l=require("crypto-js/enc-utf8"),f={encode:function(e){return l.parse(e).toString(c)},decode:function(e){return c.parse(e).toString(l)}},d=require("path-to-regexp");function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function p(e,...t){return t.every((t=>h(e,t)))}function y(e,t,r){return h(e,t)&&r(e[t])}function m(e,t){return h(e,t)&&w(e[t])}function g(e,t,r){return!h(e,t)||void 0===e[t]||r(e[t])}function b(e,t,r){return P(e)&&Object.entries(e).every((([e,n])=>t(e)&&r(n)))}function v(e,t){return Array.isArray(e)&&e.every(t)}function w(e){return"string"==typeof e}function S(e){return e instanceof Buffer}function E(e){return"number"==typeof e}function O(e){return"boolean"==typeof e}function P(e){return"object"==typeof e&&null!==e}function A(e){return null!=e}function T(e){return"function"==typeof e}function j(e){return null!=e[1]}function M(e,...t){return r=>e(r,...t)}function x(e){return t=>null!=t[e]}function $(e){return e instanceof Promise||P(e)&&y(e,"then",T)}function R(e){return"rejected"===e.status}function N(e){return"fulfilled"===e.status}function _(e){return P(e)&&g(e,"code",w)&&g(e,"path",w)&&g(e,"syscall",w)&&g(e,"errno",E)&&e instanceof Error}function k(e){return P(e)&&g(e,"cmd",w)&&g(e,"killed",O)&&g(e,"signal",w)&&g(e,"code",E)&&e instanceof Error}function C(e){return k(e)&&_(e)}const F=e=>w(e)||S(e);function L(e,t){return!!C(e)&&("string"===t?y(e,"stderr",w)&&y(e,"stdout",w):"buffer"===t?y(e,"stderr",S)&&y(e,"stdout",S):y(e,"stderr",F)&&y(e,"stdout",F))}function q(e){return P(e)&&g(e,"statusCode",E)&&g(e,"failed",O)&&g(e,"timedOut",O)&&g(e,"error",w)&&g(e,"response",P)&&e instanceof ELine truncated
@@ -0,0 +1,13 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* This is like an `AbortController` but will also abort if the parent aborts,
* but won't make the parent abort if this aborts (single direction)
*/
export declare class WrappedAbortController extends AbortController {
constructor(parent?: AbortController | undefined);
}
export declare function setTimeoutFor(controller: AbortController, timeout: number): void;
export declare function chainSignal(target: AbortController, signal: AbortSignal): void;
+29
View File
@@ -0,0 +1,29 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* A inference typed version of `Array(length).fill(value)`
* @param length The number of entries
* @param value The value of each of the indices
*/
declare function filled<T>(length: number, value: T): T[];
/**
* This function splits an array into two sub arrays on the first instance of
* element (from the left). If the array does not contain the element. The
* return value is defined to be `[array, [], false]`. If the element is in
* the array then the return value is `[left, right, true]` where `left` is
* the elements of `array` from `[0, index)` and `right` is `(index, length)`
* @param array the full array to split into two sub-arrays
* @param element the element in the middle of the array
* @returns the left and right sub-arrays which when conjoined with `element`
* is the same as `array`, and `true`
*/
declare function split<T>(src: T[], element: T): [T[], T[], boolean];
declare function bifurcate<T>(src: T[], condition: (item: T) => any): [falses: T[], trues: T[]];
export declare const array: {
bifurcate: typeof bifurcate;
filled: typeof filled;
split: typeof split;
};
export {};
@@ -0,0 +1,35 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { AsyncResult } from "./result";
/**
* @param error The error that resulted in the failure
* @param attempt The 1-index attempt count
*/
export type OnIntermediateError<E> = (error: E, attempt: number) => void;
export interface BackoffCallerOptions<E> {
/**
* Called when an attempt fails
*/
onIntermediateError?: OnIntermediateError<E>;
/**
* @default 5
*/
maxAttempts?: number;
/**
* In milliseconds
* @default 1000
*/
initialTimeout?: number;
/**
* @default 2
*/
scaleFactor?: number;
}
/**
* Calls `fn` once and then again (with exponential delay between each attempt) up to `options.maxAttempts` times.
* @param fn The function to repeatedly attempt
* @returns The first success or the last failure
*/
export declare const backoffCaller: <T, E>(fn: () => AsyncResult<T, E>, options?: BackoffCallerOptions<E> | undefined) => AsyncResult<T, E>;
@@ -0,0 +1,21 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Computes utf-8 from base64
* @param data A Base64 encoded string
* @returns The original utf-8 string
*/
declare function decode(data: string): string;
/**
* Computes base64 from utf-8
* @param data A normal string
* @returns A base64 encoded version
*/
declare function encode(data: string): string;
export declare const base64: {
encode: typeof encode;
decode: typeof decode;
};
export {};
@@ -0,0 +1,20 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { RouteProps } from "react-router";
export interface UrlRouteProps extends RouteProps {
path: string;
}
export interface URLParams<P extends object = {}, Q extends object = {}> {
params?: P;
query?: Q;
fragment?: string;
}
export declare function buildURL<P extends object = {}, Q extends object = {}>(path: string, { params, query, fragment }?: URLParams<P, Q>): string;
export declare function buildURLPositional<P extends object = {}, Q extends object = {}>(path: string): (params?: P, query?: Q, fragment?: string) => string;
export type UrlParamsFor<Pathname extends string> = Pathname extends `${string}/:${infer A}?/${infer Tail}` ? Partial<Record<A, string>> & UrlParamsFor<`/${Tail}`> : Pathname extends `${string}/:${infer A}/${infer Tail}` ? Record<A, string> & UrlParamsFor<`/${Tail}`> : Pathname extends `${string}/:${infer A}?` ? Partial<Record<A, string>> : Pathname extends `${string}/:${infer A}` ? Record<A, string> : {};
export interface UrlBuilder<Pathname extends string> {
compile(params: UrlParamsFor<Pathname>, query?: object, fragment?: string): string;
}
export declare function urlBuilderFor<Pathname extends string>(pathname: Pathname): UrlBuilder<Pathname>;
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function toCamelCase<T extends Record<string, unknown>[]>(obj: T): T;
export declare function toCamelCase<T extends Record<string, unknown>>(obj: T): T;
@@ -0,0 +1,67 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Get the value behind `key`. If it was not present, first insert `value`
* @param map The map to interact with
* @param key The key to insert into the map with
* @param value The value to optional add to the map
* @returns The value in the map
*/
export declare function getOrInsert<K, V>(map: Map<K, V>, key: K, value: V): V;
/**
* Updates map and returns the value that was just inserted
*/
export declare function put<K, V>(map: Map<K, V>, key: K, value: V): V;
/**
* Like `getOrInsert` but specifically for when `V` is `Map<MK, MV>` so that
* the typings are inferred correctly.
*/
export declare function getOrInsertMap<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map<MK, MV>;
/**
* Like `getOrInsert` but specifically for when `V` is `Set<any>` so that
* the typings are inferred.
*/
export declare function getOrInsertSet<K, SK>(map: Map<K, Set<SK>>, key: K): Set<SK>;
/**
* A currying version of {@link getOrInsertSet}
*/
export declare function getOrInsertSetFor<K, SK>(map: Map<K, Set<SK>>): (key: K) => Set<SK>;
/**
* Like `getOrInsert` but with delayed creation of the item. Which is useful
* if it is very expensive to create the initial value.
*/
export declare function getOrInsertWith<K, V>(map: Map<K, V>, key: K, builder: () => V): V;
export declare function getOrInsertWith<K extends object, V>(map: Map<K, V> | WeakMap<K, V>, key: K, builder: () => V): V;
/**
* Like {@link getOrInsertWith} but the builder is async and will be awaited before inserting into the map
*/
export declare function getOrInsertWithAsync<K, V>(map: Map<K, V>, key: K, asyncBuilder: () => Promise<V>): Promise<V>;
/**
* Insert `val` into `map` under `key` and then get the value back
*/
export declare function setAndGet<K, V>(map: Map<K, V>, key: K, val: V): V;
/**
* Set the value associated with `key` iff there was not a previous value
* @param map The map to interact with
* @throws if `key` already in map
* @returns `this` so that `strictSet` can be chained
*/
export declare function strictSet<K, V>(map: Map<K, V>, key: K, val: V): typeof map;
/**
* Get the value associated with `key`
* @param map The map to interact with
* @throws if `key` did not a value associated with it
*/
export declare function strictGet<K, V>(map: Map<K, V>, key: K): V;
/**
* If `key` is in `set`, remove it otherwise add it.
* @param set The set to manipulate
* @param key The key to toggle the "is in"-ness of
*/
export declare function toggle<K>(set: Set<K>, key: K): void;
/**
* A helper function to also check for defined-ness
*/
export declare function includes<T>(src: T[], value: T | null | undefined): boolean;
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { IComputedValue } from "mobx";
export declare const computedOr: (...values: IComputedValue<boolean>[]) => IComputedValue<boolean>;
@@ -0,0 +1,5 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function cpuUnitsToNumber(value: string): number | undefined;
@@ -0,0 +1,13 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function unitsToBytes(value: string): number;
export interface BytesToUnitesOptions {
/**
* The number of decimal places. MUST be an integer. MUST be in the range [0, 20].
* @default 1
*/
precision?: number;
}
export declare function bytesToUnits(bytes: number, { precision }?: BytesToUnitesOptions): string;
@@ -0,0 +1,7 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export type IgnoredClassNames = number | symbol | Function;
export type IClassName = string | string[] | Record<string, any> | undefined | null | false | IgnoredClassNames;
export declare function cssNames(...classNames: IClassName[]): string;
@@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function cssVar(elem: HTMLElement): {
get(name: string): {
toString: () => string;
valueOf: () => number;
};
set(name: string, value: number | string): void;
};
@@ -0,0 +1,5 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function debouncePromise<T, F extends any[]>(func: (...args: F) => T | Promise<T>, timeout?: number): (...args: F) => Promise<T>;
+12
View File
@@ -0,0 +1,12 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Return a promise that will be resolved after at least `timeout` ms have
* passed. If `failFast` is provided then the promise is also resolved if it has
* been aborted.
* @param timeout The number of milliseconds before resolving
* @param failFast An abort controller instance to cause the delay to short-circuit
*/
export declare function delay(timeout?: number, failFast?: AbortSignal): Promise<void>;
@@ -0,0 +1,8 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Format `mode` in octal notation
*/
export declare function displayMode(mode: number): string;
@@ -0,0 +1,15 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { SingleOrMany } from "./types";
export interface Disposer {
(): void;
}
export interface Disposable {
dispose(): void;
}
export interface ExtendableDisposer extends Disposer {
push(...values: (Disposer | ExtendableDisposer | Disposable)[]): void;
}
export declare function disposer(...items: SingleOrMany<Disposer | Disposable | undefined | null>[]): ExtendableDisposer;
@@ -0,0 +1,9 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* This function formats durations in a more human readable form.
* @param timeValue the duration in milliseconds to format
*/
export declare function formatDuration(timeValue: number, compact?: boolean): string;
@@ -0,0 +1,49 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { IInterceptable, IInterceptor, IListenable, ISetWillChange } from "mobx";
import { ObservableSet } from "mobx";
export declare function makeIterableIterator<T>(iterator: Iterator<T>): IterableIterator<T>;
export declare class HashSet<T> implements Set<T> {
#private;
protected hasher: (item: T) => string;
constructor(initialValues: Iterable<T>, hasher: (item: T) => string);
replace(other: ObservableHashSet<T> | ObservableSet<T> | Set<T> | readonly T[]): this;
clear(): void;
add(value: T): this;
toggle(value: T): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, key: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
get size(): number;
entries(): IterableIterator<[T, T]>;
keys(): IterableIterator<T>;
values(): IterableIterator<T>;
[Symbol.iterator](): IterableIterator<T>;
get [Symbol.toStringTag](): string;
toJSON(): T[];
toString(): string;
}
export declare class ObservableHashSet<T> implements Set<T>, IInterceptable<ISetWillChange>, IListenable {
#private;
protected hasher: (item: T) => string;
get interceptors_(): IInterceptor<ISetWillChange<T>>[];
get changeListeners_(): Function[];
constructor(initialValues: Iterable<T>, hasher: (item: T) => string);
replace(other: ObservableHashSet<T> | ObservableSet<T> | Set<T> | readonly T[]): this;
clear(): void;
add(value: T): this;
toggle(value: T): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, key: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
get size(): number;
entries(): IterableIterator<[T, T]>;
keys(): IterableIterator<T>;
values(): IterableIterator<T>;
[Symbol.iterator](): IterableIterator<T>;
get [Symbol.toStringTag](): string;
toJSON(): T[];
toString(): string;
}
@@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export interface IntervalFn {
start(runImmediately?: boolean): void;
stop(): void;
restart(runImmediately?: boolean): void;
readonly isRunning: boolean;
}
export declare function interval(timeSec: number | undefined, callback: (count: number) => void, autoRun?: boolean): IntervalFn;
@@ -0,0 +1,17 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type React from "react";
/**
* Returns `true` if `node` is a falsy value
*/
export declare function isNodeFalsy(node: React.ReactNode): boolean;
/**
* Return `true` if React would render this
*/
export declare function isNodeRenderable(node: React.ReactNode): boolean;
/**
* Returns the first react node provided that is would be rendered by react
*/
export declare function foldNodes(...nodes: React.ReactNode[]): React.ReactNode;
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type React from "react";
export declare function isMiddleClick<E extends React.MouseEvent>(callback: (evt: E) => any): (evt: E) => any;
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ReactNode } from "react";
export declare function isReactNode(node: unknown): node is ReactNode;
+144
View File
@@ -0,0 +1,144 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export type Falsy = false | 0 | "" | null | undefined;
interface Iterator<T> extends Iterable<T> {
filter(fn: (val: T) => unknown): Iterator<T>;
filterMap<U>(fn: (val: T) => Falsy | U): Iterator<U>;
find(fn: (val: T) => unknown): T | undefined;
collect<U>(fn: (values: Iterable<T>) => U): U;
toArray(): T[];
toMap(): T extends [infer K, infer V] ? Map<K, V> : never;
toSet(): Set<T>;
map<U>(fn: (val: T) => U): Iterator<U>;
flatMap<U>(fn: (val: T) => U[]): Iterator<U>;
concat(src2: IterableIterator<T>): Iterator<T>;
join(sep?: string): string;
take(count: number): Iterator<T>;
}
declare function chain<T>(src: IterableIterator<T>): Iterator<T>;
/**
* Create a new type safe empty Iterable
* @returns An `Iterable` that yields 0 items
*/
declare function newEmpty<T>(): IterableIterator<T>;
/**
* Creates a new `Iterable` that yields at most n items from src.
* Does not modify `src` which can be used later.
* @param src An initial iterator
* @param n The maximum number of elements to take from src. Yields up to the floor of `n` and 0 items if n < 0
*/
declare function take<T>(src: Iterable<T>, n: number): IterableIterator<T>;
/**
* Creates a new iterator that iterates (lazily) over its input and yields the
* result of `fn` for each item.
* @param src A type that can be iterated over
* @param fn The function that is called for each value
*/
declare function map<T, U>(src: Iterable<T>, fn: (from: T) => U): IterableIterator<U>;
/**
* The single layer flattening of an iterator, discarding `Falsy` values.
* @param src A type that can be iterated over
* @param fn The function that returns either an iterable over items that should be filtered out or a `Falsy` value indicating that it should be ignored
*/
declare function filterFlatMap<T, U>(src: Iterable<T>, fn: (from: T) => Iterable<U | Falsy> | Falsy): IterableIterator<U>;
/**
* Returns a new iterator that yields the items that each call to `fn` would produce
* @param src A type that can be iterated over
* @param fn A function that returns an iterator
*/
declare function flatMap<T, U>(src: Iterable<T>, fn: (from: T) => Iterable<U>): IterableIterator<U>;
/**
* Creates a new iterator that iterates (lazily) over its input and yields the
* items that return a `truthy` value from `fn`.
* @param src A type that can be iterated over
* @param fn The function that is called for each value
*/
declare function filter<T>(src: Iterable<T>, fn: (from: T) => any): IterableIterator<T>;
/**
* Creates a new iterator that iterates (lazily) over its input and yields the
* result of `fn` when it is `truthy`
* @param src A type that can be iterated over
* @param fn The function that is called for each value
*/
declare function filterMap<T, U>(src: Iterable<T>, fn: (from: T) => U | Falsy): IterableIterator<U>;
/**
* Creates a new iterator that iterates (lazily) over its input and yields the
* result of `fn` when it is not null or undefined
* @param src A type that can be iterated over
* @param fn The function that is called for each value
*/
declare function filterMapStrict<T, U>(src: Iterable<T>, fn: (from: T) => U | null | undefined): IterableIterator<U>;
/**
* Iterate through `src` until `match` returns a truthy value
* @param src A type that can be iterated over
* @param match A function that should return a truthy value for the item that you want to find
* @returns The first entry that `match` returns a truthy value for, or `undefined`
*/
declare function find<T>(src: Iterable<T>, match: (i: T) => any): T | undefined;
/**
* Iterate over `src` calling `reducer` with the previous produced value and the current
* yielded value until `src` is exhausted. Then return the final value.
* @param src The value to iterate over
* @param reducer A function for producing the next item from an accumulation and the current item
* @param initial The initial value for the iteration
*/
declare function reduce<T, R extends Iterable<any>>(src: Iterable<T>, reducer: (acc: R, cur: T) => R, initial: R): R;
/**
* A convenience function for reducing over an iterator of strings and concatenating them together
* @param src The value to iterate over
* @param connector The string value to intersperse between the yielded values
* @returns The concatenated entries of `src` interspersed with copies of `connector`
*/
declare function join(src: IterableIterator<unknown>, connector?: string): string;
/**
* Iterate `n` times and then return the next value.
* @param src The value to iterate over
* @param n The zero-index value for the item to return to.
*/
declare function nth<T>(src: Iterable<T>, n: number): T | undefined;
/**
* A convenience function to get the first item of an iterator
* @param src The value to iterate over
*/
declare function first<T>(src: Iterable<T>): T | undefined;
/**
* Iterate through `src` and return `true` if `fn` returns a truthy value for every yielded value.
* Otherwise, return `false`. This function short circuits.
* @param src The type to be iterated over
* @param fn A function to check each iteration
*/
declare function every<T>(src: Iterable<T>, fn: (val: T) => any): boolean;
declare function concat<T>(...sources: IterableIterator<T>[]): IterableIterator<T>;
/**
* Split an iterable into several arrays with matching fields
* @param from The iterable of items to split up
* @param field The field of each item to split over
* @param parts What each array will be filtered to
* @returns A `parts.length` tuple of `T[]` where each array has matching `field` values
*/
declare function nFircate<T>(from: Iterable<T>, field: keyof T, parts: []): [];
declare function nFircate<T>(from: Iterable<T>, field: keyof T, parts: [T[typeof field]]): [T[]];
declare function nFircate<T>(from: Iterable<T>, field: keyof T, parts: [T[typeof field], T[typeof field]]): [T[], T[]];
declare function nFircate<T>(from: Iterable<T>, field: keyof T, parts: [T[typeof field], T[typeof field], T[typeof field]]): [T[], T[], T[]];
export declare const iter: {
chain: typeof chain;
concat: typeof concat;
every: typeof every;
filter: typeof filter;
filterFlatMap: typeof filterFlatMap;
filterMap: typeof filterMap;
filterMapStrict: typeof filterMapStrict;
find: typeof find;
first: typeof first;
flatMap: typeof flatMap;
join: typeof join;
map: typeof map;
nFircate: typeof nFircate;
newEmpty: typeof newEmpty;
nth: typeof nth;
reduce: typeof reduce;
take: typeof take;
};
export {};
@@ -0,0 +1,8 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { Result } from "./result";
export declare const json: {
parse: (input: string) => Result<unknown, Error>;
};
@@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* The GO package that kubectl and kubernetes uses for its JSONpath implementation has some
* shorthand conveniences that are not part of the official spec. This function tries to convert
* those shorthands to the official spec.
*
* Known shorthands:
* - Leading `$` is optional (but implied)
* - The string `/` can be used without a leading `\` escapement
* - The string `\.` is used to denote the "value of '.'" and not "next key"
* - The string `-` can be used while not in quotes
* - `[]` as shorthand for `[0]`
* - Remove `..` at the end of a path, we will just format it slightly differently
* - Allow `...foo` as well as `..foo`
*/
export declare function convertKubectlJsonPathToNodeJsonPath(jsonPath: string): string;
export declare function formatJSONValue(value: unknown): string;
/**
* This function is a safer version of `JSONPath.value(obj, path)` with untrusted jsonpath strings
*
* This function will also stringify the value retreived from the object
*/
export declare function safeJSONPathValue(obj: object, path: string): unknown;
@@ -0,0 +1,5 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function metricUnitsToNumber(value: string): number;
@@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Split `name` into the parts seperated by one or more of (-, _, or .) and
* the sections can be converted to numbers will be converted
* @param name A kube object name
* @returns The converted parts of the name
*/
export declare function getConvertedParts(name: string): (string | number)[];
@@ -0,0 +1,8 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* A function that does nothing
*/
export declare function noop<T extends any[]>(...args: T): void;
@@ -0,0 +1,19 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* A better typed version of `Object.fromEntries` where the keys are known to
* be a specific subset
*/
declare function fromEntries<T, Key extends string>(entries: Iterable<readonly [Key, T]>): Record<Key, T>;
declare function keys<K extends keyof any>(obj: Partial<Record<K, any>>): K[];
declare function entries<K extends string, V>(obj: Partial<Record<K, V>> | null | undefined): [K, V][];
declare function entries<K extends string | number | symbol, V>(obj: Partial<Record<K, V>> | null | undefined): [K, V][];
declare function entries<K extends string | number | symbol, V>(obj: Record<K, V> | null | undefined): [K, V][];
export declare const object: {
entries: typeof entries;
fromEntries: typeof fromEntries;
keys: typeof keys;
};
export {};
@@ -0,0 +1,18 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export interface ObservableCrate<T> {
get(): T;
set(value: T): void;
}
export interface ObservableCrateFactory {
<T>(initialValue: T, transitionHandlers?: ObservableCrateTransitionHandlers<T>): ObservableCrate<T>;
}
export interface ObservableCrateTransitionHandler<T> {
from: T;
to: T;
onTransition: () => void;
}
export type ObservableCrateTransitionHandlers<T> = ObservableCrateTransitionHandler<T>[];
export declare const observableCrate: ObservableCrateFactory;
@@ -0,0 +1,5 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare function onKeyboardShortcut(descriptor: string, action: () => void): (this: Window, ev: WindowEventMap["keydown"]) => any;
@@ -0,0 +1,7 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type React from "react";
export declare function prevDefault<E extends React.SyntheticEvent | Event, R>(callback: (evt: E) => R): (event: E) => R;
export declare function stopPropagation(evt: Event | React.SyntheticEvent): void;
@@ -0,0 +1,46 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { Readable } from "readable-stream";
import type { TypedArray } from "type-fest";
/**
* ReadableWebToNodeStream
*
* Copied from https://github.com/Borewit/readable-web-to-node-stream
*
* Adds read error handler
*
* */
export declare class ReadableWebToNodeStream<T extends TypedArray> extends Readable {
bytesRead: number;
released: boolean;
/**
* Default web API stream reader
* https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader
*/
private reader;
private pendingRead?;
/**
*
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
*/
constructor(stream: ReadableStream<T>);
/**
* Implementation of readable._read(size).
* When readable._read() is called, if data is available from the resource,
* the implementation should begin pushing that data into the read queue
* https://nodejs.org/api/stream.html#stream_readable_read_size_1
*/
_read(): Promise<void>;
/**
* If there is no unresolved read call to Web-API ReadableStream immediately returns;
* otherwise will wait until the read is resolved.
*/
waitForReadToComplete(): Promise<void>;
/**
* Close wrapper
*/
close(): Promise<void>;
private syncAndRelease;
}
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ReadonlyDeep } from "type-fest";
export declare function readonly<T>(src: T): ReadonlyDeep<T>;
@@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Creates a new promise that will be rejected when the signal rejects.
*
* Useful for `Promise.race()` applications.
* @param signal The AbortController's signal to reject with
*/
export declare function rejectPromiseBy(signal: AbortSignal): Promise<never>;
@@ -0,0 +1,22 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* A helper type for async functions that return a `Result`
*/
export type AsyncResult<Response, Error = string> = Promise<Result<Response, Error>>;
/**
* Result describes the "error is just more data" pattern instead of using exceptions for
* normal execution
*/
export type Result<Response, Error = string> = (Response extends void ? {
callWasSuccessful: true;
response?: undefined;
} : {
callWasSuccessful: true;
response: Response;
}) | {
callWasSuccessful: false;
error: Error;
};
@@ -0,0 +1,33 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export declare enum Ordering {
LESS = -1,
EQUAL = 0,
GREATER = 1
}
/**
* This function switches the direction of `ordering` if `direction` is `"desc"`
* @param ordering The original ordering (assumed to be an "asc" ordering)
* @param direction The new desired direction
*/
export declare function rectifyOrdering(ordering: Ordering, direction: "asc" | "desc"): Ordering;
/**
* An ascending sorting function
* @param left An item from an array
* @param right An item from an array
* @returns The relative ordering in an ascending manner.
* - Less if left < right
* - Equal if left == right
* - Greater if left > right
*/
export declare function sortCompare<T>(left: T, right: T): Ordering;
/**
* This function sorts of list of items that have what should be a semver version formatted string
* as the field `version` but if it is not loosely coercible to semver falls back to sorting them
* alphanumerically
*/
export declare function sortBySemverVersion<T extends {
version: string;
}>(versioned: T[]): T[];
@@ -0,0 +1,8 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Get an ordering function based on the function getter
*/
export declare function byValue<T>(getOrderValue: (src: T) => number): (left: T, right: T) => number;
+17
View File
@@ -0,0 +1,17 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/// <reference types="node" />
import type { JsonValue } from "type-fest";
export type ReadFileFromTarOpts<ParseJson extends boolean> = {
tarPath: string;
filePath: string;
} & (ParseJson extends true ? {
parseJson: true;
} : {
parseJson?: false;
});
export declare function readFileFromTar(opts: ReadFileFromTarOpts<false>): Promise<Buffer>;
export declare function readFileFromTar(opts: ReadFileFromTarOpts<true>): Promise<JsonValue>;
export declare function listTarEntries(filePath: string): Promise<string[]>;
+35
View File
@@ -0,0 +1,35 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* A strict N-tuple of type T
*/
export type Tuple<T, N extends number> = N extends N ? number extends N ? T[] : TupleOfImpl<T, N, []> : never;
type TupleOfImpl<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : TupleOfImpl<T, N, [T, ...R]>;
/**
* Iterates over `sources` yielding full tuples until one of the tuple arrays
* is empty. Then it returns a tuple with the rest of each of tuples
* @param sources The source arrays
* @yields A tuple of the next element from each of the sources
* @returns The tuple of all the sources as soon as at least one of the sources is exausted
*/
declare function zip<T>(...sources: Tuple<T[], 0>): Iterator<Tuple<T, 0>, Tuple<T[], 0>>;
declare function zip<T>(...sources: Tuple<T[], 1>): Iterator<Tuple<T, 1>, Tuple<T[], 1>>;
declare function zip<T>(...sources: Tuple<T[], 2>): Iterator<Tuple<T, 2>, Tuple<T[], 2>>;
/**
* Returns a `length` tuple filled with copies of `value`
* @param length The size of the tuple
* @param value The value for each of the tuple entries
*/
declare function filled<T, L extends number>(length: L, value: T): Tuple<T, L>;
/**
* A function for converting an explicit array to a tuple but without the `readonly` typing
*/
declare function from<T extends any[]>(...args: T): [...T];
export declare const tuple: {
zip: typeof zip;
filled: typeof filled;
from: typeof from;
};
export {};
@@ -0,0 +1,138 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type { ExecException, ExecFileException } from "child_process";
import type { IncomingMessage } from "http";
/**
* Narrows `val` to include the property `key` (if true is returned)
* @param val The object to be tested
* @param key The key to test if it is present on the object (must be a literal for tsc to do any meaningful typing)
*/
export declare function hasOwnProperty<S extends object, K extends PropertyKey>(val: S, key: K): val is (S & {
[key in K]: unknown;
});
/**
* Narrows `val` to a static type that includes fields of names in `keys`
* @param val the value that we are trying to type narrow
* @param keys the key names (must be literals for tsc to do any meaningful typing)
*/
export declare function hasOwnProperties<S extends object, K extends PropertyKey>(val: S, ...keys: K[]): val is (S & {
[key in K]: unknown;
});
/**
* Narrows `val` to include the property `key` with type `V`
* @param val the value that we are trying to type narrow
* @param key The key to test if it is present on the object (must be a literal for tsc to do any meaningful typing)
* @param isValid a function to check if the field is valid
*/
export declare function hasTypedProperty<S extends object, K extends PropertyKey, V>(val: S, key: K, isValid: (value: unknown) => value is V): val is (S & {
[key in K]: V;
});
/**
* Narrows `val` to include the property `key` with type string
* @param val the value that we are trying to type narrow
* @param key The key to test if it is present on the object (must be a literal for tsc to do any meaningful typing)
*/
export declare function hasStringProperty<S extends object, K extends PropertyKey>(val: S, key: K): val is (S & {
[key in K]: string;
});
/**
* Narrows `val` to include the property `key` with type `V | undefined` or doesn't contain it
* @param val the value that we are trying to type narrow
* @param key The key to test if it is present on the object (must be a literal for tsc to do any meaningful typing)
* @param isValid a function to check if the field (when present) is valid
*/
export declare function hasOptionalTypedProperty<S extends object, K extends PropertyKey, V>(val: S, key: K, isValid: (value: unknown) => value is V): val is (S & {
[key in K]?: V;
});
/**
* isRecord checks if `val` matches the signature `Record<T, V>` or `{ [label in T]: V }`
* @param val The value to be checked
* @param isKey a function for checking if the key is of the correct type
* @param isValue a function for checking if a value is of the correct type
*/
export declare function isRecord<T extends PropertyKey, V>(val: unknown, isKey: (key: unknown) => key is T, isValue: (value: unknown) => value is V): val is Record<T, V>;
/**
* isTypedArray checks if `val` is an array and all of its entries are of type `T`
* @param val The value to be checked
* @param isEntry a function for checking if an entry is the correct type
*/
export declare function isTypedArray<T>(val: unknown, isEntry: (entry: unknown) => entry is T): val is T[];
/**
* checks if val is of type string
* @param val the value to be checked
*/
export declare function isString(val: unknown): val is string;
/**
* checks if val is of type Buffer
* @param val the value to be checked
*/ export declare function isBuffer(val: unknown): val is Buffer;
/**
* checks if val is of type number
* @param val the value to be checked
*/
export declare function isNumber(val: unknown): val is number;
/**
* checks if val is of type boolean
* @param val the value to be checked
*/
export declare function isBoolean(val: unknown): val is boolean;
/**
* checks if val is of type object and isn't null
* @param val the value to be checked
*/
export declare function isObject(val: unknown): val is Record<string | symbol | number, unknown>;
/**
* checks if `val` is defined, useful for filtering out undefined values in a strict manner
*/
export declare function isDefined<T>(val: T | undefined | null): val is T;
export declare function isFunction(val: unknown): val is (...args: unknown[]) => unknown;
/**
* Checks if the value in the second position is non-nullable
*/
export declare function hasDefinedTupleValue<K, V>(pair: readonly [K, V | undefined | null]): pair is [K, V];
/**
* Creates a new predicate function (with the same predicate) from `fn`. Such
* that it can be called with just the value to be tested.
*
* This is useful for when using `hasOptionalProperty` and `hasTypedProperty`
* @param fn A typescript user predicate function to be bound
* @param boundArgs the set of arguments to be passed to `fn` in the new function
*/
export declare function bindPredicate<FnArgs extends any[], T>(fn: (arg1: unknown, ...args: FnArgs) => arg1 is T, ...boundArgs: FnArgs): (arg1: unknown) => arg1 is T;
export declare function hasDefiniteField<Field extends keyof T, T>(field: Field): (val: T) => val is T & {
[f in Field]-?: NonNullable<T[Field]>;
};
export declare function isPromiseLike(res: unknown): res is (Promise<unknown> | {
then: (fn: (val: unknown) => any) => Promise<unknown>;
});
export declare function isPromiseSettledRejected<T>(result: PromiseSettledResult<T>): result is PromiseRejectedResult;
export declare function isPromiseSettledFulfilled<T>(result: PromiseSettledResult<T>): result is PromiseFulfilledResult<T>;
export declare function isErrnoException(error: unknown): error is NodeJS.ErrnoException;
export declare function isExecException(error: unknown): error is ExecException;
export declare function isExecFileException(error: unknown): error is ExecFileException;
export type OutputFormat = "string" | "buffer";
export type ComputeOutputFormat<Format> = Format extends "string" ? string : Format extends "buffer" ? Buffer : string | Buffer;
export interface ChildProcessExecpetion<Format> extends ExecFileException {
stderr: ComputeOutputFormat<Format>;
stdout: ComputeOutputFormat<Format>;
}
export declare function isChildProcessError(error: unknown, format?: OutputFormat): error is ChildProcessExecpetion<typeof format>;
export interface RequestLikeError extends Error {
statusCode?: number;
failed?: boolean;
timedOut?: boolean;
error?: string;
response?: IncomingMessage & {
body?: any;
};
}
/**
* A type guard for checking if the error is similar in shape to a request package error
*/
export declare function isRequestError(error: unknown): error is RequestLikeError;
+20
View File
@@ -0,0 +1,20 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { SetRequired } from "type-fest";
export type RemoveUndefinedFromValues<K> = {
[P in keyof K]: NonNullable<K[P]>;
};
/**
* This type helps define which fields of some type will always be defined
*/
export type Defaulted<Params, DefaultParams extends keyof Params> = RemoveUndefinedFromValues<Required<Pick<Params, DefaultParams>>> & Omit<Params, DefaultParams>;
export type OptionVariant<Key, Base, RequiredKey extends keyof Base> = {
type: Key;
} & Pick<Base, RequiredKey> & {
[OtherKey in Exclude<keyof Base, RequiredKey>]?: undefined;
};
export type SingleOrMany<T> = T | T[];
export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends (<G>() => G extends U ? 1 : 2) ? Y : N;
export type MaybeSetRequired<BaseType, Keys extends keyof BaseType, Query> = Query extends true ? SetRequired<BaseType, Keys> : BaseType;
@@ -0,0 +1,12 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Join all entires with a PATH env var delimited string together
* @param PATHs Any number of PATH env variables
*
* NOTE: This function does not attempt to handle any sort of escape sequences since after testing
* it was found that `zsh` (at least on `macOS`) does not when trying to find programs
*/
export declare function unionPATHs(...PATHs: string[]): string;
+10
View File
@@ -0,0 +1,10 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { IComputedValue } from "mobx";
import type { Disposer } from "./disposer";
export declare function waitUntilDefined<T>(getter: (() => T | null | undefined) | IComputedValue<T | null | undefined>, opts?: {
timeout?: number;
}): Promise<T>;
export declare function onceDefined<T>(getter: () => T | null | undefined, action: (val: T) => void): Disposer;
@@ -0,0 +1,2 @@
export type ConcurrencyLimiter = <Args extends any[], Res>(fn: (...args: Args) => Res) => (...args: Args) => Promise<Res>;
export declare function withConcurrencyLimit(limit: number): ConcurrencyLimiter;