Skip to content

Commit

Permalink
Merge pull request #120 from ddbeck/add-shown-key
Browse files Browse the repository at this point in the history
Add `shown` key
  • Loading branch information
ai committed Aug 26, 2023
2 parents 308a8fe + ec2aa8e commit 00bc9c7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -57,7 +57,7 @@ In addition, the subset contains the `release_date` key with release dates (as t

The `feature` method takes a file from `data/features` and converts it into
something that more closely represents the `caniuse-db` format. Note that only
the `title`, `stats` and `status` keys are kept from the original data.
the `title`, `stats`, `status`, and `shown` keys are kept from the original data.


### `lite.features`
Expand Down
6 changes: 5 additions & 1 deletion dist/unpacker/feature.js
Expand Up @@ -27,7 +27,11 @@ function unpackSupport(cipher) {
}

function unpackFeature(packed) {
let unpacked = { status: statuses[packed.B], title: packed.C }
let unpacked = {
status: statuses[packed.B],
title: packed.C,
shown: packed.D
}
unpacked.stats = Object.keys(packed.A).reduce((browserStats, key) => {
let browser = packed.A[key]
browserStats[browsers[key]] = Object.keys(browser).reduce(
Expand Down
1 change: 1 addition & 0 deletions src/feature.test.js
Expand Up @@ -42,6 +42,7 @@ test('should be 1:1', () => {
})
equal(unpacked.status, data.status)
equal(unpacked.title, data.title)
equal(unpacked.shown, data.shown)
})
})

Expand Down
2 changes: 2 additions & 0 deletions src/lib/stringifyObject.js
Expand Up @@ -17,6 +17,8 @@ function stringifyRecursive(data) {
return t.identifier('undefined')
} else if (typeof data === 'string') {
return t.stringLiteral(data)
} else if (typeof data === 'boolean') {
return t.booleanLiteral(data)
} else if (typeof data === 'number') {
return t.numericLiteral(data)
} else if (Array.isArray(data)) {
Expand Down
1 change: 1 addition & 0 deletions src/packer/feature.js
Expand Up @@ -83,6 +83,7 @@ module.exports = async function packFeature() {
)
packed.B = parseDecimal(statusesInverted[contents.status])
packed.C = contents.title
packed.D = contents.shown
return fs.writeFile(
path.join(__dirname, `../../data/features/${name}.js`),
stringifyObject(packed)
Expand Down

0 comments on commit 00bc9c7

Please sign in to comment.