UNPKG

@cerebral/useragent

Version:
48 lines (36 loc) 1.42 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; exports.default = getFeatures; require('feature.js'); function getFeatures(options) { var feature = options.feature; var uaFeatures = window.feature; var featureMap = {}; Object.keys(uaFeatures).filter(isTestResult).filter(isEnabled).reduce(function (result, featureName) { result[featureName] = uaFeatures[featureName]; return result; }, featureMap); if (feature === Object(feature)) { Object.keys(feature).filter(isCustomTest).reduce(function (result, featureName) { result[featureName] = feature[featureName].call(); return result; }, featureMap); } function isEnabled(featureName) { if ((typeof feature === 'undefined' ? 'undefined' : _typeof(feature)) === 'object') { return feature[featureName] === true; } return feature; } function isCustomTest(featureName) { return typeof feature[featureName] === 'function'; } function isTestResult(featureName) { return typeof uaFeatures[featureName] === 'boolean'; } return featureMap; } //# sourceMappingURL=getFeatures.js.map