This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Dropdown, Checkbox, RadioButtons, FormElement } from "@emisgroup/ui-kit-react"; | |
| const testData = [ | |
| { | |
| text: "Item one", | |
| isChecked: false, | |
| radioItem: "one", | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Tabs, ButtonGroup, Button } from "@emisgroup/ui-kit-react"; | |
| const TabComponent = () => { | |
| const tabsList = [{ text: "Tab1" }, { text: "Tab2" }, { text: "Tab3" }]; | |
| const [selectedTab, setSelectedTab] = React.useState(0); | |
| return ( | |
| <> | |
| <Tabs tabsList={tabsList} activeTab={selectedTab} onTabSelect={setSelectedTab} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { render, RenderResult } from "@testing-library/react"; | |
| import fetch from "jest-fetch-mock"; | |
| import { useGetAnnotation } from "./useGetAnnotation"; | |
| import { act } from "react-dom/test-utils"; | |
| fetch.enableMocks(); | |
| const presignedUrl = "https:/a-presigned-url"; | |
| const testXml = btoa("<something/>"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function longestPrefix(strings: string[]) { | |
| const { 0: first, [strings.length - 1]: last } = [...strings].sort(); | |
| let prefixLength = -1; | |
| for (let i = 0; i < Math.min(first.length, last.length); i++) { | |
| if (first[i] === last[i]) { | |
| prefixLength = i; | |
| } else { | |
| break; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function groupAnagrams(anagrams: string[]) { | |
| const grouped: { [name: string]: string[] } = {}; | |
| for(const anagram of anagrams) { | |
| const sorted = anagram.split('').sort().join(''); | |
| if(!grouped[sorted]) { | |
| grouped[sorted] = [anagram]; | |
| } else { | |
| grouped[sorted].push(anagram); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const addZerosCount = ({ str, zeroCount }: { str: string; zeroCount: number }) => `${str}${zeroCount || ''}` | |
| const replaceZeros = (strIncludingZeros: string) => | |
| addZerosCount( | |
| strIncludingZeros.split('').reduce((acc, ch) => (ch === '0' ? { ...acc, zeroCount: (acc.zeroCount += 1) } : { str: `${addZerosCount(acc)}${ch}`, zeroCount: 0 }), { | |
| str: '', | |
| zeroCount: 0, | |
| }) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const maxSubArray = (arr: number[], len: number) => | |
| arr.length < len | |
| ? [] | |
| : arr | |
| .map((_, index, a) => a.slice(index, index + len)) | |
| .filter(a => a.length === len) | |
| .sort((arr1, arr2) => Math.max(...arr2) - Math.max(...arr1))[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sumEveryOther = (num: number) => | |
| num | |
| .toString() | |
| .split('') | |
| .reduce((total, digit, index) => ((index + 1) % 2 === 0 ? total + parseInt(digit) : total), 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fillGap = (num: number, prev: number) => (num - prev === 2 ? `${num - 1},${num}` : `...,${num}`) | |
| const missingBits = (numbers: number[]) => | |
| `[${numbers | |
| .map((num, index, arr) => ({ num, prev: arr[index - 1] })) | |
| .map(({ num, prev }) => (num - prev === 1 ? num : fillGap(num, prev))) | |
| .join(',')}]` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const generateArrays = (n: number) => Array.from({ length: n }, (_, index) => Array.from({ length: index + 1 }, (_, innerIndex) => innerIndex + 1)) |