Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 1x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x | /**
* 检测操作系统类型
*
* 支持的类型检测
* - ios
* - android
* @method env/os
* @returns {Object} UA 检查结果
* @example
* var $os = require('@spore-ui/kit/packages/env/os');
* console.info($os().ios);
* console.info($os.detect());
*/
var $assign = require('../obj/assign');
var $uaMatch = require('./uaMatch');
var testers = {
ios: /like mac os x/i,
android: function (ua) {
return ua.indexOf('android') > -1 || ua.indexOf('linux') > -1;
},
};
function detect(options, checkers) {
var conf = $assign({
ua: '',
}, options);
$assign(testers, checkers);
return $uaMatch(testers, conf.ua, conf);
}
var result = null;
function os() {
Eif (!result) {
result = detect();
}
return result;
}
os.detect = detect;
module.exports = os;
|