monagree-locs 1.0.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,46 @@
1
1
  import { mLoc } from "./classes";
2
2
  export declare class mCountry {
3
- static getAllCountries(): mLoc[];
3
+ /**
4
+ * Retrieves an array of all countries (Only supports Nigeria for now).
5
+ * Set oderedList to true if you want the data ordered
6
+ *
7
+ * @returns {mLoc[]} An array of mLoc objects representing countries.
8
+ */
9
+ static getAllCountries(oderedList?: boolean): mLoc[];
10
+ /**
11
+ * Retrieves a country by its code
12
+ *
13
+ * @returns {mLoc}
14
+ */
4
15
  static getCountryByCode(countryCode: string): mLoc | undefined;
5
16
  }
6
17
  export declare class mState {
7
- static getStatesByCountry(countryCode: string): mLoc[];
18
+ /**
19
+ * Retrieves an array of all states in the provided country code.
20
+ * Set oderedList to true if you want the data ordered
21
+ *
22
+ * @returns {mLoc[]} An array of mLoc objects representing states.
23
+ */
24
+ static getStatesByCountry(countryCode: string, oderedList?: boolean): mLoc[];
25
+ /**
26
+ * Retrieves a state by its code and countryCode
27
+ *
28
+ * @returns {mLoc}
29
+ */
8
30
  static getStateByCode(countryCode: string, stateCode: string): mLoc | undefined;
9
31
  }
10
32
  export declare class mLga {
11
- static getLgasByState(countryCode: string, stateCode: string): mLoc[];
33
+ /**
34
+ * Retrieves an array of all LGAs in the specified country & state.
35
+ * Set oderedList to true if you want the data ordered
36
+ *
37
+ * @returns {mLoc[]} An array of mLoc objects representing LGAs.
38
+ */
39
+ static getLgasByState(countryCode: string, stateCode: string, oderedList?: boolean): mLoc[];
40
+ /**
41
+ * Retrieves an LGA by its code, state code and country code
42
+ *
43
+ * @returns {mLoc}
44
+ */
12
45
  static getLgaByCode(countryCode: string, stateCode: string, lgaCode: string): mLoc | undefined;
13
46
  }
package/dist/index.js CHANGED
@@ -6,7 +6,13 @@ var locs_1 = require("./locs");
6
6
  var mCountry = /** @class */ (function () {
7
7
  function mCountry() {
8
8
  }
9
- mCountry.getAllCountries = function () {
9
+ /**
10
+ * Retrieves an array of all countries (Only supports Nigeria for now).
11
+ * Set oderedList to true if you want the data ordered
12
+ *
13
+ * @returns {mLoc[]} An array of mLoc objects representing countries.
14
+ */
15
+ mCountry.getAllCountries = function (oderedList) {
10
16
  var countries = [];
11
17
  for (var countryCode in locs_1.locs) {
12
18
  if (locs_1.locs.hasOwnProperty(countryCode)) {
@@ -18,8 +24,16 @@ var mCountry = /** @class */ (function () {
18
24
  countries.push(new classes_1.mLoc(countryCode, country));
19
25
  }
20
26
  }
27
+ if (oderedList) {
28
+ return countries.slice().sort(function (a, b) { return a.getName().localeCompare(b.getName()); });
29
+ }
21
30
  return countries;
22
31
  };
32
+ /**
33
+ * Retrieves a country by its code
34
+ *
35
+ * @returns {mLoc}
36
+ */
23
37
  mCountry.getCountryByCode = function (countryCode) {
24
38
  if (locs_1.locs[countryCode]) {
25
39
  var acountry = locs_1.locs[countryCode];
@@ -37,7 +51,13 @@ exports.mCountry = mCountry;
37
51
  var mState = /** @class */ (function () {
38
52
  function mState() {
39
53
  }
40
- mState.getStatesByCountry = function (countryCode) {
54
+ /**
55
+ * Retrieves an array of all states in the provided country code.
56
+ * Set oderedList to true if you want the data ordered
57
+ *
58
+ * @returns {mLoc[]} An array of mLoc objects representing states.
59
+ */
60
+ mState.getStatesByCountry = function (countryCode, oderedList) {
41
61
  var states = [];
42
62
  if (locs_1.locs[countryCode]) {
43
63
  var nLoc = locs_1.locs[countryCode]['states'];
@@ -52,8 +72,16 @@ var mState = /** @class */ (function () {
52
72
  }
53
73
  }
54
74
  }
75
+ if (oderedList) {
76
+ return states.slice().sort(function (a, b) { return a.getName().localeCompare(b.getName()); });
77
+ }
55
78
  return states;
56
79
  };
80
+ /**
81
+ * Retrieves a state by its code and countryCode
82
+ *
83
+ * @returns {mLoc}
84
+ */
57
85
  mState.getStateByCode = function (countryCode, stateCode) {
58
86
  if (locs_1.locs[countryCode]) {
59
87
  var nLoc = locs_1.locs[countryCode]['states'];
@@ -74,7 +102,13 @@ exports.mState = mState;
74
102
  var mLga = /** @class */ (function () {
75
103
  function mLga() {
76
104
  }
77
- mLga.getLgasByState = function (countryCode, stateCode) {
105
+ /**
106
+ * Retrieves an array of all LGAs in the specified country & state.
107
+ * Set oderedList to true if you want the data ordered
108
+ *
109
+ * @returns {mLoc[]} An array of mLoc objects representing LGAs.
110
+ */
111
+ mLga.getLgasByState = function (countryCode, stateCode, oderedList) {
78
112
  var lgas = [];
79
113
  if (locs_1.locs[countryCode]) {
80
114
  var nLoc = locs_1.locs[countryCode]['states'];
@@ -88,8 +122,16 @@ var mLga = /** @class */ (function () {
88
122
  }
89
123
  }
90
124
  }
125
+ if (oderedList) {
126
+ return lgas.slice().sort(function (a, b) { return a.getName().localeCompare(b.getName()); });
127
+ }
91
128
  return lgas;
92
129
  };
130
+ /**
131
+ * Retrieves an LGA by its code, state code and country code
132
+ *
133
+ * @returns {mLoc}
134
+ */
93
135
  mLga.getLgaByCode = function (countryCode, stateCode, lgaCode) {
94
136
  if (locs_1.locs[countryCode]) {
95
137
  var nLoc = locs_1.locs[countryCode]['states'];