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
| # DigiExpress, Debounce (Core JS → React Hook) — #09 | |
| ## Part A — Implement `debounce` | |
| **Goal:** Write a **pure JavaScript** `debounce(fn, wait, options?)` that delays invoking `fn` until `wait` ms since the last call. | |
| **Signature** | |
| ```js | |
| /** | |
| * @param {Function} fn |
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
| DELIMITER $$ | |
| CREATE FUNCTION gregorian_to_jalali(gregorian_datetime DATETIME) | |
| RETURNS VARCHAR(19) | |
| DETERMINISTIC | |
| BEGIN | |
| -- Variable declarations | |
| DECLARE adjusted_datetime DATETIME; | |
| -- Gregorian date components |
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
| DELIMITER $$ | |
| CREATE FUNCTION jalali_to_gregorian(jalali_datetime VARCHAR(19)) | |
| RETURNS VARCHAR(19) | |
| DETERMINISTIC | |
| BEGIN | |
| -- Jalali date and time components | |
| DECLARE jy INT; -- Year | |
| DECLARE jm INT; -- Month | |
| DECLARE jd INT; -- Day |
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
| -- Drop the function if it already exists | |
| DROP FUNCTION IF EXISTS jalali_to_gregorian(jalali_datetime VARCHAR, end_of_day BOOLEAN); | |
| -- Create the jalali_to_gregorian function | |
| CREATE OR REPLACE FUNCTION jalali_to_gregorian(jalali_datetime VARCHAR, end_of_day BOOLEAN) | |
| RETURNS TIMESTAMP WITHOUT TIME ZONE AS | |
| $$ | |
| DECLARE | |
| -- Jalali date and time components | |
| jy INT; |
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
| CREATE OR REPLACE FUNCTION gregorian_to_jalali(gregorian_datetime TIMESTAMPTZ) | |
| RETURNS TEXT AS $$ | |
| DECLARE | |
| -- Adjusted datetime in Tehran time (without time zone) | |
| adjusted_datetime TIMESTAMP; | |
| -- Gregorian date components | |
| gy INTEGER; -- Year | |
| gm INTEGER; -- Month | |
| gd INTEGER; -- Day |
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 type Implements<T, U extends T> = {} | |
| type APIBasicDataResponse<Type> = { | |
| type: Type; | |
| id: string; | |
| }; | |
| type APILinkObject = { | |
| href: string; | |
| meta: object; |