1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/core/src/common/utils/find-key-contains.injectable.ts
Juho Heikka 65afe3c64a Fix ensure hashed directory for extension
Earlier open lens versions stored extension_data directory based on
path of extension's package.json. This causes problems
because extensions have moved to new location. This ensures
backward compatibility that extension will get the same
directory than before the change.

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
2023-02-17 16:40:33 +02:00

28 lines
707 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
export type FindKeyContains = <T>(map: Map<string, T>, text: string) => T | undefined;
const findKeyContainsInjectable = getInjectable({
id: "find-key-contains",
instantiate: (): FindKeyContains => {
return <T>(map: Map<string, T>, text: string) => {
const entries = map.entries();
for (const [key, value] of entries) {
if (key.includes(text)) {
return value;
}
}
return undefined;
};
},
});
export default findKeyContainsInjectable;