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 log = console.log; | |
/* #1 Array.prototype.fill [0.7s/10M ops] */ | |
log(Array(10).fill(0).map((_, i) => i)); | |
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
/* #2 Array.apply & Array.prototype.map [1.9s/10M ops] */ | |
log(Array.apply(null, Array(10)).map((_, i) => i)); | |
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
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
let maxSafeInteger = 2 ** 53 - 1; | |
console.log(Number.MAX_SAFE_INTEGER); // 9007199254740991 | |
console.log(maxSafeInteger); // 9007199254740991 | |
console.log(maxSafeInteger + 1); // 9007199254740992 | |
console.log(maxSafeInteger + 2); // 9007199254740992 😯 | |
let bigInteger = 2n ** 53n - 1n; | |
maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER); |
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 apiUrl = 'https://jsonplaceholder.typicode.com'; | |
const createUserEndpoint = userId => apiUrl + '/users/' + userId; | |
const createTodosEndpoint = userId => createUserEndpoint(userId) + '/todos'; | |
const createAltTodosEndpoint = userId => apiUrl + '/todos?userId=' + userId; | |
const createTimeout = seconds => new Promise( | |
(_, reject) => setTimeout(() => reject('TIMEOUT'), seconds * 1000) | |
); | |
const fetchJSON = endpoint => fetch(endpoint).then(res => res.json()); | |
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
@Directive({ | |
// tslint:disable-next-line | |
selector: 'ngx-datatable[default]', | |
exportAs: 'ngxDatatableDefault', | |
}) | |
export class NgxDatatableDefaultDirective { | |
@Input() class = 'material bordered'; | |
@HostBinding('class') | |
get classes(): string { |
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
@Directive({ | |
// tslint:disable-next-line | |
selector: 'ngx-datatable[list]', | |
exportAs: 'ngxDatatableList', | |
}) | |
export class NgxDatatableListDirective implements OnChanges, OnDestroy, OnInit { | |
private subscription = new Subscription(); | |
@Input() list: ListService; |
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
<ngx-datatable | |
[rows]="data$ | async" | |
[count]="totalCount$ | async" | |
[list]="list" | |
default | |
> | |
<!-- templates here --> | |
</ngx-datatable> |
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
<ngx-datatable | |
[rows]="data$ | async" | |
[count]="totalCount$ | async" | |
[loadingIndicator]="list.isLoading$ | async" | |
[limit]="list.maxResultCount" | |
[offset]="list.page" | |
(page)="list.page = $event.offset" | |
(sort)="sort($event)" | |
[externalPaging]="true" | |
[externalSorting]="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
import { Injectable } from '@angular/core'; | |
import { ContentStrategy } from '../strategies/content.strategy'; | |
import { generateHash } from '../utils'; | |
@Injectable({ providedIn: 'root' }) | |
export class DomInsertionService { | |
private readonly inserted = new Set<number>(); | |
insertContent<T extends HTMLScriptElement | HTMLStyleElement>( | |
contentStrategy: ContentStrategy<T>, |
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 { | |
ContentSecurityStrategy, | |
CONTENT_SECURITY_STRATEGY, | |
} from './content-security.strategy'; | |
import { DomStrategy, DOM_STRATEGY } from './dom.strategy'; | |
export abstract class ContentStrategy<T extends HTMLScriptElement | HTMLStyleElement = any> { | |
constructor( | |
public content: string, | |
protected domStrategy: DomStrategy = DOM_STRATEGY.AppendToHead(), |
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 { DomInsertionService, CONTENT_STRATEGY } from '@abp/ng.core'; | |
@Component({ | |
/* class metadata here */ | |
}) | |
class DemoComponent { | |
constructor(private domInsertionService: DomInsertionService) {} | |
ngOnInit() { | |
const scriptElement = this.domInsertionService.insertContent( |