Skip to content

Instantly share code, notes, and snippets.

View utsav-dhimmar's full-sized avatar

Utsav Dhimmar utsav-dhimmar

  • India
  • 08:47 (UTC +05:30)
View GitHub Profile
// Directly injecting in Array prototype so function is avialbale to all array.
// mapFunctionPolyFill is name of the function
// i just assign function that provider own implemention of map function
// cb is a callback function that will execute against the each array element
Array.prototype.filterFunctionPolyFill = function (cb) {
const output = [];// store the result of cb function
const arrLength = this.length; // length of the array in which cb function is called
// we need to call cb function for each element in array
for (let i = 0; i < arrLength; i++) {
// same as inbuilt filter function our map function had 3 parameters
@utsav-dhimmar
utsav-dhimmar / validation.ts
Last active October 30, 2025 10:42
Gist of common function used in development
// zod validation with any type of schema
import type { z, ZodIssue, ZodObject, ZodRawShape } from "zod";
type ValidationResult<T> =
| {
success: true;
data: T;
}
| {
success: false;
1. Posting terminal postman