Skip to content

Instantly share code, notes, and snippets.

View dayhaysoos's full-sized avatar
🏠
Working from home

Nick DeJesus dayhaysoos

🏠
Working from home
View GitHub Profile
import React from 'react'
// Call the provided function with the provided value as the only argument,
// if the call throws an exception, return the original value, otherwise
// return the result of applying fn to val
function attempt(fn, val) {
try {
return fn(val)
} catch (e) {
return val