This file contains 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 const isEqual = (obj1: unknown, obj2: unknown) => { | |
type GenericObject = { | |
[key: string]: unknown; | |
}; | |
function getType(obj: unknown) { | |
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); | |
} | |
function areArraysEqual(arr1: unknown[], arr2: unknown[]) { |
This file contains 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 const onClickOutside = (element: HTMLElement, callback: Function) => { | |
const handler = ({ target }: Event) => { | |
let currentElement = target; | |
do { | |
if (currentElement === element) { | |
return; | |
} |
This file contains 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
import { Component } from 'solid-js'; | |
import { HTMLElementEvent } from '../../@types/alltypes'; | |
import { throttle } from '../lib/helpers'; | |
interface Props { | |
className?: string; | |
children: any; | |
ref: (el: HTMLDivElement) => HTMLDivElement; | |
onScroll?: (e: HTMLElementEvent<HTMLDivElement>) => void; | |
onScrollEnd?: () => void; |
This file contains 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
const getStartOfQuarter = date => { | |
const | |
quarters = { | |
1: 1, | |
2: 4, | |
3: 7, | |
4: 10 | |
}, | |
d = date ? new Date(date) : new Date(), | |
q = Math.ceil((d.getMonth() + 1) / 3), |
This file contains 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
const out = document.querySelector('output'); | |
const plaindiv = document.querySelector('div'); | |
const absdiv = document.querySelector('div.absolute'); | |
const floatdiv = document.querySelector('div.float'); | |
const getposition = ev => { | |
let x = ev.clientX; | |
let y = ev.clientY; | |
let pos = ev.target.getBoundingClientRect(); | |
return { |
This file contains 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
const stripScripts = (s) => { | |
const div = document.createElement('div'); | |
div.innerHTML = s; | |
const scripts = div.querySelectorAll('script'); | |
for (var script of scripts) { | |
script.parentNode.removeChild(script); | |
} |
This file contains 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
const getUrlParams = (url) => { | |
const { searchParams } = new URL(url); | |
return Object.fromEntries([...searchParams.entries()]); | |
}; |
This file contains 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
const createReducer = (initialState = {}, handlers = {}) => ( | |
state = {}, | |
action = {} | |
) => | |
handlers.hasOwnProperty(action.type) | |
? handlers[action.type](state, action) | |
: { ...initialState, ...state }; | |
export default createReducer; |
This file contains 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
const API_URL = 'https://apis.google.com/js/api.js'; | |
const GOOGLE_CLIENT_ID = ''; | |
const GOOGLE_CLIENT_SCOPE = ''; | |
function loadScript(src) { | |
return new Promise((resolve, reject) => { | |
try { | |
if (!document.querySelector(`script[src="${src}"]`)) { |
This file contains 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
function processRow(row, separator) { | |
let finalVal = ""; | |
for (let j = 0; j < row.length; j++) { | |
let innerValue = row[j] === null ? "" : row[j].toString(); | |
if (row[j] instanceof Date) { | |
innerValue = row[j].toLocaleString(); | |
} |
NewerOlder