Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant due to optional chaining #6

Open
jmadelaine opened this issue Nov 1, 2021 · 1 comment
Open

Redundant due to optional chaining #6

jmadelaine opened this issue Nov 1, 2021 · 1 comment

Comments

@jmadelaine
Copy link

What are the benefits of this library over optional chaining?

For example:

const a = { b: { c: 1 } }

console.log(a?.b?.c) // 1
console.log(a?.d?.c) // undefined - no error thrown
@EnixCoda
Copy link
Owner

EnixCoda commented Nov 1, 2021

Hi @jmadelaine

No obvious benefits, I made it for fun. It has similar behavior to optional chaining in most cases.

const $a = safeTouch(a)

console.log($a.b.c()) // 1
console.log($a.d.c()) // undefined - no error thrown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants