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
| export function autocast<T>(type: {new (): T}) { | |
| return function(target: any, key: string) { | |
| makeAutocast(target, key, (newVal: any) => { | |
| if (newVal === undefined) { | |
| return undefined; | |
| } | |
| if (newVal instanceof type) { | |
| return newVal; | |
| } | |
| return Object.assign(new type(), newVal); |
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 INIT_METHODS = new Map<any, string[]>(); | |
| type InitMethodDescriptor = TypedPropertyDescriptor<() => void> | |
| | TypedPropertyDescriptor<() => Promise<void>>; | |
| export function init(target: any, key: string, _descriptor: InitMethodDescriptor) { | |
| if (!INIT_METHODS.has(target)) { | |
| INIT_METHODS.set(target, []); | |
| } | |
| INIT_METHODS.get(target)!.push(key); |
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 makePropertyMapper<T>(prototype: any, key: string, mapper: (value: any) => T) { | |
| const values = new Map<any, T>(); | |
| Object.defineProperty(prototype, key, { | |
| set(firstValue: any) { | |
| Object.defineProperty(this, key, { | |
| get() { | |
| return values.get(this); | |
| }, | |
| set(value: any) { | |
| values.set(this, mapper(value)); |
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 {Locator} from "protractor/built/locators"; | |
| declare module "protractor/built/locators" { | |
| export interface ProtractorBy { | |
| marker(marker: string, parentElement?: Node): Locator; | |
| } | |
| } |
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
| /* Run this during setup */ | |
| beforeAll(() => { | |
| jasmine.addMatchers({ | |
| toBeInstanceOf: function() { | |
| return { | |
| compare: function(actual: any, expected: {new (...args: any[]): any}) { | |
| const pass = actual instanceof expected; | |
| return { | |
| pass, |
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
| yarn add express # or 'npm install express' | |
| echo 'var express = require("express"); | |
| var app = express(); | |
| app.use("/", express.static(__dirname)); | |
| app.listen(3001);' > serve.js | |
| node serve.js |
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
| <template> | |
| <p>Result:</p> | |
| <compose view.bind="message" containerless></compose> | |
| <hr> | |
| <label for="replaceTimeout1">Ms before first replacement</label> | |
| <input type="number" value.bind="replaceTimeout1" id="replaceTimeout1"/> | |
| <hr> | |
| <label for="replaceTimeout2">Ms before second replacement</label> | |
| <input type="number" value.bind="replaceTimeout2" id="replaceTimeout2"/> |
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 {BackendService} from "./backend"; | |
| export class PollerService { | |
| constructor(private backendService: BackendService) { | |
| } | |
| static readonly INTERVAL = { | |
| SHORT: 1000, | |
| STANDARD: 2000, |
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
| <template> | |
| <require from="./registration-form"></require> | |
| <registration-form></registration-form> | |
| </template> |