mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-12-26 07:23:03 +03:00
8679af38a2
* add: deeplinks * add: enhanced pagination for large datasets * add more meta tags * add data to initial state * remove preview page, instead link directly into the list
24 lines
641 B
TypeScript
24 lines
641 B
TypeScript
import { MetaData, NixType } from "../models/nix";
|
|
import { getTypes } from "./lib";
|
|
|
|
export const byType =
|
|
({ to, from }: { to: NixType; from: NixType }) =>
|
|
(data: MetaData): MetaData => {
|
|
if (to === "any" && from === "any") {
|
|
return data;
|
|
} else {
|
|
return data.filter(
|
|
// TODO: Implement proper type matching
|
|
({ name, fn_type }) => {
|
|
if (fn_type) {
|
|
const parsedType = getTypes(name, fn_type);
|
|
return (
|
|
parsedType.args.includes(from) && parsedType.types.includes(to)
|
|
);
|
|
} else {
|
|
return to === "any" && from === "any";
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}; |