We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an array nested within an array. What is the correct way to write a recursive function? I'm just new to using the library fp-ts
I wrote a function. Which makes the flag isShow true.
Link to example https://stackblitz.com/edit/typescript-39acrw?file=index.ts
import { pipe } from 'fp-ts/function'; import * as A from 'fp-ts/Array'; import * as S from 'fp-ts/Separated'; interface Ichildren { isActive: boolean; name: string; key: string; } interface IMenu { id: number; title: string; children: Ichildren[]; } interface IgetSidebar { menu: IMenu[]; isAbility: boolean; } const menus: IMenu[] = [ { title: 'title 1', id: 1, children: [ { name: 'children 2', key: 'children1', isActive: true, }, ], }, { title: 'title 2', id: 2, children: [ { name: 'children 21', key: 'children21', isActive: true, }, { name: 'children 22', key: 'children22', isActive: false, }, ], }, { title: 'title 3', id: 2, children: [ { name: 'children 3', key: 'children3', isActive: true, }, ], }, ]; const getSidebar = ({ menu, isAbility }: IgetSidebar) => pipe( menu, A.map((el) => ({ ...el, children: pipe( el.children, A.partition((children) => { if (children.key === 'children22') { return (children.isActive = isAbility); } return children.isActive; }), S.right ), })) ); console.log( getSidebar({ menu: menus, isAbility: true, }) );
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have an array nested within an array. What is the correct way to write a recursive function? I'm just new to using the library fp-ts
I wrote a function. Which makes the flag isShow true.
Link to example https://stackblitz.com/edit/typescript-39acrw?file=index.ts
The text was updated successfully, but these errors were encountered: