Better HN
topnewbestaskshowjobs
Log inSign up

slmgc

63 karma · joined Aug 27, 2017 (9y ago) · 15 submissions

Submissions

comment 8y ago · link · parent

Updated the readme, added a few comments, changed some names

comment 8y ago · link · parent

Added a FAQ section: https://github.com/slmgc/Nothing#faq

comment 8y ago · link · parent

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

comment 8y ago · link · parent

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?

comment 8y ago · link · parent

I agree, examples can be (and will be) improved with additional comments.

comment 8y ago · link · parent

I've seen this one: https://github.com/GoogleChrome/proxy-polyfill

comment 8y ago · link · parent

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.

comment 8y ago · link · parent

Nope, hint won't help here as it gets `default` instead of `number`.

9.

Show HN: Nothing.js – A chainable mock object which always returns itself(github.com ↗)

89 points · by slmgc · 8y ago · 40 comments

10.

Show HN: React-Hint v3 – 140LoC Tooltip Component for React, Preact and Inferno(react-hint.js.org ↗)

2 points · by slmgc · 9y ago · discuss

comment 9y ago · link · parent

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})

comment 9y ago · link · parent

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.

comment 9y ago · link · parent

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 :)

comment 9y ago · link · parent

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.

15.

Show HN: React-hint – 150LoC Tooltip Component for React, Preact and Inferno(github.com ↗)

37 points · by slmgc · 9y ago · 15 comments