Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created May 1, 2017 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/18fac33500c811920a7a9f48625427ff to your computer and use it in GitHub Desktop.
Save mattpodwysocki/18fac33500c811920a7a9f48625427ff to your computer and use it in GitHub Desktop.
import { IterableX } from '../../iterable';
import { _if as ifStatic } from '../../iterable/if';
function* _if<T>(
fn: () => boolean,
thenSource: Iterable<T>,
elseSource: Iterable<T>) {
return new IterableX(ifStatic(fn, thenSource, elseSource));
}
IterableX.if = _if;
@rbuckton
Copy link

rbuckton commented May 1, 2017

Try this:

import { IterableX } from '../../iterable';
import { _if as ifStatic } from '../../iterable/if';

function* _if<T>(
    fn: () => boolean,
    thenSource: Iterable<T>,
    elseSource: Iterable<T>) {
    return new IterableX(ifStatic(fn, thenSource, elseSource));
}

IterableX.if = _if;

declare module "../../iterable" {
  namespace IterableX {
    function _if<T>(fn: () => boolean, thenSource: Iterable<T>, elseSource: Iterable<T>): IterableIterator<T>;
    export { _if as if }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment