Pawan Kumar

Results 129 issues of Pawan Kumar

index.js ```js index.js export function debounce(func, delay, options = {}) { const { leading = false, trailing = true } = options; let timerId; const debounced = function () {...

answer
javascript
459

index.js ```js index.js export function throttle(func, wait, options = {}) { const { leading = true, trailing = true } = options; let timer = null; let lastArgs = null;...

answer
javascript
432

index.js ```js index.js export function throttle(cb, delay = 250) { let shouldInvoke = true; return (...args) => { if (shouldInvoke) { shouldInvoke = false; cb.call(this, ...args); setTimeout(() => { shouldInvoke...

answer
javascript
20

index.js ```js index.js function curry(fn) { function curried(...args) { // If enough args and no placeholders → call fn if (args.length >= fn.length && args.every(arg => arg !== __)) {...

answer
javascript
455

index.js ```js index.js /** * @param {Function} fn - original function to curry * @returns {Function} */ export function curry(fn) { return function curried(...args) { if (args.length >= fn.length) {...

answer
javascript
449

index.ts ```ts index.ts /** * Retrieves a value from an object via a path. */ export function get( object: T, path: string | Array, defaultValue?: R, ): R | unknown...

answer
typescript
446

index.ts ```ts index.ts export function deepClone(value: T): T { if (typeof value !== "object" || value === null) { return value; } if (Array.isArray(value)) { return value.map((item) => deepClone(item)) as...

answer
typescript
442

index.ts ```ts index.ts /** * Converts a snake_case string to camelCase. */ export function snakeToCamel(input: string): string { const words = input.split("_").filter(Boolean); for (let i = 0; i < words.length;...

answer
typescript
439

index.ts ```ts index.ts export async function retryPromise(fn: () => Promise, retries: number): Promise { return fn().catch((error) => { if (retries > 0) { return retryPromise(fn, retries - 1); } throw...

answer
typescript
428

styles.css ```css styles.css body { font-family: sans-serif; } h1 { font-size: 1.5rem; } span[aria-disabled="true"] { pointer-events: none; opacity: 0.5; } ``` App.tsx ```tsx App.tsx import React, { useState, useRef }...

answer
434
react-ts