@ham2k/lib-operation-data 0.7.4 → 0.8.1
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/lib/modes.js +7 -7
- package/src/lib/modes.spec.js +3 -3
package/package.json
CHANGED
package/src/lib/modes.js
CHANGED
|
@@ -162,17 +162,17 @@ const AllSegments = Object.keys(BandPlans.bands).reduce((segments, band) => {
|
|
|
162
162
|
)
|
|
163
163
|
}, [])
|
|
164
164
|
|
|
165
|
-
export function modeForFrequency(frequency, {
|
|
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,13 +2,13 @@ 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, {
|
|
11
|
-
expect(modeForFrequency(14140, {
|
|
10
|
+
expect(modeForFrequency(14140, { ituRegion: 2 })).toEqual('SSB')
|
|
11
|
+
expect(modeForFrequency(14140, { entityPrefix: 'K' })).toEqual('CW')
|
|
12
12
|
|
|
13
13
|
})
|
|
14
14
|
})
|