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
import {Injectable} from '@angular/core'; | |
import {HttpClient, HttpParams} from '@angular/common/http'; | |
import {environment} from '../../../environments/environment'; | |
@Injectable() | |
export class ApiService { | |
constructor(public http: HttpClient) { } | |
refreshToken(refreshToken) { | |
return this.http.post(`${environment.refreshTokenUrl}${refreshToken}`, {isRefreshUrl: true}); |
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
const lastPickupDate = items => items | |
.filter(i => i.returnQuantity) | |
.map(i => i.pickupDate) | |
.sort((a, b) => +new Date(b) - +new Date(a)) | |
.find(i => i); | |
const orderTotal = order => { | |
const totalNormalItems = order.items | |
.filter(x => !x.shipping) | |
.reduce((prev, cur) => prev + cur.quantity * cur.price, 0) |
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
export class ModalComponent { | |
readonly escapeKeyCode = 27; | |
@Output() modalClosed = new EventEmitter(); | |
@HostListener('document:click', ['$event']) onClickHandler(event) { | |
if (this.checkBackgroundClass(event.target, 'transparent-background')) { | |
this.close(); | |
} | |
} |
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
const arr = [1, 2, 3, 4, 5, 6]; | |
// forEach() | |
arr.forEach(item => { | |
console.log(item); // output: 1 2 3 4 5 6 | |
}); | |
// includes() |
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
// dog example | |
const dog = () => { | |
const sound = 'Where are my testicles, Summer?'; | |
return { | |
talk: () => console.log(sound) | |
} | |
} | |
const snuffles = dog(); | |
snuffles.talk(); |
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
console.time("Promise flow"); | |
const promises = [ | |
Promise.resolve(console.log("Promises array has begun executing")), | |
new Promise((resolve) => | |
setTimeout(() => resolve(console.log("Initial Promise resolving after:", 5000)), 5000) | |
)]; | |
Promise.all(promises).then(() => console.timeEnd("Promise flow")) |
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
// hoisting (don't declare with var, use let/const instead) | |
// comparing objects (reference vs primitive) | |
// higher order functions (pass function as an argument, return with a function) | |
// data storing in functions (implement add, retrieve functions) | |
// Promises with async/await Promise.all([promise1, promise2]); | |
// Array . map filter reduce | |
// Object . keys entries values | |
// Array . sort find forEach some every includes | |
// Spread, Rest operators: const rest = (...args) => args; |
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
Creation: from, fromPromise, fromEvent, of | |
Combination: combineLatest, concat, merge, startWith , withLatestFrom, zip | |
Filtering: debounceTime, distinctUntilChanged, filter, take, takeUntil | |
Transformation: bufferTime, concatMap, map, mergeMap, scan, switchMap | |
Utility: tap | |
Multicasting: share |
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
/* | |
Example usage: | |
@include animation(10s, 5s, changecolour) | |
*/ | |
@mixin animation ($delay, $duration, $animation) { | |
-webkit-animation-delay: $delay; | |
-webkit-animation-duration: $duration; | |
-webkit-animation-name: $animation; | |
-webkit-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ |
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
const pagination = (c, m) => { | |
let current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |