// EXPECTED
new Set(...document.body.classList)
> {"l", "o", "g", "e", "d", …}
// ACTUAL
new (Set.bind.apply(Set, [void 0].concat(document.body.classList)))();
> {"logged-in", "env-production", "emoji-size-boost"}
// FIX
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
type GetValTypeIfNot<T, D> = T extends { [k: string]: infer V } ? (V extends D ? never : T) : never; | |
interface IndexableByDeletedProp { | |
__IndexableByDeletedProp: true; | |
} | |
type IndexedBy<TA extends Array<any>, K extends keyof T, T = TA[number]> = { | |
[P in T[K]]: GetValTypeIfNot< | |
{ [PP in keyof T]: T[K] extends P ? T[PP] : IndexableByDeletedProp }, | |
IndexableByDeletedProp |
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
type DecoratorFactory<T, D extends Function> = (config: T) => D; | |
type PropertyDecoratorFactory<T> = DecoratorFactory<T, PropertyDecorator>; | |
function extendDecoratorConfig<C>(decoratorFactory: PropertyDecoratorFactory<C>) { | |
return <C_CUSTOM = {}, C_NEW extends C = C>( | |
configFactory: (config: C & C_CUSTOM) => C_NEW, | |
) => (userConfig?: C & C_CUSTOM) => decoratorFactory(configFactory(userConfig)); | |
} | |
function Property(config?: { required?: boolean }): PropertyDecorator { |
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 with branching | |
function giveAppleOrOrange(condition) { | |
if (condition) { | |
return 'apple'; | |
} else { | |
return 'orange'; | |
} | |
} | |
// function without branching |
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
// Module for loading Faket.js | |
let _faker: Faker.FakerStatic; | |
/** | |
* Load and cache Faker.js with just english locale | |
*/ | |
export function faker(): Faker.FakerStatic { | |
if (!_faker) { | |
_faker = require('faker/locale/en'); |
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 { setOutputsMock } from './testing-helpers'; | |
declare module './testing-helpers' { | |
interface MockedOutput extends jest.Mock {} | |
} | |
setOutputsMock(() => jest.fn()); |
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
{"contents":{"launch":{"version":"0.2.0","configurations":[{"type":"chrome","request":"attach","name":"Attach: ng serve","port":9222,"webRoot":"${workspaceFolder}"},{"type":"chrome","request":"launch","name":"ng serve","url":"http://localhost:4200","webRoot":"${workspaceFolder}"},{"type":"node","request":"attach","name":"Attach by Process ID","processId":"${command:PickProcess}"},{"type":"node","request":"launch","name":"Launch Check Localizations","program":"${workspaceFolder}/scripts/check-localizations.js","args":["--tsconfig","src/tsconfig.app.json","--intl-files","../src/assets/locales/en-gb.json","--intl-files","../src/assets/locales/de-de.json","--check-intl"]}]}},"overrides":[],"keys":["launch.version","launch.configurations"]} |
This is a draft idea to reduce boilerplate code when writing action creators for redux.
It simplifies the proces to bare minimum and provides shourtcuts for comminly used patterns like async
action
(where for one action you need to have 2 more that represent success or failure).
The idea here is to have an abstraction to safely run browser dependent code in non browser-native environment (like webworker or server-side) without breaking the app and not changing any application logic code.
import { Injectable, NgModule, PLATFORM_INITIALIZER, Provider } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {