Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
upzylon
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
1.
▲
by
upzylon
4y ago
applyPipe is added now: https://github.com/MathisBullinger/froebel#applypipe It's included in version 0.21.0
2.
▲
by
upzylon
4y ago
It's just an identifier like any other defined in types.ts: https://github.com/MathisBullinger/froebel/blob/main/types.t... It's defined as type λ<TA extends any[] = any[], TR = any>
3.
▲
by
upzylon
4y ago
Thanks! Yes, it should work with any number of arguments. Or at least in theory it does, it seems that around 47 chained functions TypeScript will give up and stops computing the type. It's written in TypeScript v4.7.2 but I didn'
4.
▲
by
upzylon
4y ago
There isn't necessarily any issue with it besides maybe not being very maintainable. I just tried to find a generic solution for the fun of it
5.
▲
by
upzylon
4y ago
Looks like they define pipe separately for every number of arguments: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...
6.
▲
by
upzylon
4y ago
Chaining assignments and using non-ascii characters as variable names is definitely not the norm in most TypeScript projects I've seen and worked on. When I started this project it was just for my own personal use and kind of a creativ
7.
▲
by
upzylon
4y ago
Yes, every function except the first one needs to have exactly one argument. Others have also said that `pipe` is not an ideal name for the function. So perhaps renaming it to `compose` and have `pipe` be of the form `pipe(arg, funA, funB,
8.
▲
by
upzylon
4y ago
Thanks for linking the code, I meant to link to the pipe section of the README but obviously botched that and can't change it now :) I was really exited about the pipe proposal and actively followed the discussion like 4 years ago. But
9.
▲
by
upzylon
4y ago
That looks interesting, I hadn't heard of the project. Will definitely have a look at the library. But it defines its pipe function the same way RXJS does, separately for any number of arguments: function pipe<A>(a: A): A f
10.
▲
A generically typed pipe function in TypeScript
(github.com)
137 points
by
upzylon
4y ago
|
51 comments
11.
▲
by
upzylon
4y ago
When programming in a functional style, quite of often I find myself wanting to rewrite nested function calls as a chain. Hopefully at some point the proposed pipe operator will make it into JavaScript and TypeScript but for now defining a
12.
▲
by
upzylon
4y ago
Any feedback you might have would be appreciated. The library contains a bunch of utilities that I reuse between projects and thought might be worth sharing. What makes this library different from other utility libraries like e.g. Lodash is
13.
▲
Show HN: Froebel–a strictly typed utility library for Deno, Node, and Browsers
(github.com)
16 points
by
upzylon
4y ago
|
2 comments
14.
▲
Show HN: A website where you can watch and listen to sorting algorithms
(sort.bullinger.dev)
8 points
by
upzylon
5y ago
|
4 comments
15.
▲
Show HN: A little multithreaded ray tracer written in a few lines of TypeScript
(github.com)
2 points
by
upzylon
5y ago
|
0 comments
16.
▲
Show HN: SnatchBlock – a strictly typed TypeScript utility library (WIP)
(github.com)
1 points
by
upzylon
5y ago
|
0 comments
17.
▲
by
upzylon
5y ago
There definitely are valid use cases for a Map, and even more now that we have WeakMaps (e.g. associating data DOM nodes). Or mapping functions to values, e.g. something like this: const returnCache = new Map<() => any, any>()
18.
▲
by
upzylon
5y ago
If the problem is just that you want to use non-primitive keys, that's what Maps are for. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
19.
▲
LCH colors in CSS: what, why, and how?
(lea.verou.me)
4 points
by
upzylon
5y ago
|
0 comments