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 environment = { | |
| type: 'prod', | |
| variables: { | |
| api: 'some-url', | |
| port: '8080' | |
| } | |
| } | |
| const { | |
| type: envType, // we extract "type" and call it "envType" here |
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 client = {name: 'John', login: 'john45', secretKey: 'xyz123'}; | |
| const {secretKey, ...clientData} = client; | |
| clientData // {name: 'John', login: 'john45'}; |
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 expandObjWithStatus(obj, condition) { | |
| return { | |
| ...obj, | |
| ...(condition && { | |
| status: 'modified' | |
| }) | |
| } | |
| } |
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
| @Component({}) | |
| export class AppComponent { | |
| readonly noneMessage = "nothing"; | |
| readonly selectSeat$ = new Subject<number>(); | |
| readonly selectedMessage$ = this.selectSeat$.pipe( | |
| scan(registerSeats, new Set<number>()), | |
| startWith(new Set<number>()), | |
| map(set => (set.size ? Array.from(set).join(", ") : this.noneMessage)), |
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 {DOCUMENT} from '@angular/common'; | |
| import {inject, InjectionToken} from '@angular/core'; | |
| import {fromEvent, Observable} from 'rxjs'; | |
| import {distinctUntilChanged, map, share, startWith} from 'rxjs/operators'; | |
| export const PAGE_VISIBILITY = new InjectionToken<Observable<boolean>>( | |
| 'Shared Observable based on `document visibility changed`', | |
| { | |
| factory: () => { | |
| const documentRef = inject(DOCUMENT); |
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 pageVisibility$ = fromEvent(documentRef, 'visibilitychange').pipe( | |
| startWith(0), | |
| map(() => documentRef.visibilityState !== 'hidden'), | |
| distinctUntilChanged(), | |
| ); |
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
| { | |
| "scripts": { | |
| "build": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --configuration=production" | |
| } | |
| } |
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 { inject, InjectionToken } from '@angular/core'; | |
| // from https://github.com/ng-web-apis/common | |
| import { USER_AGENT } from '@ng-web-apis/common'; | |
| // https://stackoverflow.com/a/11381730/2706426 http://detectmobilebrowsers.com/ | |
| const firstRegex = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/; | |
| const secondRegex = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go |
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
| /** | |
| * Returns current active element, including shadow dom | |
| * | |
| * @return element or null | |
| */ | |
| export function getNativeFocused(documentRef: Document): Element | null { | |
| if (!documentRef.activeElement || !documentRef.activeElement.shadowRoot) { | |
| return documentRef.activeElement; | |
| } |
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
| @Injectable({ providedIn: 'root' }) | |
| export class StaticRequestService { | |
| private readonly cache = new Map<string, Observable<string>>(); | |
| request(url: string): Observable<string> { | |
| const cache = this.cache.get(url); | |
| if (cache) { | |
| return cache; | |
| } |
NewerOlder