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