@ham2k/lib-operation-data 0.8.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ham2k/lib-operation-data",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
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 (entity && !a.entities[entityPrefix] && b.entities[entityPrefix]) return 1
169
- if (entity && a.entities[entityPrefix] && !b.entities[entityPrefix]) return -1
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 (country && !a.countries[countryCode] && b.countries[countryCode]) return 1
172
- if (country && a.countries[countryCode] && !b.countries[countryCode]) return -1
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 (region && !a.regions[ituRegion] && b.regions[ituRegion]) return 1
175
- if (region && a.regions[ituRegion] && !b.regions[ituRegion]) return -1
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
  })
@@ -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('USB')
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('USB')
10
+ expect(modeForFrequency(14140, { ituRegion: 2 })).toEqual('SSB')
11
11
  expect(modeForFrequency(14140, { entityPrefix: 'K' })).toEqual('CW')
12
12
 
13
13
  })