Skip to content

Commit 05821c4

Browse files
committed
refactor: remove vendored neverthrow
BREAKING CHANGE: use unwrap utility rather than importing neverthrow from libjs
1 parent 7e52155 commit 05821c4

File tree

10 files changed

+16
-61
lines changed

10 files changed

+16
-61
lines changed

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
".": {
1919
"types": "./dist/index.d.ts",
2020
"import": "./dist/index.js"
21-
},
22-
"./vendor/*": {
23-
"types": "./dist/vendor/*.d.ts",
24-
"import": "./dist/vendor/*.js"
2521
}
2622
},
2723
"files": [

src/__tests__/exception.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Err } from 'neverthrow';
12
import type { Simplify } from 'type-fest';
23
import { describe, expect, expectTypeOf, it, test } from 'vitest';
34

@@ -10,7 +11,6 @@ import {
1011
RuntimeException,
1112
ValueException
1213
} from '../exception.js';
13-
import { Err } from '../vendor/neverthrow.js';
1414

1515
import type { ExceptionConstructor } from '../exception.js';
1616

src/__tests__/http.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import type { Err } from 'neverthrow';
12
import { afterEach, describe, expect, it, vi } from 'vitest';
23

34
import * as datetime from '../datetime.js';
45
import { safeFetch, waitForServer } from '../http.js';
56

6-
import type { Err } from '../vendor/neverthrow.js';
7-
87
const fetch = vi.hoisted(() => vi.fn());
98
const networkError = new Error('Network Error');
109

src/datetime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { OutOfRangeException } from './exception.js';
2-
import { err, ok } from './vendor/neverthrow.js';
1+
import { err, ok } from 'neverthrow';
2+
import type { Result } from 'neverthrow';
33

4-
import type { Result } from './vendor/neverthrow.js';
4+
import { OutOfRangeException } from './exception.js';
55

66
export type Duration = {
77
days: number;

src/exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import cleanStack from 'clean-stack';
66
import extractStack from 'extract-stack';
7+
import { err, errAsync, Result, ResultAsync } from 'neverthrow';
78
import { isErrorLike, serializeError } from 'serialize-error';
89
import stringifyObject from 'stringify-object';
910
import type { IsNever, RequiredKeysOf } from 'type-fest';
1011
import type { z } from 'zod';
1112

1213
import { objectify } from './object.js';
1314
import { indentLines } from './string.js';
14-
import { err, errAsync, Result, ResultAsync } from './vendor/neverthrow.js';
1515

1616
import type { SingleKeyMap, ToAbstractConstructor } from './types.js';
1717

src/http.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { ok, ResultAsync } from 'neverthrow';
2+
13
import { sleep } from './datetime.js';
24
import { ExceptionBuilder, RuntimeException } from './exception.js';
35
import { asyncResultify } from './result.js';
4-
import { ok, ResultAsync } from './vendor/neverthrow.js';
56

67
import type { ExceptionLike } from './exception.js';
78

src/random.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ValueException } from './exception.js';
2-
import { ok } from './vendor/neverthrow.js';
1+
import { ok } from 'neverthrow';
2+
import type { Result } from 'neverthrow';
33

4-
import type { Result } from './vendor/neverthrow.js';
4+
import { ValueException } from './exception.js';
55

66
/** Returns a random integer between `min` (inclusive) and `max` (not inclusive) */
77
export function randomInt(min: number, max: number): Result<number, typeof ValueException.Instance> {

src/range.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ValueException } from './exception.js';
2-
import { ok } from './vendor/neverthrow.js';
1+
import { ok } from 'neverthrow';
2+
import type { Result } from 'neverthrow';
33

4-
import type { Result } from './vendor/neverthrow.js';
4+
import { ValueException } from './exception.js';
55

66
/** Return an array of integers between 0 (inclusive) and `end` (not inclusive) */
77
export function range(end: number): Result<readonly number[], typeof ValueException.Instance>;

src/vendor/neverthrow.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/zod.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { ok } from 'neverthrow';
2+
import type { Result } from 'neverthrow';
13
import { z } from 'zod';
24

35
import { ValidationException } from './exception.js';
46
import { isNumberLike, parseNumber } from './number.js';
57
import { isObject } from './object.js';
6-
import { ok } from './vendor/neverthrow.js';
7-
8-
import type { Result } from './vendor/neverthrow.js';
98

109
/** Used to determine if object is of type `ZodType` independent of specific instances or library versions */
1110
export function isZodType(arg: unknown): arg is z.ZodTypeAny {

0 commit comments

Comments
 (0)