Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use recommended TS settings for libraries #1136

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased]

- Use `node16` module resolution setting (recommended setting for libraries that run in
both browsers and Node environments)

## [2.4.0] - 2025-02-19

- Add second param `index` to all predicates. This will make operations like
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
"version": "2.4.0",
"description": "A JavaScript port of Python's awesome itertools standard library",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/nvie/itertools.git"
},
"author": "Vincent Driessen",
"homepage": "https://github.com/nvie/itertools#readme",
"bugs": {
"url": "https://github.com/nvie/itertools/issues"
},
"type": "module",
"types": "./dist/index.d.cts",
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"exports": {
".": {
"import": {
Expand Down Expand Up @@ -44,11 +35,6 @@
"LICENSE",
"README.md"
],
"keywords": [
"itertool",
"itertools",
"node-itertools"
],
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.3",
"@eslint/js": "^9.20.0",
Expand All @@ -68,6 +54,20 @@
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.6"
},
"author": "Vincent Driessen",
"repository": {
"type": "git",
"url": "git+https://github.com/nvie/itertools.git"
},
"homepage": "https://github.com/nvie/itertools#readme",
"bugs": {
"url": "https://github.com/nvie/itertools/issues"
},
"keywords": [
"itertool",
"itertools",
"node-itertools"
],
"githubUrl": "https://github.com/nvie/itertools",
"sideEffects": false
}
6 changes: 3 additions & 3 deletions src/builtins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { count, ifilter, imap, izip, izip3, takewhile } from "./itertools";
import type { Predicate, Primitive } from "./types";
import { identityPredicate, keyToCmp, numberIdentity, primitiveIdentity } from "./utils";
import { count, ifilter, imap, izip, izip3, takewhile } from "./itertools.js";
import type { Predicate, Primitive } from "./types.js";
import { identityPredicate, keyToCmp, numberIdentity, primitiveIdentity } from "./utils.js";

/**
* Returns the first item in the iterable for which the predicate holds, if
Expand Down
8 changes: 4 additions & 4 deletions src/custom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { find } from "./builtins";
import { ifilter, imap } from "./itertools";
import { flatten } from "./more-itertools";
import type { Predicate } from "./types";
import { find } from "./builtins.js";
import { ifilter, imap } from "./itertools.js";
import { flatten } from "./more-itertools.js";
import type { Predicate } from "./types.js";

function isNullish<T>(x: T): x is NonNullable<T> {
return x != null;
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export {
sum,
zip,
zip3,
} from "./builtins";
export { compact, compactObject, first, flatmap, icompact } from "./custom";
} from "./builtins.js";
export { compact, compactObject, first, flatmap, icompact } from "./custom.js";
export {
chain,
compress,
Expand All @@ -42,7 +42,7 @@ export {
zipLongest,
zipLongest3,
zipMany,
} from "./itertools";
} from "./itertools.js";
export {
chunked,
dupes,
Expand All @@ -56,5 +56,5 @@ export {
take,
uniqueEverseen,
uniqueJustseen,
} from "./more-itertools";
export type { Predicate, Primitive } from "./types";
} from "./more-itertools.js";
export type { Predicate, Primitive } from "./types.js";
8 changes: 4 additions & 4 deletions src/itertools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { every, iter, range } from "./builtins";
import { flatten } from "./more-itertools";
import type { Predicate, Primitive } from "./types";
import { primitiveIdentity } from "./utils";
import { every, iter, range } from "./builtins.js";
import { flatten } from "./more-itertools.js";
import type { Predicate, Primitive } from "./types.js";
import { primitiveIdentity } from "./utils.js";

const SENTINEL = Symbol();

Expand Down
8 changes: 4 additions & 4 deletions src/more-itertools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { iter, map } from "./builtins";
import { izip, repeat } from "./itertools";
import type { Predicate, Primitive } from "./types";
import { primitiveIdentity } from "./utils";
import { iter, map } from "./builtins.js";
import { izip, repeat } from "./itertools.js";
import type { Predicate, Primitive } from "./types.js";
import { primitiveIdentity } from "./utils.js";

/**
* Break iterable into lists of length `size`:
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Primitive } from "./types";
import type { Primitive } from "./types.js";

type CmpFn<T> = (a: T, b: T) => number;

Expand Down
2 changes: 1 addition & 1 deletion test-d/inference.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { partition } from "../dist";
import { partition } from "../dist/index.js";
import { expectType } from "tsd";

function isStr(x: unknown): x is string {
Expand Down
2 changes: 1 addition & 1 deletion test/builtins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
sum,
zip,
zip3,
} from "~";
} from "~/index.js";

const isEven = (n: number) => n % 2 === 0;
const isEvenIndex = (_: unknown, index: number) => index % 2 === 0;
Expand Down
2 changes: 1 addition & 1 deletion test/custom.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { compact, compactObject, flatmap, repeat } from "~";
import { compact, compactObject, flatmap, repeat } from "~/index.js";

describe("compact", () => {
it("compact w/ empty list", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/itertools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
zipLongest,
zipLongest3,
zipMany,
} from "~";
} from "~/index.js";

const isEven = (x: number) => x % 2 === 0;
const isEvenIndex = (_: unknown, index: number) => index % 2 === 0;
Expand Down
4 changes: 2 additions & 2 deletions test/more-itertools.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fc from "fast-check";
import { describe, expect, it } from "vitest";

import { find, iter, range } from "~/builtins.js";
import {
chunked,
dupes,
Expand All @@ -14,8 +15,7 @@ import {
take,
uniqueEverseen,
uniqueJustseen,
} from "~";
import { find, iter, range } from "~/builtins";
} from "~/index.js";

const isEven = (x: number) => x % 2 === 0;
const isEvenIndex = (_: unknown, index: number) => index % 2 === 0;
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"compilerOptions": {
"noEmit": true,
"strict": true,
"target": "es2015",
"lib": ["es6"],
"module": "es2020",
"moduleResolution": "bundler",
"target": "es2020",
"module": "node16",
"moduleResolution": "node16",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand Down