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
| duplicatesList = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1] | |
| cleanedList = list(set(duplicatesList)) | |
| print(cleanedList) | |
| # Output: [1, 2, 3, 4, 5] |
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
| export const useArrMem = (i, arr) => { | |
| if (arr.indexOf(i) >= 0) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
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 { isServer } from '@hasty-bazar-commerce/utils' | |
| import { useEffect, useState } from 'react' | |
| export const useSpeechRecognition = ( | |
| lang?: string, | |
| continues?: boolean, | |
| interimResults?: boolean, | |
| ) => { | |
| const [speechRecognitionState, setSpeechRecognitionState] = useState<boolean>() |
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 searchValueInArrays = <T extends any = [], K extends any = "">( | |
| values: T[], | |
| searchedValue: K | |
| ): { filteredItems: T[]; searchedValueCounts: number; searchedValue: K } => { | |
| if (values?.length) { | |
| const filteredItems = values?.filter((item) => | |
| item.includes(searchedValue) | |
| ); | |
| return { | |
| filteredItems: filteredItems, |
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
| interface IRemoveEmptyProperties { | |
| [index: string]: any; | |
| } | |
| const removeEmptyProperties = <T extends IRemoveEmptyProperties = {}>( | |
| param: T | |
| ) => { | |
| let newObject: IRemoveEmptyProperties = {}; | |
| Object.keys(param).forEach((key: any) => { | |
| if (param[key]) { |
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 localStorageController = <T extends string = "", K = "">( | |
| storageName: T, | |
| type: "GET" | "SET" | "DELETE", | |
| storageValue?: K | |
| ) => { | |
| if (global?.window !== undefined && window !== undefined) { | |
| if (type === "GET") { | |
| const fetchedValue = window.localStorage.getItem(storageName); | |
| if (fetchedValue) { | |
| return JSON.parse(fetchedValue); |