@ham2k/lib-operation-data 0.8.0 → 0.8.2
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/package.json +1 -1
- package/src/data/bandPlans.json +4 -4
- package/src/lib/modes.js +6 -6
- package/src/lib/modes.spec.js +2 -2
package/package.json
CHANGED
package/src/data/bandPlans.json
CHANGED
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"mhz": [7000, 7300],
|
|
40
40
|
"segments": [
|
|
41
41
|
{ "name": "CW", "mhz": [7000, 7060], "mode": "CW" },
|
|
42
|
-
{ "name": "CW", "mhz": [7000, 7125], "mode": "CW", "countries": [ "
|
|
42
|
+
{ "name": "CW", "mhz": [7000, 7125], "mode": "CW", "countries": [ "us" ] },
|
|
43
43
|
{ "name": "FT4", "mhz": [7047.5, 7050.5], "mode": "FT4" },
|
|
44
44
|
{ "name": "Phone", "mhz": [7060, 7300], "mode": "SSB", "submode": "LSB" },
|
|
45
45
|
{ "name": "FT8", "mhz": [7074, 7077], "mode": "FT8" },
|
|
46
46
|
{ "name": "Data", "mhz": [7080, 7125], "mode": "RTTY" },
|
|
47
|
-
{ "name": "Phone", "mhz": [7125, 7300], "mode": "SSB", "submode": "LSB", "countries": [ "
|
|
47
|
+
{ "name": "Phone", "mhz": [7125, 7300], "mode": "SSB", "submode": "LSB", "countries": [ "us" ] }
|
|
48
48
|
]
|
|
49
49
|
},
|
|
50
50
|
"30m": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
{ "name": "Data", "mhz": [10130, 10140], "mode": "RTTY" },
|
|
55
55
|
{ "name": "FT8", "mhz": [10136, 10139], "mode": "FT8" },
|
|
56
56
|
{ "name": "FT4", "mhz": [10140, 10143], "mode": "FT4" },
|
|
57
|
-
{ "name": "Australia", "mhz": [10100, 10150], "mode": null, "countries": ["
|
|
57
|
+
{ "name": "Australia", "mhz": [10100, 10150], "mode": null, "countries": ["au", "za"] }
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"20m": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
{ "name": "FT8", "mhz": [14074, 14077], "mode": "FT8" },
|
|
68
68
|
{ "name": "FT4", "mhz": [14080, 14083], "mode": "FT4" },
|
|
69
69
|
{ "name": "Phone", "mhz": [14112, 14350], "mode": "SSB", "submode": "USB", "regions": [ 1, 2 ] },
|
|
70
|
-
{ "name": "Phone", "mhz": [14150, 14350], "mode": "SSB", "submode": "USB", "countries": [ "
|
|
70
|
+
{ "name": "Phone", "mhz": [14150, 14350], "mode": "SSB", "submode": "USB", "countries": [ "us" ] }
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"17m": {
|
package/src/lib/modes.js
CHANGED
|
@@ -165,14 +165,14 @@ const AllSegments = Object.keys(BandPlans.bands).reduce((segments, band) => {
|
|
|
165
165
|
export function modeForFrequency(frequency, { ituRegion, countryCode, entityPrefix } = {}) {
|
|
166
166
|
const segments = AllSegments.filter(segment => segment.mhz[0] <= frequency && segment.mhz[1] >= frequency)
|
|
167
167
|
const sortedSegments = segments.sort((a, b) => {
|
|
168
|
-
if (
|
|
169
|
-
if (
|
|
168
|
+
if (entityPrefix && !a.entities[entityPrefix] && b.entities[entityPrefix]) return 1
|
|
169
|
+
if (entityPrefix && a.entities[entityPrefix] && !b.entities[entityPrefix]) return -1
|
|
170
170
|
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
171
|
+
if (countryCode && !a.countries[countryCode] && b.countries[countryCode]) return 1
|
|
172
|
+
if (countryCode && a.countries[countryCode] && !b.countries[countryCode]) return -1
|
|
173
173
|
|
|
174
|
-
if (
|
|
175
|
-
if (
|
|
174
|
+
if (ituRegion && !a.regions[ituRegion] && b.regions[ituRegion]) return 1
|
|
175
|
+
if (ituRegion && a.regions[ituRegion] && !b.regions[ituRegion]) return -1
|
|
176
176
|
|
|
177
177
|
return a.width - b.width
|
|
178
178
|
})
|
package/src/lib/modes.spec.js
CHANGED
|
@@ -2,12 +2,12 @@ import { modeForFrequency } from './modes'
|
|
|
2
2
|
|
|
3
3
|
describe('modeForFrequency', () => {
|
|
4
4
|
it('should find the most common mode for a frequency', () => {
|
|
5
|
-
expect(modeForFrequency(14255)).toEqual('
|
|
5
|
+
expect(modeForFrequency(14255)).toEqual('SSB')
|
|
6
6
|
expect(modeForFrequency(14107)).toEqual('CW')
|
|
7
7
|
expect(modeForFrequency(14074)).toEqual('FT8')
|
|
8
8
|
|
|
9
9
|
expect(modeForFrequency(14140)).toEqual('CW')
|
|
10
|
-
expect(modeForFrequency(14140, { ituRegion: 2 })).toEqual('
|
|
10
|
+
expect(modeForFrequency(14140, { ituRegion: 2 })).toEqual('SSB')
|
|
11
11
|
expect(modeForFrequency(14140, { entityPrefix: 'K' })).toEqual('CW')
|
|
12
12
|
|
|
13
13
|
})
|