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

safely-try

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safely-try

An elegant try-catch replacement for JavaScript / TypeScript

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
8.2K
-12.31%
Maintainers
1
Weekly downloads
 
Created
Source

safely-try

Test npm

safelyTry() is a type-safe elegant try-catch replacement for JavaScript / TypeScript inspired by Go error handling.

Installation

npm i --save safely-try

Usage

Instead of using ugly native try-catch like this

let result;
try {
  result = somethingMightThrowException();
} catch(e) {
  handleTheError(e);
}

you can use safelyTry to do something like this

import safelyTry from 'safely-try';

const { data: result, error } = safelyTry(somethingMightThrowException);
if (error) {
  handleTheError(error);
  return;
}

or you can use safelyTryTuple to do something like this

import { safelyTryTuple as st } from 'safely-try';

const [result, error] = st(somethingMightThrowException);
if (error) {
  handleTheError(error);
  return;
}

Screenshots

Type inference works with Language Server Protocol (LSP) in your favorite IDE

Type inference works with LSP

Two screenshots were taken from Visual Studio Code and combined with Nano Banana Pro

Keywords

safely

FAQs

Package last updated on 03 Jan 2026

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