-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathAnalyser.js
53 lines (48 loc) · 1.13 KB
/
Analyser.js
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
47
48
49
50
51
52
53
const Main = require('./model/Main');
const { Camouflage, Corrections, Derive, Header } = require('./Analyser/');
/**
* Class that parse the user-agent
*/
class Analyser {
/**
* Create a Analyser instance
*
* @param {object} headers An object with all of the headers or a string with just the User-Agent header
* @param {object} options Optional, an object with configuration options
*/
constructor(headers = {}, options = {}) {
this.headers = headers;
this.options = options;
}
/**
* set data to data property
*
* @param {object} data
*/
setData(data) {
this.data = data;
}
/**
* return data from data property
*
* @return {object} data
*/
getData() {
return this.data;
}
/**
* Analyse the provided headers or User-Agent string
*
*/
analyse() {
if (!this.data) {
this.data = new Main();
}
Header.analyseHeaders.call(this);
Derive.deriveInformation.call(this);
Corrections.applyCorrections.call(this);
Camouflage.detectCamouflage.call(this);
Derive.deriveDeviceSubType.call(this);
}
}
module.exports = Analyser;