Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Readd pipe helper

+243 -1
+6
package.json
··· 38 38 "url": "https://github.com/0no-co/wonka/issues" 39 39 }, 40 40 "license": "MIT", 41 + "jest": { 42 + "transform": { 43 + "^.+\\.tsx?$": "@sucrase/jest-plugin" 44 + } 45 + }, 41 46 "dependencies": {}, 42 47 "devDependencies": { 48 + "@sucrase/jest-plugin": "^2.2.1", 43 49 "@types/jest": "^28.1.6", 44 50 "@types/node": "^18.7.2", 45 51 "@types/zen-observable": "^0.8.3",
+1
src/index.ts
··· 4 4 export * from './sinks' 5 5 export * from './observable' 6 6 export * from './callbag' 7 + export * from './pipe'
+161
src/pipe.ts
··· 1 + import { Source } from './types'; 2 + 3 + interface UnaryFn<T, R> { 4 + (source: T): R; 5 + } 6 + 7 + /* pipe definitions for source + operators composition */ 8 + 9 + function pipe<T, A>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>): Source<A>; 10 + 11 + function pipe<T, A, B>( 12 + source: Source<T>, 13 + op1: UnaryFn<Source<T>, Source<A>>, 14 + op2: UnaryFn<Source<A>, Source<B>> 15 + ): Source<B>; 16 + 17 + function pipe<T, A, B, C>( 18 + source: Source<T>, 19 + op1: UnaryFn<Source<T>, Source<A>>, 20 + op2: UnaryFn<Source<A>, Source<B>>, 21 + op3: UnaryFn<Source<B>, Source<C>> 22 + ): Source<C>; 23 + 24 + function pipe<T, A, B, C, D>( 25 + source: Source<T>, 26 + op1: UnaryFn<Source<T>, Source<A>>, 27 + op2: UnaryFn<Source<A>, Source<B>>, 28 + op3: UnaryFn<Source<B>, Source<C>>, 29 + op4: UnaryFn<Source<C>, Source<D>> 30 + ): Source<D>; 31 + 32 + function pipe<T, A, B, C, D, E>( 33 + source: Source<T>, 34 + op1: UnaryFn<Source<T>, Source<A>>, 35 + op2: UnaryFn<Source<A>, Source<B>>, 36 + op3: UnaryFn<Source<B>, Source<C>>, 37 + op4: UnaryFn<Source<C>, Source<D>>, 38 + op5: UnaryFn<Source<D>, Source<E>> 39 + ): Source<E>; 40 + 41 + function pipe<T, A, B, C, D, E, F>( 42 + source: Source<T>, 43 + op1: UnaryFn<Source<T>, Source<A>>, 44 + op2: UnaryFn<Source<A>, Source<B>>, 45 + op3: UnaryFn<Source<B>, Source<C>>, 46 + op4: UnaryFn<Source<C>, Source<D>>, 47 + op5: UnaryFn<Source<D>, Source<E>>, 48 + op6: UnaryFn<Source<E>, Source<F>> 49 + ): Source<F>; 50 + 51 + function pipe<T, A, B, C, D, E, F, G>( 52 + source: Source<T>, 53 + op1: UnaryFn<Source<T>, Source<A>>, 54 + op2: UnaryFn<Source<A>, Source<B>>, 55 + op3: UnaryFn<Source<B>, Source<C>>, 56 + op4: UnaryFn<Source<C>, Source<D>>, 57 + op5: UnaryFn<Source<D>, Source<E>>, 58 + op6: UnaryFn<Source<E>, Source<F>>, 59 + op7: UnaryFn<Source<F>, Source<G>> 60 + ): Source<G>; 61 + 62 + function pipe<T, A, B, C, D, E, F, G, H>( 63 + source: Source<T>, 64 + op1: UnaryFn<Source<T>, Source<A>>, 65 + op2: UnaryFn<Source<A>, Source<B>>, 66 + op3: UnaryFn<Source<B>, Source<C>>, 67 + op4: UnaryFn<Source<C>, Source<D>>, 68 + op5: UnaryFn<Source<D>, Source<E>>, 69 + op6: UnaryFn<Source<E>, Source<F>>, 70 + op7: UnaryFn<Source<F>, Source<G>>, 71 + op8: UnaryFn<Source<G>, Source<H>> 72 + ): Source<H>; 73 + 74 + /* pipe definitions for source + operators + consumer composition */ 75 + 76 + function pipe<T, R>(source: Source<T>, consumer: UnaryFn<Source<T>, R>): R; 77 + 78 + function pipe<T, A, R>( 79 + source: Source<T>, 80 + op1: UnaryFn<Source<T>, Source<A>>, 81 + consumer: UnaryFn<Source<A>, R> 82 + ): R; 83 + 84 + function pipe<T, A, B, R>( 85 + source: Source<T>, 86 + op1: UnaryFn<Source<T>, Source<A>>, 87 + op2: UnaryFn<Source<A>, Source<B>>, 88 + consumer: UnaryFn<Source<B>, R> 89 + ): R; 90 + 91 + function pipe<T, A, B, C, R>( 92 + source: Source<T>, 93 + op1: UnaryFn<Source<T>, Source<A>>, 94 + op2: UnaryFn<Source<A>, Source<B>>, 95 + op3: UnaryFn<Source<B>, Source<C>>, 96 + consumer: UnaryFn<Source<C>, R> 97 + ): R; 98 + 99 + function pipe<T, A, B, C, D, R>( 100 + source: Source<T>, 101 + op1: UnaryFn<Source<T>, Source<A>>, 102 + op2: UnaryFn<Source<A>, Source<B>>, 103 + op3: UnaryFn<Source<B>, Source<C>>, 104 + op4: UnaryFn<Source<C>, Source<D>>, 105 + consumer: UnaryFn<Source<D>, R> 106 + ): R; 107 + 108 + function pipe<T, A, B, C, D, E, R>( 109 + source: Source<T>, 110 + op1: UnaryFn<Source<T>, Source<A>>, 111 + op2: UnaryFn<Source<A>, Source<B>>, 112 + op3: UnaryFn<Source<B>, Source<C>>, 113 + op4: UnaryFn<Source<C>, Source<D>>, 114 + op5: UnaryFn<Source<D>, Source<E>>, 115 + consumer: UnaryFn<Source<E>, R> 116 + ): R; 117 + 118 + function pipe<T, A, B, C, D, E, F, R>( 119 + source: Source<T>, 120 + op1: UnaryFn<Source<T>, Source<A>>, 121 + op2: UnaryFn<Source<A>, Source<B>>, 122 + op3: UnaryFn<Source<B>, Source<C>>, 123 + op4: UnaryFn<Source<C>, Source<D>>, 124 + op5: UnaryFn<Source<D>, Source<E>>, 125 + op6: UnaryFn<Source<E>, Source<F>>, 126 + consumer: UnaryFn<Source<F>, R> 127 + ): R; 128 + 129 + function pipe<T, A, B, C, D, E, F, G, R>( 130 + source: Source<T>, 131 + op1: UnaryFn<Source<T>, Source<A>>, 132 + op2: UnaryFn<Source<A>, Source<B>>, 133 + op3: UnaryFn<Source<B>, Source<C>>, 134 + op4: UnaryFn<Source<C>, Source<D>>, 135 + op5: UnaryFn<Source<D>, Source<E>>, 136 + op6: UnaryFn<Source<E>, Source<F>>, 137 + op7: UnaryFn<Source<F>, Source<G>>, 138 + consumer: UnaryFn<Source<G>, R> 139 + ): R; 140 + 141 + function pipe<T, A, B, C, D, E, F, G, H, R>( 142 + source: Source<T>, 143 + op1: UnaryFn<Source<T>, Source<A>>, 144 + op2: UnaryFn<Source<A>, Source<B>>, 145 + op3: UnaryFn<Source<B>, Source<C>>, 146 + op4: UnaryFn<Source<C>, Source<D>>, 147 + op5: UnaryFn<Source<D>, Source<E>>, 148 + op6: UnaryFn<Source<E>, Source<F>>, 149 + op7: UnaryFn<Source<F>, Source<G>>, 150 + op8: UnaryFn<Source<G>, Source<H>>, 151 + consumer: UnaryFn<Source<H>, R> 152 + ): R; 153 + 154 + function pipe() { 155 + let x = arguments[0]; 156 + for (let i = 1, l = arguments.length; i < l; i++) 157 + x = arguments[i](x); 158 + return x; 159 + } 160 + 161 + export { pipe };
+75 -1
yarn.lock
··· 558 558 dependencies: 559 559 "@sinonjs/commons" "^1.7.0" 560 560 561 + "@sucrase/jest-plugin@^2.2.1": 562 + version "2.2.1" 563 + resolved "https://registry.yarnpkg.com/@sucrase/jest-plugin/-/jest-plugin-2.2.1.tgz#659d31f34412fc9c50e6e0622298baaf27b75366" 564 + integrity sha512-5fG+kHOlfwPNi82MCvTFQdAg50YQymGbdwH9nzTA9D9FhJVHynTjadXi58gb/Ae17RMvinY0+Fglx33MB056Rg== 565 + dependencies: 566 + sucrase "^3.18.0" 567 + 561 568 "@types/babel__core@^7.1.14": 562 569 version "7.1.19" 563 570 resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460" ··· 687 694 version "5.2.0" 688 695 resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" 689 696 integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== 697 + 698 + any-promise@^1.0.0: 699 + version "1.3.0" 700 + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" 701 + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== 690 702 691 703 anymatch@^3.0.3: 692 704 version "3.1.2" ··· 924 936 resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" 925 937 integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== 926 938 939 + commander@^4.0.0: 940 + version "4.1.1" 941 + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" 942 + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== 943 + 927 944 concat-map@0.0.1: 928 945 version "0.0.1" 929 946 resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" ··· 1106 1123 version "6.0.1" 1107 1124 resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" 1108 1125 integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== 1126 + 1127 + glob@7.1.6: 1128 + version "7.1.6" 1129 + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" 1130 + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== 1131 + dependencies: 1132 + fs.realpath "^1.0.0" 1133 + inflight "^1.0.4" 1134 + inherits "2" 1135 + minimatch "^3.0.4" 1136 + once "^1.3.0" 1137 + path-is-absolute "^1.0.0" 1109 1138 1110 1139 glob@^7.1.3, glob@^7.1.4: 1111 1140 version "7.2.3" ··· 1719 1748 version "2.1.2" 1720 1749 resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" 1721 1750 integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== 1751 + 1752 + mz@^2.7.0: 1753 + version "2.7.0" 1754 + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" 1755 + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== 1756 + dependencies: 1757 + any-promise "^1.0.0" 1758 + object-assign "^4.0.1" 1759 + thenify-all "^1.0.0" 1722 1760 1723 1761 natural-compare@^1.4.0: 1724 1762 version "1.4.0" ··· 1747 1785 dependencies: 1748 1786 path-key "^3.0.0" 1749 1787 1788 + object-assign@^4.0.1: 1789 + version "4.1.1" 1790 + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" 1791 + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== 1792 + 1750 1793 once@^1.3.0: 1751 1794 version "1.4.0" 1752 1795 resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" ··· 1827 1870 resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" 1828 1871 integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== 1829 1872 1830 - pirates@^4.0.4: 1873 + pirates@^4.0.1, pirates@^4.0.4: 1831 1874 version "4.0.5" 1832 1875 resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b" 1833 1876 integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== ··· 2007 2050 version "3.1.1" 2008 2051 resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" 2009 2052 integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== 2053 + 2054 + sucrase@^3.18.0: 2055 + version "3.25.0" 2056 + resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.25.0.tgz#6dffa34e614b3347877507a4380cc4f022b7b7aa" 2057 + integrity sha512-WxTtwEYXSmZArPGStGBicyRsg5TBEFhT5b7N+tF+zauImP0Acy+CoUK0/byJ8JNPK/5lbpWIVuFagI4+0l85QQ== 2058 + dependencies: 2059 + commander "^4.0.0" 2060 + glob "7.1.6" 2061 + lines-and-columns "^1.1.6" 2062 + mz "^2.7.0" 2063 + pirates "^4.0.1" 2064 + ts-interface-checker "^0.1.9" 2010 2065 2011 2066 supports-color@^5.3.0: 2012 2067 version "5.5.0" ··· 2059 2114 glob "^7.1.4" 2060 2115 minimatch "^3.0.4" 2061 2116 2117 + thenify-all@^1.0.0: 2118 + version "1.6.0" 2119 + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" 2120 + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== 2121 + dependencies: 2122 + thenify ">= 3.1.0 < 4" 2123 + 2124 + "thenify@>= 3.1.0 < 4": 2125 + version "3.3.1" 2126 + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" 2127 + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== 2128 + dependencies: 2129 + any-promise "^1.0.0" 2130 + 2062 2131 tmpl@1.0.5: 2063 2132 version "1.0.5" 2064 2133 resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" ··· 2075 2144 integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== 2076 2145 dependencies: 2077 2146 is-number "^7.0.0" 2147 + 2148 + ts-interface-checker@^0.1.9: 2149 + version "0.1.13" 2150 + resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" 2151 + integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== 2078 2152 2079 2153 type-detect@4.0.8: 2080 2154 version "4.0.8"