New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

attempt-statement

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attempt-statement

try in fp

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

attempt-statement

Never use try/catch/finally again, use attempt/rescue/else/ensure instead.

usage

const attempt = require('attempt-statement')
attempt(() => {
  consoe.log('this line throws an error because i mispelled console as consoe')
}).rescue((error) => {
  console.log('Error: ' + error)
}).else(() => {
  console.log('this will never be run because there\'s always an error')
}).ensure(() => {
  console.log('This will always be run')
}).end()
// Output:

// Error: ReferenceError: consoe is not defined
// This will always be run

above is equivalent to

let error = false
try {
  consoe.log('this line throws an error because i mispelled console as consoe')

  console.log('this will never be run because there\'s always an error')
} catch(error) {
  console.log('Error: ' + error)
  error = true
} finally {
  console.log('This will always be run')
}
// Output:

// Error: ReferenceError: consoe is not defined
// This will always be run

Keywords

attempt

FAQs

Package last updated on 24 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts