This file contains 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
getUniques(): Hit[] { | |
const mergedHits = this.read().concat(this.previousData); | |
const hitsById = new Map(mergedHits.map(hit => [hit.id, hit]); | |
return [...mergedHitsById.values()]; | |
} |
This file contains 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
// Based on https://codereview.stackexchange.com/a/223655/145828 | |
static public IEnumerable<T> SkipLast<T>(this IEnumerable<T> data, int count) | |
{ | |
if (data == null) throw new ArgumentNullException(nameof(data)); | |
if (count <= 0) return data; | |
if (data is ICollection<T> collection) | |
return collection.Take(collection.Count - count); | |
IEnumerable<T> Skipper() |
This file contains 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 { timer, throwError, Observable } from 'rxjs'; | |
import { mergeMap } from 'rxjs/operators'; | |
export interface RetryParams { | |
maxAttempts?: number; | |
scalingDuration?: number; | |
shouldRetry?: ({ status: number }) => boolean; | |
} | |
const defaultParams: RetryParams = { |
This file contains 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 MatSidenavMock { | |
_animationStarted = new EventEmitter<AnimationEvent>(); | |
opened = false; | |
} | |
export class TdLayoutManageListComponentMock implements ILayoutTogglable { | |
get sidenav(): MatSidenav { | |
return <any>this.mockSidenav; | |
} | |
readonly mockSidenav = new MatSidenavMock(); |
This file contains 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
// Assignment compatibility. | |
string str = "test"; | |
// An object of a more derived type is assigned to an object of a less derived type. | |
object obj = str; | |
// Covariance. | |
IEnumerable<string> strings = new List<string>(); | |
// An object that is instantiated with a more derived type argument | |
// is assigned to an object instantiated with a less derived type argument. | |
// Assignment compatibility is preserved. |
This file contains 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, ClassProvider } from '@angular/core'; | |
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http'; | |
import { Observable } from 'rxjs/Observable'; | |
import { _throw } from 'rxjs/observable/throw'; | |
import 'rxjs/add/operator/catch'; | |
/** | |
* Intercepts the HTTP responses, and in case that an error/exception is thrown, handles it | |
* and extract the relevant information of it. | |
*/ |