Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-results

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-results - npm Package Versions

2

3.3.0

Diff

vultix
published 3.2.1 •

Changelog

Source

v3.2.1

  • Fix regression found in Issue#24
vultix
published 3.2.0 •

Changelog

Source

v3.2.0

  • Fixes for Typescript 4.2
vultix
published 3.1.1 •

vultix
published 3.1.0 •

Changelog

Source

v3.1.0

Big thank you to @petehunt for all his work adding the Option type.

New Features

  • Added new Option<T>, Some<T>, and None types!

    • You should feel at home if you're used to working with Rust:

      import { Option, Some, None } from 'ts-results';
      
      const optionalNum: Option<number> = Some(3).map((num) => num * 2);
      
      if (optionalNum.some) {
          console.log(optionalNum.val === 6); // prints `true`
      }
      
      const noneNum: Option<number> = None;
      
      if (noneNum.some) {
          // You'll never get in here
      }
      
  • Added new Option.isOption and Result.isResult helper functions.

Other Improvements

  • Got to 100% test coverage on all code!
  • Removed uses of @ts-ignore
vultix
published 3.0.0 •

Changelog

Source

v3.0.0

Huge shout out to @Jack-Works for helping get this release out. Most of the work was his, and it would not have happened without him.

New Features

  • Ok<T> and Err<T> are now callable without new!
  • No longer breaks when calling from node
  • Tree-shakable when using tools like rollup or webpack
  • Fully unit tested
  • Added these helper functions:
    • Result.all(...) - Same as Results from previous releases. Collects all Ok values, or returns the first Err value.
    • Results.any(...) - Returns the first Ok value, or all of the Err values.
    • Result.wrap<T, E>(() => ...) - Wraps an operation that may throw an error, uses try / catch to return a Result<T, E>
    • Result.wrapAsync<T, E>(() => ...) - Same as the above, but async
  • Deprecated else in favor of unwrapOr to prefer api parity with Rust
vultix
published 2.0.1 •

Changelog

Source

v2.0.1

New Features

  • core: Added reaonly static EMPTY: Ok<void>; to Ok class.
  • core: Added reaonly static EMPTY: Err<void>; to Err class.
vultix
published 2.0.0 •

Changelog

Source

v2.0.0

This release features a complete rewrite of most of the library with one focus in mind: simpler types.

The entire library now consists of only the following:

  • Two classes: Ok<T> and Err<E>.
  • A Result<T, E> type that is a simple or type between the two classes.
  • A simple Results function that allows combining multiple results.

New Features

  • core: much simpler Typescript types
  • rxjs: added new filterResultOk and filterResultErr operators
  • rxjs: added new resultMapErrTo operator

Breaking Changes

  • core: Err and Ok now require new:
    • Before: let result = Ok(value); let error = Err(message);
    • After: let result = new Ok(value); let error = new Err(message);
  • core: map function broken into two functions: map and mapErr
    • before: result.map(value => "new value", error => "new error")
    • after: result.map(value => "newValue").mapError(error => "newError")
  • rxjs: resultMap operator broken into two operators: resultMap and resultMapErr
    • before: obs.pipe(resultMap(value => "new value", error => "new error"))
    • after: result.pipe(resultMap(value => "newValue"), resultMapError(error => "newError"))
vultix
published 2.0.0-alpha.2 •

vultix
published 2.0.0-alpha.1 •

2
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc