mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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>
28 lines
707 B
TypeScript
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;
|