Skip to content

Instantly share code, notes, and snippets.

Avatar

Roger Rkokie

View GitHub Profile
@Rkokie
Rkokie / deepClone.ts
Created Mar 25, 2021
deepClone class with typescript
View deepClone.ts
export function deepClone<T>(obj: any): T {
if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) {
return obj;
}
const clone = obj instanceof Date ? new Date(obj) : new obj.constructor();
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
obj.isActiveClone = null;
@Rkokie
Rkokie / LongPressEventHandler.ts
Last active Feb 28, 2020
Angular long press events
View LongPressEventHandler.ts
import {EventEmitter} from '@angular/core';
var DOWN_EVENT = 'pointerdown';
var MOVE_EVENT = 'pointermove';
var UP_EVENT = 'pointerup';
var CANCEL_EVENT = 'pointercancel';
if (!('PointerEvent' in window)) {
DOWN_EVENT = 'touchstart';
MOVE_EVENT = 'touchmove';