Skip to content

Commit

Permalink
Migrate from caniuse-db to caniuse-lite. Closes #57.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed Apr 20, 2017
1 parent a0d94a2 commit 1f10589
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"browserslist": "^1.3.6",
"caniuse-db": "^1.0.30000529",
"caniuse-lite": "^1.0.0",
"lodash.memoize": "^4.1.2",
"lodash.uniq": "^4.5.0"
},
Expand All @@ -40,7 +40,7 @@
"release": "npmpub"
},
"babel": {
"presets":[
"presets": [
"babel-preset-latest"
]
}
Expand Down
11 changes: 5 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import memoize from "lodash.memoize"
import browserslist from "browserslist"
import {features, feature as featureUnpack} from "caniuse-lite"

import {contains, parseCaniuseData, cleanBrowsersList} from "./utils"
import db from "caniuse-db/data.json"

const features = db.data
const featuresList = Object.keys(features)

let browsers
Expand All @@ -16,14 +15,14 @@ function getBrowserScope() {
return browsers
}

const parse = memoize(parseCaniuseData, function(feature, browsers) {
return feature.title + browsers
const parse = memoize(parseCaniuseData, function(feat, browsers) {
return feat.title + browsers
})

function getSupport(query) {
let feature
try {
feature = features[query]
feature = featureUnpack(features[query])
} catch(e) {
let res = find(query)
if (res.length === 1) return getSupport(res[0])
Expand All @@ -35,7 +34,7 @@ function getSupport(query) {
function isSupported(feature, browsers) {
let data
try {
data = features[feature]
data = featureUnpack(features[feature])
} catch(e) {
let res = find(feature)
if (res.length === 1) {
Expand Down
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from "tape"
import browserslist from "browserslist"
import {feature} from "caniuse-lite"
import * as caniuse from "../src/index"
import {cleanBrowsersList} from "../src/utils"

Expand Down Expand Up @@ -60,7 +61,7 @@ test("isSupported test with browsers caniuse doesn't know", (t) => {
test("getSupport tests", (t) => {
caniuse.setBrowserScope()

const borderRadiusFeature = require('caniuse-db/features-json/border-radius')
const borderRadiusFeature = feature(require('caniuse-lite/data/features/border-radius'))
const support = caniuse.getSupport("border-radius")
t.ok(support.safari.y, "border-radius support is ok on some safari")
t.throws(() => caniuse.getSupport("canaillou"),"throws if silly thing are asked")
Expand Down
3 changes: 2 additions & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import test from "tape"
import browserslist from "browserslist"
import uniq from "lodash.uniq"
import {feature} from "caniuse-lite"
import {contains, parseCaniuseData, cleanBrowsersList} from "../src/utils"

test("contains should work", (t) => {
Expand All @@ -12,7 +13,7 @@ test("contains should work", (t) => {

test("parseCaniuseData should work", (t) => {
const browsers = cleanBrowsersList()
const borderRadiusFeature = require('caniuse-db/features-json/border-radius')
const borderRadiusFeature = feature(require('caniuse-lite/data/features/border-radius'))
const parsed = parseCaniuseData(borderRadiusFeature, browsers)

t.ok(parsed.safari.y, "border-radius support is ok on some safari")
Expand Down

0 comments on commit 1f10589

Please sign in to comment.