-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use
dts-buddy
to generate types (#239)
- Loading branch information
1 parent
8b24cc1
commit d077cfb
Showing
42 changed files
with
560 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
|
||
*.js | ||
*.d.ts | ||
*.map |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,31 +8,41 @@ | |
"type": "module", | ||
"scripts": { | ||
"clean": "git add * && git clean -dfx -e node_modules", | ||
"watch": "pnpm pub:build --watch", | ||
"format": "prettier -w . --plugin=prettier-plugin-sort-package-json", | ||
"check": "pnpm check:code && pnpm check:style", | ||
"check:code": "pnpm pub:build --noEmit", | ||
"check:code": "pnpm build:files --noEmit", | ||
"check:style": "prettier -c . --plugin=prettier-plugin-sort-package-json", | ||
"test": "pnpm test:unit", | ||
"test:unit": "uvu -r tsm src \"(spec\\.ts)\"", | ||
"pub:build": "tsc --project src --declaration", | ||
"pub:format": "prettier -wu **/*.{d.ts,js}", | ||
"prepublishOnly": "pnpm pub:build && pnpm pub:format" | ||
"build:types": "tsm scripts/compile-types.ts", | ||
"build:files": "tsc --project src", | ||
"prepublishOnly": "pnpm build:types && pnpm build:files" | ||
}, | ||
"types": "./core/index.d.ts", | ||
"typings": "./index.d.ts", | ||
"exports": { | ||
".": "./core/index.js", | ||
"./api": "./api/index.js", | ||
"./bits": "./bits/index.js", | ||
"./guards": "./guards/index.js", | ||
"./math": "./math/index.js", | ||
"./std": "./std/index.js", | ||
"./web": "./web/index.js", | ||
"./typings": "./typings/index.d.ts", | ||
".": "./src/core/index.js", | ||
"./api": "./src/api/index.js", | ||
"./bits": "./src/bits/index.js", | ||
"./compare": "./src/compare/index.js", | ||
"./csv": "./src/csv/index.js", | ||
"./date": "./src/date/index.js", | ||
"./guards": "./src/guards/index.js", | ||
"./math": "./src/math/index.js", | ||
"./random": "./src/random/index.js", | ||
"./std": "./src/std/index.js", | ||
"./web": "./src/web/index.js", | ||
"./typings": "./src/typings/index.d.ts", | ||
"./package.json": "./package.json", | ||
"./prettier.json": "./prettier.json", | ||
"./tsconfig.json": "./tsconfig.json" | ||
}, | ||
"files": [ | ||
"src/**/*.js", | ||
"index.d.ts", | ||
"index.d.ts.map", | ||
"prettier.json", | ||
"tsconfig.json" | ||
], | ||
"packageManager": "[email protected]", | ||
"prettier": "./prettier.json", | ||
"keywords": [ | ||
|
@@ -51,11 +61,12 @@ | |
"settings" | ||
], | ||
"devDependencies": { | ||
"@types/node": "^20.11.0", | ||
"prettier": "^3.1.1", | ||
"@types/node": "^20.14.9", | ||
"dts-buddy": "^0.5.0", | ||
"prettier": "^3.3.2", | ||
"prettier-plugin-sort-package-json": "^0.2.0", | ||
"tsm": "^2.3.0", | ||
"typescript": "^5.3.3", | ||
"typescript": "^5.5.2", | ||
"uvu": "^0.5.6" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createBundle } from 'dts-buddy'; | ||
import { exports } from '../package.json'; | ||
|
||
await createBundle({ | ||
output: 'index.d.ts', | ||
project: 'src/tsconfig.json', | ||
modules: Object.entries(exports).reduce((acc, [key, entry]) => { | ||
if (key.slice(2).includes('.')) return acc; // skip non-modules | ||
return { ...acc, ['mauss' + key.slice(1)]: entry }; | ||
}, {}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
export * from './find.js'; | ||
import type { UnaryFunction } from '../typings/helpers.js'; | ||
|
||
export function binary<T>( | ||
sorted: T[], | ||
check: { | ||
item: UnaryFunction<T, false | UnaryFunction<T>>; | ||
pointer: UnaryFunction<T, boolean>; | ||
}, | ||
): T | undefined { | ||
let start = 0, final = sorted.length - 1; // prettier-ignore | ||
while (start <= final) { | ||
const midpoint = (start + final) >> 1; | ||
const current = sorted[midpoint]; | ||
const passes = check.item(current); | ||
if (passes) return passes(current); | ||
const flag = check.pointer(current); | ||
start = flag ? start : midpoint + 1; | ||
final = flag ? midpoint - 1 : final; | ||
} | ||
return; | ||
} | ||
|
||
export function minmax(array: number[]): [number, number] { | ||
if (!array.length) return [0, 0]; | ||
|
||
let min = array[0], max = array[0]; // prettier-ignore | ||
for (let i = 1; i < array.length; i++) { | ||
min = array[i] < min ? array[i] : min; | ||
max = array[i] > max ? array[i] : max; | ||
} | ||
return [min, max]; | ||
} |
Oops, something went wrong.