-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
70 lines (56 loc) · 1.35 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
var _ = require('lodash');
/**
* Expose the Class
*/
module.exports = MccMnc;
function MccMnc(List) {
if (List) {
this.List = List;
} else {
this.List = getListFromDB();
}
}
MccMnc.prototype.mcc = function (arg) {
return this._filter("mcc", arg);
};
MccMnc.prototype.mnc = function (arg) {
return this._filter("mnc", arg);
};
MccMnc.prototype.network = function (arg) {
return this._filter("network", arg);
};
MccMnc.prototype.country = function (arg) {
return this._filter("country", arg);
};
MccMnc.prototype.iso = function (arg) {
return this._filter("iso", arg);
};
MccMnc.prototype.countryCode = function (arg) {
return this._filter("country_code", arg);
};
MccMnc.prototype.get = function () {
if (this.List.length === 0) {
return -1;
} else if (this.List.length === 1) {
return this.List[0];
} else {
return this.List;
}
};
MccMnc.prototype._filter = function (key, value) {
var obj = {};
obj[key] = "" + value;
this.List = _.filter(this.List, obj);
return this;
};
MccMnc.prototype.clear = function () {
this.List = List;
return this;
};
function getListFromDB() {
return require('./src/database/mcc-mnc-table.json');
}
//var mccMnc = new MccMnc();
//console.log(mccMnc.mcc(310).mnc(410).get())
//require('./src/scraper')()