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

neverthrow

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neverthrow - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

39

dist/index.cjs.js

@@ -34,3 +34,3 @@ 'use strict';

***************************************************************************** */
/* global Reflect, Promise */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -44,3 +44,3 @@

function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, [])).next());
step((generator = generator.apply(thisArg, _arguments || [])).next());
});

@@ -68,4 +68,5 @@ }

var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }

@@ -81,3 +82,3 @@ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }

return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
}

@@ -93,2 +94,7 @@

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
class ResultAsync {

@@ -206,2 +212,13 @@ constructor(res) {

}
[Symbol.asyncIterator]() {
return __asyncGenerator(this, arguments, function* _a() {
const result = yield __await(this._promise);
if (result.isErr()) {
// @ts-expect-error -- This is structurally equivalent and safe
yield yield __await(errAsync(result.error));
}
// @ts-expect-error -- This is structurally equivalent and safe
return yield __await(result.value);
});
}
}

@@ -369,2 +386,6 @@ const okAsync = (value) => new ResultAsync(Promise.resolve(new Ok(value)));

}
// eslint-disable-next-line @typescript-eslint/no-this-alias, require-yield
*[Symbol.iterator]() {
return this.value;
}
}

@@ -432,2 +453,10 @@ class Err {

}
*[Symbol.iterator]() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// @ts-expect-error -- This is structurally equivalent and safe
yield self;
// @ts-expect-error -- This is structurally equivalent and safe
return self;
}
}

@@ -434,0 +463,0 @@ const fromThrowable = exports.Result.fromThrowable;

@@ -32,2 +32,3 @@ interface ErrorConfig {

then<A, B>(successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
[Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
}

@@ -270,2 +271,3 @@ declare const okAsync: <T, E = never>(value: T) => ResultAsync<T, E>;

_unsafeUnwrapErr(config?: ErrorConfig): E;
[Symbol.iterator](): Generator<Err<never, E>, T>;
}

@@ -293,2 +295,3 @@ declare class Err<T, E> implements IResult<T, E> {

_unsafeUnwrapErr(_?: ErrorConfig): E;
[Symbol.iterator](): Generator<Err<never, E>, T>;
}

@@ -295,0 +298,0 @@ declare const fromThrowable: typeof Result.fromThrowable;

@@ -32,3 +32,3 @@ const defaultErrorConfig = {

***************************************************************************** */
/* global Reflect, Promise */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -42,3 +42,3 @@

function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, [])).next());
step((generator = generator.apply(thisArg, _arguments || [])).next());
});

@@ -66,4 +66,5 @@ }

var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }

@@ -79,3 +80,3 @@ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }

return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
}

@@ -91,2 +92,7 @@

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
class ResultAsync {

@@ -204,2 +210,13 @@ constructor(res) {

}
[Symbol.asyncIterator]() {
return __asyncGenerator(this, arguments, function* _a() {
const result = yield __await(this._promise);
if (result.isErr()) {
// @ts-expect-error -- This is structurally equivalent and safe
yield yield __await(errAsync(result.error));
}
// @ts-expect-error -- This is structurally equivalent and safe
return yield __await(result.value);
});
}
}

@@ -367,2 +384,6 @@ const okAsync = (value) => new ResultAsync(Promise.resolve(new Ok(value)));

}
// eslint-disable-next-line @typescript-eslint/no-this-alias, require-yield
*[Symbol.iterator]() {
return this.value;
}
}

@@ -430,2 +451,10 @@ class Err {

}
*[Symbol.iterator]() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// @ts-expect-error -- This is structurally equivalent and safe
yield self;
// @ts-expect-error -- This is structurally equivalent and safe
return self;
}
}

@@ -432,0 +461,0 @@ const fromThrowable = Result.fromThrowable;

17

package.json
{
"name": "neverthrow",
"version": "8.0.0",
"version": "8.1.0",
"description": "Stop throwing errors, and instead return Results!",

@@ -13,3 +13,3 @@ "main": "dist/index.cjs.js",

"local-ci": "npm run typecheck && npm run lint && npm run test && npm run format && npm run build",
"test": "jest && npm run test-types",
"test": "vitest run && npm run test-types",
"test-types": "tsc --noEmit -p ./tests/tsconfig.tests.json",

@@ -35,16 +35,10 @@ "lint": "eslint ./src --ext .ts",

"devDependencies": {
"@babel/core": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@types/jest": "27.4.1",
"@types/node": "^18.19.39",
"@typescript-eslint/eslint-plugin": "4.28.1",
"@typescript-eslint/parser": "4.28.1",
"babel-jest": "27.5.1",
"eslint": "7.30.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-prettier": "3.4.0",
"jest": "27.5.1",
"prettier": "2.2.1",

@@ -55,5 +49,5 @@ "rollup": "^4.18.0",

"testdouble": "3.20.2",
"ts-jest": "27.1.5",
"ts-toolbelt": "9.6.0",
"typescript": "4.7.2"
"typescript": "4.7.2",
"vitest": "^2.1.3"
},

@@ -68,3 +62,6 @@ "keywords": [

"node": ">=18"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.24.0"
}
}
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