mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rename iter.pipeline as iter.chain
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
1841907eb8
commit
9f4941f4a8
@ -15,12 +15,12 @@ interface Iterator<T> extends Iterable<T> {
|
|||||||
join(sep?: string): string;
|
join(sep?: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pipeline<T>(src: IterableIterator<T>): Iterator<T> {
|
export function chain<T>(src: IterableIterator<T>): Iterator<T> {
|
||||||
return {
|
return {
|
||||||
filter: (fn) => pipeline(filter(src, fn)),
|
filter: (fn) => chain(filter(src, fn)),
|
||||||
filterMap: (fn) => pipeline(filterMap(src, fn)),
|
filterMap: (fn) => chain(filterMap(src, fn)),
|
||||||
map: (fn) => pipeline(map(src, fn)),
|
map: (fn) => chain(map(src, fn)),
|
||||||
flatMap: (fn) => pipeline(flatMap(src, fn)),
|
flatMap: (fn) => chain(flatMap(src, fn)),
|
||||||
find: (fn) => find(src, fn),
|
find: (fn) => find(src, fn),
|
||||||
join: (sep) => join(src, sep),
|
join: (sep) => join(src, sep),
|
||||||
collect: (fn) => fn(src),
|
collect: (fn) => fn(src),
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export class KubeconfigSyncManager {
|
|||||||
const seenIds = new Set<string>();
|
const seenIds = new Set<string>();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
iter.pipeline(this.sources.values())
|
iter.chain(this.sources.values())
|
||||||
.flatMap(([entities]) => entities.get())
|
.flatMap(([entities]) => entities.get())
|
||||||
.filter(entity => {
|
.filter(entity => {
|
||||||
const alreadySeen = seenIds.has(entity.getId());
|
const alreadySeen = seenIds.has(entity.getId());
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import type { V1APIGroupList } from "@kubernetes/client-node";
|
import type { V1APIGroupList } from "@kubernetes/client-node";
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { pipeline } from "../../common/utils/iter";
|
import { chain } from "../../common/utils/iter";
|
||||||
import k8sRequestInjectable from "../k8s-request.injectable";
|
import k8sRequestInjectable from "../k8s-request.injectable";
|
||||||
import { requestApiVersionsInjectionToken } from "./request-api-versions";
|
import { requestApiVersionsInjectionToken } from "./request-api-versions";
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ const requestNonCoreApiVersionsInjectable = getInjectable({
|
|||||||
return async (cluster) => {
|
return async (cluster) => {
|
||||||
const { groups } = await k8sRequest(cluster, "/apis") as V1APIGroupList;
|
const { groups } = await k8sRequest(cluster, "/apis") as V1APIGroupList;
|
||||||
|
|
||||||
return pipeline(groups.values())
|
return chain(groups.values())
|
||||||
.filterMap(group => group.preferredVersion?.groupVersion && ({
|
.filterMap(group => group.preferredVersion?.groupVersion && ({
|
||||||
group: group.name,
|
group: group.name,
|
||||||
path: `/apis/${group.preferredVersion.groupVersion}`,
|
path: `/apis/${group.preferredVersion.groupVersion}`,
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export class AddSecretDialog extends React.Component<AddSecretDialogProps> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private getDataFromFields = (fields: SecretTemplateField[] = [], processValue: (val: string) => string = (val => val)) => {
|
private getDataFromFields = (fields: SecretTemplateField[] = [], processValue: (val: string) => string = (val => val)) => {
|
||||||
return iter.pipeline(fields.values())
|
return iter.chain(fields.values())
|
||||||
.filterMap(({ key, value }) => (
|
.filterMap(({ key, value }) => (
|
||||||
value
|
value
|
||||||
? [key, processValue(value)] as const
|
? [key, processValue(value)] as const
|
||||||
|
|||||||
@ -67,7 +67,7 @@ const NonInjectedCommandDialog = observer(({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeCommands = iter.pipeline(commands.get().values())
|
const activeCommands = iter.chain(commands.get().values())
|
||||||
.filter(command => {
|
.filter(command => {
|
||||||
try {
|
try {
|
||||||
return command.isActive(context);
|
return command.isActive(context);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export function cssNames(...classNames: IClassName[]): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter.pipeline(classNamesEnabled.entries())
|
return iter.chain(classNamesEnabled.entries())
|
||||||
.filter(([, isActive]) => !!isActive)
|
.filter(([, isActive]) => !!isActive)
|
||||||
.filterMap(([className]) => className.trim())
|
.filterMap(([className]) => className.trim())
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user