Skip to content

Commit

Permalink
add a new export: feature list
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyalab committed Apr 6, 2017
1 parent ca59a96 commit 2774552
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.6.0 - 2017-04-06

- Added: export the feature list
([#48](https://github.com/Nyalab/caniuse-api/pull/48))

# 1.5.3 - 2017-02-01

- Removed unused dependency
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "caniuse-api",
"version": "1.5.3",
"version": "1.6.0",
"description": "request the caniuse data to check browsers compatibilities",
"repository": "https://github.com/nyalab/caniuse-api.git",
"keywords": [
Expand All @@ -17,10 +17,10 @@
"dist"
],
"dependencies": {
"browserslist": "^1.0.1",
"caniuse-db": "^1.0.30000346",
"lodash.memoize": "^4.1.0",
"lodash.uniq": "^4.3.0"
"browserslist": "^1.3.6",
"caniuse-db": "^1.0.30000529",
"lodash.memoize": "^4.1.2",
"lodash.uniq": "^4.5.0"
},
"devDependencies": {
"babel-cli": "^6.22.2",
Expand All @@ -30,7 +30,7 @@
"jshint": "^2.5.10",
"npmpub": "^3.1.0",
"tap-spec": "^4.1.1",
"tape": "^4.5.1"
"tape": "^4.6.0"
},
"scripts": {
"build": "babel src --out-dir dist",
Expand Down
16 changes: 11 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {contains, parseCaniuseData, cleanBrowsersList} from "./utils"
import db from "caniuse-db/data.json"

const features = db.data

const featuresList = Object.keys(features)


var browsers
let browsers
function setBrowserScope(browserList) {
browsers = cleanBrowsersList(browserList)
}
Expand All @@ -18,7 +16,7 @@ function getBrowserScope() {
return browsers
}

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

Expand Down Expand Up @@ -70,4 +68,12 @@ function getLatestStableBrowsers() {

setBrowserScope()

export {getSupport, isSupported, find, getLatestStableBrowsers, setBrowserScope, getBrowserScope}
export {
featuresList as features,
getSupport,
isSupported,
find,
getLatestStableBrowsers,
setBrowserScope,
getBrowserScope
}
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ test("browserscope tests", (t) => {
t.end()
})

test("features test", (t) => {
t.ok(Array.isArray(caniuse.features), "a feature list is exported")
t.ok(caniuse.features.length > 0, "the feature list is not empty")
t.end()
})

test("find tests", (t) => {
t.deepEqual(caniuse.find("radius"), ["border-radius"], "`find` should find border-radius")
t.deepEqual(caniuse.find("canaillou"), [], "non-existent property should return an empty array")
Expand Down

0 comments on commit 2774552

Please sign in to comment.