Skip to content

Instantly share code, notes, and snippets.

View IKatsuba's full-sized avatar

Igor Katsuba IKatsuba

View GitHub Profile
@IKatsuba
IKatsuba / chrome_39.js
Last active June 25, 2019 14:00 — forked from ksol/chrome_39.js
Language detection in javascript
window.navigator.language // -> "fr"
window.navigator.languages // -> ["fr-FR", "fr", "en-US", "en", "es", "de"]
window.navigator.userLanguage // -> undefined
window.navigator.browserLanguage // -> undefined
window.navigator.systemLanguage // -> undefined
const skipWaiting = () => self.skipWaiting();
const unregister = (event) => {
event.waitUntil(self.clients.claim());
self.registration.unregister()
.then(() =>
console.log('Unregistered old service worker'));
};
self.addEventListener('install', skipWaiting);
{
"version": 1,
"projects": {
"app": {
"architect": {
"stepper": {
"builder": "@ ng-builders / build: stepper",
"options": {
"targets": { // description of targets
"jest": { // target name and configuration
export interface Target {
/ **
* A list of target ids that must be completed before starting the task
*
* Differs from Schema#steps in that the task does not wait for the full
* performing dependent tasks
* /
deps?: string[];
/ **
* Purpose to fulfill
// index.ts
export function runStepper(
input: Schema,
context: BuilderContext
): BuilderOutputLike {
return buildSteps(input, context).pipe (
map(() => ({
success: true
})),
catchError(error => {
// index.ts
function buildSteps(config: Schema, context: BuilderContext): Observable<any> {
return concat(
config.steps.map(step => buildStep(step, config.targets, context))
);
}
// index.ts
function buildStep(
stepName: string,
targets: Targets,
context: BuilderContext
): Observable<any> {
const {deps = [], overrides, target, watch}: Target = targets[stepName];
const deps$ = deps.length
? combineLatest(deps.map(depName => buildStep(depName, targets, context)))
{
"$ schema": "../../@angular-devkit/architect/src/builders-schema.json",
"builders": {
"stepper": {
"implementation": "./stepper",
"schema": "./schema.json",
"description": "Stepper"
}
}
}
@IKatsuba
IKatsuba / first.ts
Created April 9, 2021 09:04
The first getter example
const items = [1, 2, 3, 4];
//before
const first = items[0];
//after
const first = items.first;
@IKatsuba
IKatsuba / last.ts
Created April 9, 2021 09:08
The last getter example
const items = [1, 2, 3, 4];
//before
const last = items[items.length - 1];
//after
const last = items.last;