slmgc
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Monday April 02, 2018 @01:57AM (#16732634)
Updated the readme, added a few comments, changed some names
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Monday April 02, 2018 @01:47AM (#16732586)
Added a FAQ section: https://github.com/slmgc/Nothing#faq
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @07:37PM (#16725768)
Wrapping you code into a try/catch block decreases performance even more, you don't want to do that. You might want to check it out: https://github.com/GoogleChrome/proxy-polyfill
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @04:13PM (#16724953)
Yep, it's way easier to implement in some other languages. Btw, is it callable as well? Can you do Whatever.new().foo.bar().baz with it?
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @03:19PM (#16724691)
I agree, examples can be (and will be) improved with additional comments.
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @02:37PM (#16724495)
I've seen this one: https://github.com/GoogleChrome/proxy-polyfill
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @02:17PM (#16724400)
idx requires a transpilation step.
> you try to access a property on a value that's null (which you think isn't null), and instead of getting an error, nothing happens
You can check for Nothing if you know you shouldn't get one. It's not about swallowing errors, it's about removing try/catch and all this `a && a.b && a.b.c && a.b.c()` boilerplate code.
> Optional chaining[2] would add this to JS at the language level by using ?. as the operator
But it's not there yet and it will require a transpilation step for quite some time before all the major browsers will introduce this feature.
Nothing returns "safe" default values instead of null/undefined, which might come in useful in some cases. Also, it can be used in unit tests to mock some deeply-nested constructs.
Re:Show HN: Nothing.js – A chainable mock object which always returns ...
on Saturday March 31, 2018 @02:10PM (#16724368)
Nope, hint won't help here as it gets `default` instead of `number`.
Show HN: React-Hint v3 – 140LoC Tooltip Component for React, Preact and Inferno
Re:Show HN: React-hint – 150LoC Tooltip Component for React, Preact an...
on Sunday August 27, 2017 @04:39PM (#15112599)
Yep, it works just fine without Preact's compatibility layer:
import {h, Component} from 'preact'
import {ReactHintFactory} from 'react-hint'
import 'react-hint/css/index.css'
const ReactHint = ReactHintFactory({createElement: h,
Component})
Re:Show HN: React-hint – 150LoC Tooltip Component for React, Preact an...
on Sunday August 27, 2017 @04:34PM (#15112580)
I made this library a while ago, long before all this hype about React's license (which was with the questionable clause from the beginning). I added support for Preact as I liked the minimalistic style of Preact, used it in my own projects and Jason was really responsive solving Preact's compatibility issues. Later on, Dominic asked if I want to add support for Inferno, which I did. I really love that there are different library implementations with compatible API, so you can choose a proper solution based on its pros/cons.
Re:Show HN: React-hint – 150LoC Tooltip Component for React, Preact an...
on Sunday August 27, 2017 @04:11PM (#15112459)
Nope, it's a pure coincidence as I've made the button style just to record the GIF. As for the tooltip itself, it uses a generic style, but thanks for the link to your project, looks nice :)
Re:Show HN: React-hint – 150LoC Tooltip Component for React, Preact an...
on Sunday August 27, 2017 @04:06PM (#15112430)
That's a good question, thanks! I didn't think about that, but, surely, this functionality should be added. I will try to research what would be the best solution for accessibility.