New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rustic-error

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rustic-error - npm Package Compare versions

Comparing version

to
0.1.0

src/result/index.ts

14

dist/index.d.ts

@@ -0,2 +1,14 @@

type Result<T, E> = ResultOk<T> | ResultFail<E>;
type ResultOk<T> = {
ok: true;
value: T;
};
type ResultFail<E> = {
ok: false;
error: E;
};
export { }
declare function ok<T, E>(value: T): Result<T, E>;
declare function error<T, E>(error: E): Result<T, E>;
export { Result, error, ok };

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";
"use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var o in t)u(r,o,{get:t[o],enumerable:!0})},s=(r,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of n(t))!l.call(r,e)&&e!==o&&u(r,e,{get:()=>t[e],enumerable:!(p=f(t,e))||p.enumerable});return r};var x=r=>s(u({},"__esModule",{value:!0}),r);var i={};m(i,{error:()=>T,ok:()=>E});module.exports=x(i);function E(r){return{ok:!0,value:r}}function T(r){return{ok:!1,error:r}}0&&(module.exports={error,ok});
{
"name": "rustic-error",
"version": "0.0.1",
"version": "0.1.0",
"description": "Robust and type-safe error management inspired by Rust's Result pattern",

@@ -5,0 +5,0 @@ "author": "Bluzzi",

# Rustic Error
Robust and type-safe error management inspired by Rust's Result pattern.
Robust and type-safe error management inspired by Rust's Result pattern.
## Example
```ts
function divide(a: number, b: number): Result<number, string> {
if (b === 0) return error("Division by zero");
return ok(a / b);
}
const foo = divide(1 / 2);
if (foo.ok) {
console.log("Result", foo.value);
} else {
console.log("Error", foo.error);
}
```

@@ -1,1 +0,1 @@

// TODO
export * from "#/result";

Sorry, the diff of this file is not supported yet