Skip to content

Commit

Permalink
Add JSR metadata, fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
sondr3 committed Mar 1, 2024
1 parent 399ee8d commit 1a6d93d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
npm/
.vscode/

### Created by https://www.gitignore.io
### Node ###
Expand Down
2 changes: 1 addition & 1 deletion apca_tables.ts
Expand Up @@ -121,7 +121,7 @@ export function apcaValidateFont(
apca: number,
sizes: FontSize | Array<FontSize>,
weights?: FontWeight | ReadonlyArray<FontWeight>,
) {
): Record<string, Record<FontWeight, boolean>> {
const contrast = Math.abs(apca);
sizes = Array.isArray(sizes) ? sizes : [sizes];
if (weights !== undefined) {
Expand Down
23 changes: 10 additions & 13 deletions deno.jsonc
@@ -1,4 +1,7 @@
{
"name": "@sondr3/a11y-color-contrast",
"version": "0.2.0",
"exports": "./mod.ts",
"tasks": {
"npm": "deno run -A ./build_npm.ts",
"test": "deno test --ignore=npm/"
Expand All @@ -7,20 +10,14 @@
"testing/": "https://deno.land/std@0.174.0/testing/"
},
"fmt": {
"files": {
"exclude": [
"npm/"
]
},
"options": {
"lineWidth": 120
}
"exclude": [
"npm/"
],
"lineWidth": 120
},
"lint": {
"files": {
"exclude": [
"npm/"
]
}
"exclude": [
"npm/"
]
}
}
4 changes: 2 additions & 2 deletions mod.ts
Expand Up @@ -9,13 +9,13 @@ export { apcaContrastValue } from "./apca.ts";
/**
* Rounding that allows for arbitrary precision.
*/
export function round(number: number, digits = 2, base = Math.pow(10, digits)): number {
export function round(number: number, digits: number = 2, base: number = Math.pow(10, digits)): number {
return Math.round((number + Number.EPSILON) * base) / base + 0;
}

/**
* Flooring that allows for arbitrary precision.
*/
export function floor(number: number, digits = 2, base = Math.pow(10, digits)): number {
export function floor(number: number, digits: number = 2, base: number = Math.pow(10, digits)): number {
return Math.floor(number + Number.EPSILON * base) / base;
}

0 comments on commit 1a6d93d

Please sign in to comment.