Skip to content

Commit

Permalink
remove json-based caniuse for now
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Oct 20, 2024
1 parent a5966e7 commit d71ade2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@std/assert": "jsr:@std/assert@^1.0.6",
"@std/csv": "jsr:@std/csv@^1.0.3",
"@std/semver": "jsr:@std/semver@^1.0.3",
"caniuse-db": "npm:caniuse-db@^1.0.30001669",
// "caniuse-db": "npm:caniuse-db@^1.0.30001669",
"caniuse-lite": "npm:caniuse-lite@^1.0.30001669",
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
Expand Down
8 changes: 1 addition & 7 deletions lib/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,10 @@ export const getAgentReleaseInfo = (ua: string): AgentRelease => {
.filter(([_, date]) => date !== null)
.sort(([versionA], [versionB]) => parseFloat(versionB) - parseFloat(versionA))[0]

const sortedVersions = Object.entries(agentStats.usage_global)
.filter(([_, usage]) => usage > 0)
.sort(([, usageA], [, usageB]) => usageB - usageA)

console.dir(sortedVersions)

const versionRank = Object.entries(agentStats.usage_global)
.filter(([_, usage]) => usage > 0)
.sort(([, usageA], [, usageB]) => usageB - usageA)
.findIndex(([v]) => v === version) + 2
.findIndex(([v]) => v === version) + 2 // ensure rank starts with 1, as it's an ordinal

return {
ok: Boolean(agentStats.release_date[version]),
Expand Down
5 changes: 2 additions & 3 deletions lib/caniuse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import data from 'caniuse-db/fulldata-json/data-2.0.json' with { type: 'json' }

type EpochDate = number
type Era = number
export type VersionStr = string
Expand Down Expand Up @@ -68,4 +66,5 @@ export type CanIUseData2 = {
data: Record<FeatureKey, SupportMatrix>
}

export default data as CanIUseData2
// import data from 'caniuse-db/fulldata-json/data-2.0.json' with { type: 'json' }
// export default data as CanIUseData2

0 comments on commit d71ade2

Please sign in to comment.