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
| // 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 |
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
| // zod validation with any type of schema | |
| import type { z, ZodIssue, ZodObject, ZodRawShape } from "zod"; | |
| type ValidationResult<T> = | |
| | { | |
| success: true; | |
| data: T; | |
| } | |
| | { | |
| success: 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
| 1. Posting terminal postman |