Skip to content

Commit a09a6ba

Browse files
authored
Merge pull request #10 from DouglasNeuroInformatics/dev
feat: add vendored neverthrow
2 parents 9fce89d + fb63f5f commit a09a6ba

File tree

13 files changed

+72
-23
lines changed

13 files changed

+72
-23
lines changed

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@
1414
"bugs": {
1515
"url": "https://github.com/DouglasNeuroInformatics/libjs/issues"
1616
},
17-
"main": "./dist/index.js",
18-
"types": "./dist/index.d.ts",
17+
"exports": {
18+
".": {
19+
"types": "./dist/index.d.ts",
20+
"import": "./dist/index.js"
21+
},
22+
"./vendor/*": {
23+
"types": "./dist/vendor/*.d.ts",
24+
"import": "./dist/vendor/*.js"
25+
}
26+
},
1927
"files": [
2028
"dist"
2129
],

src/__tests__/exception.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Err } from 'neverthrow';
21
import type { Simplify } from 'type-fest';
32
import { describe, expect, expectTypeOf, it, test } from 'vitest';
43

54
import { BaseException, ExceptionBuilder, OutOfRangeException, ValueException } from '../exception.js';
5+
import { Err } from '../vendor/neverthrow.js';
66

77
import type { ExceptionConstructor } from '../exception.js';
88

src/__tests__/http.test.ts

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

43
import * as datetime from '../datetime.js';
54
import { safeFetch, waitForServer } from '../http.js';
65

6+
import type { Err } from '../vendor/neverthrow.js';
7+
78
const fetch = vi.hoisted(() => vi.fn());
89
const networkError = new Error('Network Error');
910

src/__tests__/result.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Err, err, Ok, ok } from 'neverthrow';
21
import { describe, expect, it } from 'vitest';
32

43
import { asyncResultify } from '../result.js';
4+
import { Err, err, Ok, ok } from '../vendor/neverthrow.js';
55

66
describe('asyncResultify', () => {
77
it('should convert a successful Result to ResultAsync', async () => {

src/datetime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { err, ok } from 'neverthrow';
2-
import type { Result } from 'neverthrow';
3-
41
import { OutOfRangeException } from './exception.js';
2+
import { err, ok } from './vendor/neverthrow.js';
3+
4+
import type { Result } from './vendor/neverthrow.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,13 +4,13 @@
44

55
import cleanStack from 'clean-stack';
66
import extractStack from 'extract-stack';
7-
import { err, errAsync, Result, ResultAsync } from 'neverthrow';
87
import stringifyObject from 'stringify-object';
98
import type { IsNever, RequiredKeysOf } from 'type-fest';
109
import type { z } from 'zod';
1110

1211
import { objectify } from './object.js';
1312
import { indentLines } from './string.js';
13+
import { err, errAsync, Result, ResultAsync } from './vendor/neverthrow.js';
1414

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

src/http.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { ok, ResultAsync } from 'neverthrow';
2-
31
import { sleep } from './datetime.js';
42
import { ExceptionBuilder, RuntimeException } from './exception.js';
53
import { asyncResultify } from './result.js';
4+
import { ok, ResultAsync } from './vendor/neverthrow.js';
65

76
import type { ExceptionLike } from './exception.js';
87

src/random.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ok } from 'neverthrow';
2-
import type { Result } from 'neverthrow';
3-
41
import { ValueException } from './exception.js';
2+
import { ok } from './vendor/neverthrow.js';
3+
4+
import type { Result } from './vendor/neverthrow.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 { ok } from 'neverthrow';
2-
import type { Result } from 'neverthrow';
3-
41
import { ValueException } from './exception.js';
2+
import { ok } from './vendor/neverthrow.js';
3+
4+
import type { Result } from './vendor/neverthrow.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/result.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Result, ResultAsync } from 'neverthrow';
1+
import { Result, ResultAsync } from './vendor/neverthrow.js';
22

33
export function asyncResultify<T, E>(fn: () => Promise<Result<T, E>>): ResultAsync<T, E> {
44
return new ResultAsync(fn());

0 commit comments

Comments
 (0)