Skip to content

Commit

Permalink
feat: remove repetitive words
Browse files Browse the repository at this point in the history
the full title can still be compsed out of the library.
  • Loading branch information
Kikobeats committed Oct 18, 2023
1 parent df4dedc commit b5799e7
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 211 deletions.
212 changes: 114 additions & 98 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,116 +1,132 @@
'use strict'

const MODEL_S = Object.entries({
'Model S 60D': [['BT60', 'DV4W']],
'Model S 60': [['BT60', 'DV2W']],
'Model S 70': [['BT70', 'DV2W']],
'Model S 70D': [['BT70', 'DV4W']],
'Model S 75': [
['BTX5', 'DV2W'],
['BTX7', 'DV2W'],
['BTX8', 'DV2W']
const MODEL_S = [
['60D', [['BT60', 'DV4W']]],
['60', [['BT60', 'DV2W']]],
['70', [['BT70', 'DV2W']]],
['70D', [['BT70', 'DV4W']]],
[
'75',
[
['BTX5', 'DV2W'],
['BTX7', 'DV2W'],
['BTX8', 'DV2W']
]
],
'Model S 75D': [
['BTX5', 'DV4W'],
['BTX7', 'DV4W'],
['BTX8', 'DV4W']
[
'75D',
[
['BTX5', 'DV4W'],
['BTX7', 'DV4W'],
['BTX8', 'DV4W']
]
],
'Model S P85+': [['PX01']],
'Model S P85': [
['BT85', 'X024', 'DV2W'],
['PBT85', 'X024', 'DV2W']
['P85+', [['PX01']]],
[
'P85',
[
['BT85', 'X024', 'DV2W'],
['PBT85', 'X024', 'DV2W']
]
],
'Model S 85': [['BT85', 'DV2W']],
'Model S 85D': [['BT85', 'DV4W']],
'Model S P85D': [['P85D'], ['PBT85', 'X024', 'DV4W']],
'Model S P90D': [
['X024', 'BTX4', 'DV4W'],
['X024', 'PX4D', 'DV4W']
['85', [['BT85', 'DV2W']]],
['85D', [['BT85', 'DV4W']]],
['P85D', [['P85D'], ['PBT85', 'X024', 'DV4W']]],
[
'P90D',
[
['X024', 'BTX4', 'DV4W'],
['X024', 'PX4D', 'DV4W']
]
],
'Model S 90': [['BTX4', 'DV2W']],
'Model S 90D': [['BTX4', 'DV4W']],
'Model S P100D': [['BTX6', 'X024', 'DV4W']],
'Model S 100D': [['BTX6', 'DV4W']],
'Model S Standard Range': [['MTS01'], ['MTS17']],
'Model S Long Range': [['MTS03'], ['MTS05'], ['MTS10']],
'Model S Performance': [['MTS04'], ['MTS06'], ['MTS08']],
'Model S Long Range Plus': [['MTS07']],
'Model S': [['MTS13']],
'Model S Plaid': [['MTS11'], ['MTS12'], ['MTS14']],
'Model S Plaid+': [['MTS09']]
})
['90', [['BTX4', 'DV2W']]],
['90D', [['BTX4', 'DV4W']]],
['P100D', [['BTX6', 'X024', 'DV4W']]],
['100D', [['BTX6', 'DV4W']]],
['Standard Range', [['MTS01'], ['MTS17']]],
['Long Range', [['MTS03'], ['MTS05'], ['MTS10']]],
['Performance', [['MTS04'], ['MTS06'], ['MTS08']]],
['Long Range Plus', [['MTS07']]],
['', [['MTS13']]],
['Plaid', [['MTS11'], ['MTS12'], ['MTS14']]],
['Plaid+', [['MTS09']]]
]

const MODEL_X = Object.entries({
'Model X 75D': [
['BTX5', 'DV4W'],
['BTX7', 'DV4W'],
['BTX8', 'DV4W']
const MODEL_X = [
[
'75D',
[
['BTX5', 'DV4W'],
['BTX7', 'DV4W'],
['BTX8', 'DV4W']
]
],
'Model X P90D': [
['X024', 'BTX4', 'DV4W'],
['X024', 'PX4D', 'DV4W']
[
'P90D',
[
['X024', 'BTX4', 'DV4W'],
['X024', 'PX4D', 'DV4W']
]
],
'Model X 90D': [['BTX4', 'DV4W']],
'Model X P100D': [['BTX6', 'X024', 'DV4W']],
'Model X 100D': [['BTX6', 'DV4W']],
'Model X Standard Range': [['MTX01'], ['MTX17']],
'Model X Long Range': [['MTX03'], ['MTX10']],
'Model X Long Range Plus': [['MTX05'], ['MTX07']],
'Model X Performance': [['MTX04'], ['MTX06'], ['MTX08']],
'Model X': [['MTX12'], ['MTX13'], ['MTX15']],
'Model X Plaid': [['MTX11'], ['MTX14'], ['MTX16']],
'Model X Plaid+': [['MTX09']]
})
['90D', [['BTX4', 'DV4W']]],
['P100D', [['BTX6', 'X024', 'DV4W']]],
['100D', [['BTX6', 'DV4W']]],
['Standard Range', [['MTX01'], ['MTX17']]],
['Long Range', [['MTX03'], ['MTX10']]],
['Long Range Plus', [['MTX05'], ['MTX07']]],
['Performance', [['MTX04'], ['MTX06'], ['MTX08']]],
['', [['MTX12'], ['MTX13'], ['MTX15']]],
['Plaid', [['MTX11'], ['MTX14'], ['MTX16']]],
['Plaid+', [['MTX09']]]
]

const MODEL_3 = Object.entries({
'Model 3': [['MT322'], ['MT351']],
'Model 3 Standard Range': [['MT300']],
'Model 3 Standard Range Plus': [
['MT301'],
['MT308'],
['MT309'],
['MT314'],
['MT320'],
['MT327'],
['MT336'],
['MT337']
const MODEL_3 = [
['', [['MT322'], ['MT351']]],
['Standard Range', [['MT300']]],
[
'Standard Range Plus',
[
['MT301'],
['MT308'],
['MT309'],
['MT314'],
['MT320'],
['MT327'],
['MT336'],
['MT337']
]
],
'Model 3 Mid Range': [['MT305'], ['MT307']],
'Model 3 Long Range RWD': [['MT302'], ['MT341']],
'Model 3 Long Range AWD': [
['MT303'],
['MT310'],
['MT315'],
['MT316'],
['MT321'],
['MT323'],
['MT324'],
['MT328'],
['MT352']
['Mid Range', [['MT305'], ['MT307']]],
['Long Range RWD', [['MT302'], ['MT341']]],
[
'Long Range AWD',
[
['MT303'],
['MT310'],
['MT315'],
['MT316'],
['MT321'],
['MT323'],
['MT324'],
['MT328'],
['MT352']
]
],
'Model 3 Performance': [
['MT304'],
['MT311'],
['MT317'],
['MT325'],
['MT329'],
['MT340']
[
'Performance',
[['MT304'], ['MT311'], ['MT317'], ['MT325'], ['MT329'], ['MT340']]
]
})
]

const MODEL_Y = Object.entries({
'Model Y Standard Range': [['MTY01'], ['MTY13']],
'Model Y Long Range RWD': [['MTY02']],
'Model Y Long Range AWD': [
['MTY03'],
['MTY06'],
['MTY07'],
['MTY09'],
['MTY11'],
['MTY14']
const MODEL_Y = [
['Standard Range', [['MTY01'], ['MTY13']]],
['Long Range RWD', [['MTY02']]],
[
'Long Range AWD',
[['MTY03'], ['MTY06'], ['MTY07'], ['MTY09'], ['MTY11'], ['MTY14']]
],
'Model Y Performance': [['MTY04'], ['MTY05'], ['MTY10'], ['MTY12']]
})
['Performance', [['MTY04'], ['MTY05'], ['MTY10'], ['MTY12']]]
]

const getCollection = optionCodes => {
if (optionCodes.includes('MDLS')) return MODEL_S
Expand Down
60 changes: 30 additions & 30 deletions test/model-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ const test = require('ava')
const title = require('..')

test('Model 3', t => {
t.is(title({ optionCodes: ['MDL3', 'MT322'] }), 'Model 3')
t.is(title({ optionCodes: ['MDL3', 'MT351'] }), 'Model 3')
t.is(title({ optionCodes: ['MDL3', 'MT322'] }), '')
t.is(title({ optionCodes: ['MDL3', 'MT351'] }), '')
})

test('Model 3 Standard Range', t => {
t.is(title({ optionCodes: ['MDL3', 'MT300'] }), 'Model 3 Standard Range')
t.is(title({ optionCodes: ['MDL3', 'MT300'] }), 'Standard Range')
})

test('Model 3 Mid Range', t => {
t.is(title({ optionCodes: ['MDL3', 'MT305'] }), 'Model 3 Mid Range')
t.is(title({ optionCodes: ['MDL3', 'MT307'] }), 'Model 3 Mid Range')
t.is(title({ optionCodes: ['MDL3', 'MT305'] }), 'Mid Range')
t.is(title({ optionCodes: ['MDL3', 'MT307'] }), 'Mid Range')
})

test('Model 3 Standard Range Plus', t => {
t.is(title({ optionCodes: ['MDL3', 'MT301'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT308'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT309'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT314'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT320'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT336'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT337'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT301'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT327'] }), 'Model 3 Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT301'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT308'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT309'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT314'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT320'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT336'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT337'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT301'] }), 'Standard Range Plus')
t.is(title({ optionCodes: ['MDL3', 'MT327'] }), 'Standard Range Plus')
})

test('Model 3 Long Range RWD', t => {
t.is(title({ optionCodes: ['MDL3', 'MT302'] }), 'Model 3 Long Range RWD')
t.is(title({ optionCodes: ['MDL3', 'MT341'] }), 'Model 3 Long Range RWD')
t.is(title({ optionCodes: ['MDL3', 'MT302'] }), 'Long Range RWD')
t.is(title({ optionCodes: ['MDL3', 'MT341'] }), 'Long Range RWD')
})

test('Model 3 Long Range AWD', t => {
t.is(title({ optionCodes: ['MDL3', 'MT303'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT310'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT315'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT316'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT321'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT323'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT324'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT328'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT352'] }), 'Model 3 Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT303'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT310'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT315'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT316'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT321'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT323'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT324'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT328'] }), 'Long Range AWD')
t.is(title({ optionCodes: ['MDL3', 'MT352'] }), 'Long Range AWD')
})

test('Model 3 Performance', t => {
t.is(title({ optionCodes: ['MDL3', 'MT304'] }), 'Model 3 Performance')
t.is(title({ optionCodes: ['MDL3', 'MT317'] }), 'Model 3 Performance')
t.is(title({ optionCodes: ['MDL3', 'MT325'] }), 'Model 3 Performance')
t.is(title({ optionCodes: ['MDL3', 'MT340'] }), 'Model 3 Performance')
t.is(title({ optionCodes: ['MDL3', 'MT329'] }), 'Model 3 Performance')
t.is(title({ optionCodes: ['MDL3', 'MT304'] }), 'Performance')
t.is(title({ optionCodes: ['MDL3', 'MT317'] }), 'Performance')
t.is(title({ optionCodes: ['MDL3', 'MT325'] }), 'Performance')
t.is(title({ optionCodes: ['MDL3', 'MT340'] }), 'Performance')
t.is(title({ optionCodes: ['MDL3', 'MT329'] }), 'Performance')
})

0 comments on commit b5799e7

Please sign in to comment.