2.1.0 • Published 3 years ago

noerr v2.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

noerr

Safe property reference chaining without errors.
Only TypeError can be suppressed.

Usage (Node & NPM)

npm install noerr
import noerr from 'noerr';

const a = {b: 1};
console.log(noerr(() => a.b)); // 1
console.log(noerr(() => a.b.c)); // undefined
console.log(noerr(() => a.b.c.d)); // undefined
console.log(noerr(() => a.b.c())); // undefined

noerr(() => x); // ReferenceError: x is not defined

Usage (Browser & CDN)

<script src="https://unpkg.com/noerr@latest"></script>

<script>
const noerr = NoErr.default;

const a = {b: 1};
console.log(noerr(() => a.b)); // 1
console.log(noerr(() => a.b.c)); // undefined
console.log(noerr(() => a.b.c.d)); // undefined
console.log(noerr(() => a.b.c())); // undefined

noerr(() => x); // ReferenceError: x is not defined
</script>
2.1.0

3 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago