Skip to content

Instantly share code, notes, and snippets.

View itaimoorali's full-sized avatar
👑
KING in the NORTH!

Taimoor Ali itaimoorali

👑
KING in the NORTH!
  • Upwork
  • Lahore
View GitHub Profile
@itaimoorali
itaimoorali / AgenticTyping.vue
Created September 24, 2025 12:13
Component to render the Markdown in HTML with word by word animation
<template>
<div ref="markdownContainer" class="nav-om-v1-markdown-container"></div>
</template>
<script>
// eslint-disable-next-line import/no-extraneous-dependencies
import { marked } from "marked";
import { defineComponent } from "vue";
const unmountedHook = "destroyed";
const DAYS_MAP = {
'Mon': 0,
'Tue': 1,
'Wed': 2,
'Thur': 3,
'Fri': 4,
'Sat': 5,
'Sun': 6
};
@itaimoorali
itaimoorali / is-even.js
Last active June 30, 2022 15:13
Check if number is even without using modulus operator.
function isEven(num) {
while(num > 0) {
num -= 2;
}
return num === 0;
}
function findPairOfTarget(arr, target) {
const diffMap = {};
const pairs = [];
for(let i = 0; i < arr.length; i++) {
const diff = target - arr[i];
if (diffMap[arr[i]]) {
pairs.push([diffMap[arr[i]], arr[i]]);
}
@itaimoorali
itaimoorali / to-promise.js
Last active June 17, 2022 10:39
Convert Callback style functions to Promise
function toPromise(fn, context = {}) {
return function _toPromise(...rest) {
return new Promise((resolve, reject) => {
function handler(err, ...all) {
if (err) {
reject(err);
return;
}
resolve(...all);
}
@itaimoorali
itaimoorali / support-callback-with-promise.js
Created June 16, 2022 17:59
This adds support for callback to your promise base function
function supportCallbackWithPromise(asyncFunc) {
return function _supportPromiseWithCallback (...args) {
const callback = args[args.length - 1];
if (typeof callback !== 'function' ) {
return asyncFunc(...args);
}
asyncFunc.apply({}, args)
.then((...all) => callback(null, ...all))