(WIP)
Switch Case as good as Swiss Cheese. Idiomatic-like, dynamic, functional, predictable, stateless, mature, low-fat and fun 🎈 at the same time.
Käse
,|kɛːzə|
: Cheese (🇩🇪,🇨🇭)
swiss (needle: any, defaultNeedle?: any = undefined)
->
(...haystack: kase())
kase (haystack: any)
->
returnValue: any)
->
(needle: any)
import { swiss, kase } from '@nod/swiss-kase'
swiss('Raclette')(kase('Brie')('Nope'), kase('Raclette')('Yes')) // -> 'Yes'
import swissKase from '@nod/swiss-kase'
swissKase['🧀'](1)(
swissKase['🔪'](1)('Fondue')
swissKase['🔪'](2)('Feta')
swissKase['🔪'](3)('Gorgonzola')
) // -> 'Fondue'
swiss('Irrelevant Value')(
kase('Italian')(['Parmeggiano', 'Ricotta']),
kase('French')(['Roquefort']),
kase()(['Appenzeller', 'Emmentaler', 'Sbrinz', 'Raclette'])
) // -> ['Appenzeller','Emmentaler', 'Sbrinz', 'Raclette']
swiss('WOULDNT MATCH', 'Swiss')(
kase('Parmeggiano', 'Ricotta')('Italian'),
kase('Roquefort')('French'),
kase('Gruyère', 'Emmentaler', 'Sbrinz', 'Raclette')('Swiss')
) // -> 'Swiss'
swiss('Irrelevant Value', 'Swiss')(
kase('Italian')(['Parmeggiano', 'Ricotta']),
kase('French')(['Roquefort']),
kase('Swiss')(['Gruyère', 'Emmentaler', 'Sbrinz', 'Raclette'])
) // -> ['Gruyère','Emmentaler', 'Sbrinz', 'Raclette']
const english = [
[
'cheddar',
'stilton',
'red leicester',
'mature cheddar',
'cornish',
'durham',
'cheshire'
],
'🇬🇧'
]
const turkish = [
[
'white cheese',
'ezine',
'bergama tulum',
'mihaliç',
'gravyer',
'fresh milk',
'aged kashar',
'van',
'goat white cheese',
'smoked circassian',
'konya green cheese'
],
'🇹🇷'
]
const italian = [
[
'mozerella',
'gorgonzola',
'parmeggiano',
'grand padona',
'ricotta',
'grana padano',
'pecorino',
'taleggio',
'provolone',
'mascarpone'
],
'🇮🇹'
]
const dutch = [
['gouda', 'edam', 'maasdam', 'leyden', 'mimolette', 'beemster'],
'🇳🇱'
]
const french = [
['brie', 'camembert', 'roquefort', 'munster', 'livarot', 'reblochon'],
'🇫🇷'
]
const swiss = [
[
'fondue',
'raclette',
'emmentaler',
'appanzeller',
'tête de moine',
'gruyère',
'schabziger',
'formaggini'
],
'🇨🇭'
]
const allKase = [...italian, ...dutch, ...swiss, ...turkish].map(
([cheeseList, cheeseCountry]) => kase(...cheeseList)(cheeseCountry)
)
swiss('raclette')(...allKase) // -> '🇨🇭'
swiss('cheddar')(...allKase) // -> '🇬🇧'
swiss('gorgonzola')(...allKase) // -> '🇮🇹'
swiss('gouda')(...allKase) // -> '🇳🇱'
swiss('ezine')(...allKase) // -> '🇹🇷'
-
Starts auto build process
-
Run tests
-
Run module
-
Run test without watch mode
Please see @nod/nod monorepo
Apache 2.0