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
/** | |
* Angular method decorator to caculate the time taken to execute a function | |
* | |
*/ | |
export function timer( | |
prototype: any, | |
name: string, | |
descriptor: PropertyDescriptor | |
) { |
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
/** | |
* Angular class decorator to auto unsubscribe from all subscriptions | |
* | |
*/ | |
export function unsubscribe() { | |
return function (constructor: any) { | |
const originalDestroy = constructor.prototype.ngOnDestroy; | |
constructor.prototype.ngOnDestroy = function () { |
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
/** | |
* Angular method decorator to implement setTimeout | |
* | |
*/ | |
export function timeout(milliseconds: number = 0) { | |
return function ( | |
prototype: any, | |
name: string, | |
descriptor: PropertyDescriptor |
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
/** | |
* Angular read only property decorator | |
* | |
*/ | |
export function readOnly(prototype: any, name: string) { | |
Object.defineProperty(prototype, name, { | |
writable: 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
/** | |
* Angular method decorator to implement throttle | |
* | |
*/ | |
import t from 'lodash/throttle'; | |
export function throttle(milliseconds: number = 500) { | |
return function ( | |
prototype: any, |
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
/** | |
* Angular method decorator to implement debounce | |
* | |
*/ | |
import d from 'lodash/debounce'; | |
export function debounce(milliseconds: number = 500) { | |
return function ( | |
prototype: any, |
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
/** | |
* Angular class decorator to track the page visit | |
* | |
*/ | |
import { Injector } from '@angular/core'; | |
import { AnalyticService } from '../analytics.service'; | |
export function PageAnalytics(pageName: string) { | |
return function (constructor: Function) { |
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
function getSelectorByText( | |
node: HTMLElement, | |
text: string | |
): HTMLElement | undefined { | |
if (node?.innerHTML?.trim() === text) { | |
return node; | |
} | |
for (let i = 0; i < node.children.length; i++) { | |
const found = getSelectorByText(node.children[i] as HTMLElement, text); |
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
// Module dependencies | |
var express = require('express'), | |
mysql = require('mysql'); | |
// Application initialization | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
user : 'root', |