SHARE
TWEET

Untitled

a guest Jul 21st, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const range = (from: number, to: number) => Array.from((function* () {
  2.     let i = from;
  3.     while(i <= to)
  4.         yield i++;
  5. })())
  6.  
  7. /** or even */
  8.  
  9. const fromGenerator = <T>(gen: () => Iterable<T>) => Array.from(gen())
  10.  
  11. const range = (from: number, to: number) => fromGenerator(function* () {
  12.     let i = from;
  13.     while(i <= to)
  14.         yield i++;
  15. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top