From 3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 6 Oct 2019 21:37:45 +0200 Subject: build: Add some required modules for node --- node_modules/caniuse-lite/dist/unpacker/feature.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 node_modules/caniuse-lite/dist/unpacker/feature.js (limited to 'node_modules/caniuse-lite/dist/unpacker/feature.js') diff --git a/node_modules/caniuse-lite/dist/unpacker/feature.js b/node_modules/caniuse-lite/dist/unpacker/feature.js new file mode 100644 index 0000000..d484a57 --- /dev/null +++ b/node_modules/caniuse-lite/dist/unpacker/feature.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = unpackFeature; + +var _statuses = require('../lib/statuses'); + +var _statuses2 = _interopRequireDefault(_statuses); + +var _supported = require('../lib/supported'); + +var _supported2 = _interopRequireDefault(_supported); + +var _browsers = require('./browsers'); + +var _browserVersions = require('./browserVersions'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var MATH2LOG = Math.log(2); + +function unpackSupport(cipher) { + // bit flags + var stats = Object.keys(_supported2.default).reduce(function (list, support) { + if (cipher & _supported2.default[support]) list.push(support); + return list; + }, []); + + // notes + var notes = cipher >> 7; + var notesArray = []; + while (notes) { + var note = Math.floor(Math.log(notes) / MATH2LOG) + 1; + notesArray.unshift('#' + note); + notes -= Math.pow(2, note - 1); + } + + return stats.concat(notesArray).join(' '); +} + +function unpackFeature(packed) { + var unpacked = { status: _statuses2.default[packed.B], title: packed.C }; + unpacked.stats = Object.keys(packed.A).reduce(function (browserStats, key) { + var browser = packed.A[key]; + browserStats[_browsers.browsers[key]] = Object.keys(browser).reduce(function (stats, support) { + var packedVersions = browser[support].split(' '); + var unpacked = unpackSupport(support); + packedVersions.forEach(function (v) { + return stats[_browserVersions.browserVersions[v]] = unpacked; + }); + return stats; + }, {}); + return browserStats; + }, {}); + return unpacked; +} \ No newline at end of file -- cgit v1.2.3