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 { Store as S, createStore, MetaReducer, RunOnce, RunEvery } from "./Store"; | |
| import { Reducer } from "./Reducers"; | |
| export interface StoreConfig<T> { | |
| readonly reducers: Reducer<T>[]; | |
| readonly metaReducers: MetaReducer<T>[]; | |
| readonly runOnces: RunOnce<T>[]; | |
| readonly runEverys: RunEvery<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
| use nom::{ | |
| branch::alt, | |
| bytes::complete::{tag, take_until, take_while}, | |
| character::{complete::line_ending, is_alphabetic}, | |
| combinator::{map, opt, rest}, | |
| sequence::tuple, | |
| IResult, | |
| }; | |
| use std::str::from_utf8; |
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
| Print Listener: [1, 2] | |
| SHOULD ONLY HAPPEN ONCE: [1, 2] | |
| Print Listener: [1, 2, 1] | |
| Print Listener: [1, 2, 1, 2] | |
| Print Listener: [1, 2, 1, 2, 3] | |
| Print Listener: [1, 2, 1, 2, 3, 4] | |
| Final State: [1, 2, 1, 2, 3, 4] |
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 { DatumEither, failure, initial, toRefresh } from '@nll/datum/lib/DatumEither'; | |
| import { Task } from 'fp-ts/lib/Task'; | |
| import { Errors } from 'io-ts'; | |
| import { useEffect, useState } from 'preact/hooks'; | |
| export const useTaskDatumEither = <T>(task: Task<DatumEither<Errors, T>>) => { | |
| const [state, setState] = useState<DatumEither<Errors, T>>(initial); | |
| useEffect(() => { | |
| // Setup "cancellation closure" | |
| let linked = 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 { Either } from 'fp-ts/lib/Either'; | |
| import { openDB } from 'idb'; | |
| import { array, Type } from 'io-ts'; | |
| import { from, Observable, of, throwError } from 'rxjs'; | |
| import { mergeMap } from 'rxjs/operators'; | |
| export const objectFactory = ( | |
| name: string, | |
| keyPath: string, | |
| option: 'readonly' | 'readwrite' | 'versionchange' = 'readonly', |
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 * as ts from 'typescript'; | |
| // import { Option as Option } from 'fp-ts/lib/Option'; | |
| const a = ts.createImportDeclaration( | |
| undefined, | |
| undefined, | |
| ts.createImportClause( | |
| undefined, | |
| ts.createNamedImports([ | |
| ts.createImportSpecifier( |
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 { Option } from 'fp-ts/lib/Option'; | |
| import * as t from 'io-ts'; | |
| import { createOptionFromNullable } from 'io-ts-types'; | |
| /** | |
| * Semver RegExp from https://github.com/sindresorhus/semver-regex/blob/master/index.js | |
| */ | |
| const SEMVER_REGEX = /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/gi; | |
| interface SemverBrand { |
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 { array } from 'fp-ts/lib/Array'; | |
| import { fromNullable, none, Option, some } from 'fp-ts/lib/Option'; | |
| import { fromTraversable, Lens, Optional, Prism } from 'monocle-ts'; | |
| /* Interfaces */ | |
| interface Bug { | |
| bugId: number; | |
| description: Option<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
| import { some, none, fromNullable } from 'fp-ts/lib/Option'; | |
| import { Observable } from 'rxjs' | |
| import { useEffect, useState } from 'react' | |
| const useRxjs = <T>(obs: Observable<T>, init?: T) => { | |
| const [state, setState] = useState(fromNullable(init)); | |
| const [errorState, setErrorState] = useState(none); | |
| const [completeState, setCompleteState] = useState(false); | |
| useEffect(() => obs |
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 { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, Renderer2 } from '@angular/core'; | |
| import { fromEvent, merge, Observable, Subscription } from 'rxjs'; | |
| import { catchError, map } from 'rxjs/operators'; | |
| const requestImage = (src: string) => { | |
| const img = new Image(); | |
| img.src = src; | |
| return merge(fromEvent(img, 'error'), fromEvent(img, 'load')).pipe( | |
| map(evt => { | |
| if (evt.type === 'error') { |