type-fest#ReadonlyDeep TypeScript Examples
The following examples show how to use
type-fest#ReadonlyDeep.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: angle.ts From convert with MIT License | 6 votes |
angle: ReadonlyDeep<Family> = {
id: Id.Angle,
best: ['deg'],
conversions: [
{names: ['radian', 'radians'], symbols: ['rad', 'rads', 'r'], ratio: 1},
{names: ['turn', 'turns'], ratio: 2 * Math.PI},
{names: ['degree', 'degrees'], symbols: ['deg', 'degs', '°'], ratio: Math.PI / 180},
{names: ['gradian', 'gradians'], symbols: ['gon', 'gons', 'grad', 'grads', 'grade', 'grades'], ratio: Math.PI / 200},
],
} as const
Example #2
Source File: area.ts From convert with MIT License | 6 votes |
area: ReadonlyDeep<Family> = {
id: Id.Area,
best: {metric: ['mm2', 'cm2', 'm2', 'km2'], imperial: ['sq in', 'sq ft', 'sq mi', 'ac']},
conversions: [
// https://en.wikipedia.org/wiki/Category:Units_of_area
// https://en.wikipedia.org/wiki/Square_metre
{names: ['square meter', 'square meters', 'square metre', 'square metres'], symbols: ['m²', 'm2'], ratio: 1},
...expandMacro(Macros.areaSi, {names: ['meter', 'metre', 'meters', 'metres'], symbols: ['m²', 'm2'], ratio: 1}),
// https://en.wikipedia.org/wiki/Conversion_of_units#Area
{names: ['acre', 'acres'], symbols: ['ac'], ratio: 4046.856_422_4},
// https://en.wikipedia.org/wiki/Hectare#Are
{names: ['centiare', 'centiares'], symbols: ['ca'], ratio: 1},
{names: ['deciare', 'deciares'], symbols: ['da'], ratio: 1e1},
// Symbol `a` is excluded to avoid conflict
{names: ['are', 'ares'], ratio: 1e2},
{names: ['decare', 'decares'], symbols: ['daa'], ratio: 1e3},
{names: ['hectare', 'hectares'], symbols: ['ha'], ratio: 1e4},
{names: ['square foot', 'square feet'], symbols: ['sq ft'], ratio: 9.290_304e-2},
{names: ['square inch', 'square inches'], symbols: ['sq in'], ratio: 6.4516e-4},
{names: ['square yard', 'square yards'], symbols: ['sq yd'], ratio: 0.836_127_36},
{names: ['square mile', 'square miles'], symbols: ['sq mi'], ratio: 2.589_988_110_336e6},
],
}
Example #3
Source File: data.ts From convert with MIT License | 6 votes |
data: ReadonlyDeep<Family> = {
id: Id.Data,
best: ['bits', 'B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'],
/**
* @see https://en.wikipedia.org/wiki/Orders_of_magnitude_(data) Source
*/
conversions: [
{names: ['bit', 'bits'], symbols: ['b'], ratio: 1},
...expandMacro(Macros.binary, {names: ['bit', 'bits'], symbols: ['b'], ratio: 1}),
...expandMacro(Macros.si, {names: ['bit', 'bits'], symbols: ['b'], kind: 'big', ratio: 1}),
{
names: ['nibble', 'nibbles', 'semioctet', 'semioctets', 'halfbyte', 'halfbytes'],
ratio: 4,
},
{names: ['byte', 'bytes', 'octect', 'octects'], symbols: ['B'], ratio: 8},
...expandMacro(Macros.binary, {names: ['byte', 'bytes'], symbols: ['B'], ratio: 8}),
...expandMacro(Macros.si, {names: ['byte', 'bytes'], symbols: ['B'], kind: 'big', ratio: 8}),
{names: ['hextet', 'hextets'], ratio: 16},
],
}
Example #4
Source File: energy.ts From convert with MIT License | 6 votes |
energy: ReadonlyDeep<Family> = {
id: Id.Energy,
best: ['J'],
conversions: [
{names: ['joule', 'joules'], symbols: ['J'], ratio: 1},
...expandMacro(Macros.si, {names: ['joule', 'joules'], symbols: ['J'], ratio: 1}),
// https://en.wikipedia.org/wiki/Kilowatt-hour
{names: ['kilowatt-hour'], symbols: ['kW⋅h', 'kW h', 'kWh'], ratio: 3.6e6},
],
}
Example #5
Source File: force.ts From convert with MIT License | 6 votes |
force: ReadonlyDeep<Family> = {
id: Id.Force,
best: {metric: ['N'], imperial: ['lbf']},
conversions: [
{names: ['newton', 'newtons'], symbols: ['N'], ratio: 1},
{names: ['dyne', 'dynes'], symbols: ['dyn'], ratio: 1e-5},
{names: ['kilogram-force'], symbols: ['kgf', 'kilopond', 'kiloponds', 'kp'], ratio: 9.806_65},
{names: ['pound of force', 'pound-force'], symbols: ['lbf'], ratio: 4.448_222},
{names: ['poundal', 'poundals'], symbols: ['pdl'], ratio: 0.138_255},
],
}
Example #6
Source File: length.ts From convert with MIT License | 6 votes |
length: ReadonlyDeep<Family> = {
id: Id.Length,
best: {
metric: ['mm', 'cm', 'm', 'km'],
imperial: ['in', 'ft', 'yd', 'mi'],
},
conversions: [
{names: ['meter', 'meters', 'metre', 'metres'], symbols: ['m'], ratio: 1},
...expandMacro(Macros.si, {names: ['meter', 'metre', 'meters', 'metres'], symbols: ['m'], ratio: 1}),
{names: ['foot', 'feet'], symbols: ['ft', "'"], ratio: 0.3048},
{names: ['inch', 'inches'], symbols: ['in', '"'], ratio: 0.0254},
{names: ['yard', 'yards'], symbols: ['yd'], ratio: 0.9144},
{names: ['mile', 'miles'], symbols: ['mi'], ratio: 1609.344},
{names: ['nautical mile', 'nautical miles'], symbols: ['M', 'NM', 'nmi'], ratio: 1852},
],
}
Example #7
Source File: mass.ts From convert with MIT License | 6 votes |
mass: ReadonlyDeep<Family> = {
id: Id.Mass,
best: {
metric: ['mg', 'g', 'kg'],
imperial: ['oz', 'lb'],
},
conversions: [
{names: ['gram', 'grams'], symbols: ['g'], ratio: 1},
...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),
{names: ['tonne', 'tonnes', 'metric ton', 'metric tons'], symbols: ['t'], ratio: 1e6},
...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),
{names: ['pound', 'pounds'], symbols: ['lb'], ratio: poundInGrams},
{names: ['stone', 'stones'], symbols: ['st'], ratio: poundInGrams.times(14)},
// TODO: Remove ℥ on next breaking release
{names: ['ounce', 'ounces'], symbols: ['oz', '℥'], ratio: poundInGrams.div(16)},
{names: ['short ton', 'short tons', 'US ton', 'US tons'], ratio: poundInGrams.times(2000)},
{names: ['long ton', 'long tons', 'imperial ton', 'imperial tons', 'displacement ton', 'displacement tons'], ratio: poundInGrams.times(2240)},
],
}
Example #8
Source File: power.ts From convert with MIT License | 6 votes |
power: ReadonlyDeep<Family> = {
id: Id.Power,
best: ['W', 'kW', 'MW', 'GW', 'TW', 'PW'],
conversions: [
// https://en.wikipedia.org/wiki/Watt
{names: ['watt', 'watts'], symbols: ['W'], ratio: 1},
...expandMacro(Macros.si, {names: ['watt', 'watts'], symbols: ['W'], ratio: 1}),
{names: ['horsepower', 'mechanical horsepower'], symbols: ['hp'], ratio: 745.699_872},
],
}
Example #9
Source File: pressure.ts From convert with MIT License | 6 votes |
pressure: ReadonlyDeep<Family> = {
id: Id.Pressure,
best: {metric: ['Pa'], imperial: ['psi']},
conversions: [
{names: ['pascal', 'pascals'], symbols: ['Pa'], ratio: 1},
...expandMacro(Macros.si, {names: ['pascal', 'pascals'], symbols: ['Pa'], ratio: 1}),
{names: ['bar', 'bars'], symbols: ['bar'], ratio: 1e5},
...expandMacro(Macros.si, {names: ['bar', 'bars'], symbols: ['bar'], ratio: 1e5}),
{names: ['torr', 'torrs'], symbols: ['Torr'], ratio: new BigNumber(101_325).div(760)},
{names: ['millitorr'], symbols: ['mTorr'], ratio: new BigNumber(101_325).div(760).div(1e3)},
{names: ['atmosphere', 'atmospheres'], symbols: ['atm'], ratio: 101_325},
// https://en.wikipedia.org/wiki/Pound_per_square_inch
{names: ['pound per square inch', 'pounds per square inch'], symbols: ['psi', 'lbf/in2', 'lbf/in²'], ratio: 6.894_757e3},
],
}
Example #10
Source File: temperature.ts From convert with MIT License | 6 votes |
temperature: ReadonlyDeep<Family> = {
id: Id.Temperature,
best: {metric: ['C'], imperial: ['F']},
/** @see https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature#Kelvin */
conversions: [
{names: [KelvinNames.kelvin, KelvinNames.kelvins], symbols: [KelvinNames.K], ratio: 1},
...expandMacro(Macros.si, {names: [KelvinNames.kelvin, KelvinNames.kelvins], symbols: [KelvinNames.K], ratio: 1}),
{names: ['fahrenheit'], symbols: ['F'], ratio: 5 / 9, difference: 459.67},
{names: ['celsius'], symbols: ['C'], ratio: 1, difference: 273.15},
{names: ['rankine'], symbols: ['R'], ratio: 5 / 9},
],
}
Example #11
Source File: time.ts From convert with MIT License | 6 votes |
time: ReadonlyDeep<Family> = {
id: Id.Time,
best: ['ns', 'μs', 'ms', 's', 'min', 'h', 'd', 'y'],
conversions: [
{names: ['second', 'seconds'], symbols: ['s'], ratio: 1},
...expandMacro(Macros.si, {names: ['second', 'seconds'], symbols: ['s'], ratio: 1}),
{names: ['minute', 'minutes'], symbols: ['min'], ratio: 60},
{names: ['hour', 'hours'], symbols: ['h'], ratio: 60 * 60},
{names: ['milliday', 'millidays'], symbols: ['md'], ratio: (60 * 60 * 24) / 1e3},
{names: ['day', 'days'], symbols: ['d'], ratio: 60 * 60 * 24},
{names: ['week', 'weeks'], symbols: ['wk'], ratio: 60 * 60 * 24 * 7},
{names: ['fortnight', 'fortnights'], symbols: ['fn'], ratio: 60 * 60 * 24 * 14},
{names: ['month', 'months'], symbols: ['mo'], ratio: 2.592e6},
{names: ['year', 'years'], symbols: ['a', 'y', 'yr'], ratio: 3.1536e7},
{names: ['decade', 'decades'], symbols: ['dec'], ratio: 3.155_695_2e8},
// Symbol `c` is excluded to avoid conflict
{names: ['century', 'centuries'], ratio: 3.155_695_2e9},
{names: ['millennium', 'millennia'], ratio: 3.155_695_2e10},
{names: ['moment', 'moments'], ratio: 90},
{names: ['shake', 'shakes'], ratio: 1e-8},
{names: ['time unit'], symbols: ['TU'], ratio: 1024e-6},
{names: ['svedberg', 'svedbergs'], symbols: ['S'], ratio: 1e-13},
],
}
Example #12
Source File: index.d.ts From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution | 5 votes |
globals: ReadonlyDeep<typeof globalsJson>
Example #13
Source File: volume.ts From convert with MIT License | 5 votes |
volume: ReadonlyDeep<Family> = {
id: Id.Volume,
best: {
metric: ['mL', 'L'],
imperial: ['tsp', 'tbsp', 'fl oz', 'cup', 'pt', 'qt', 'gal'],
},
conversions: [
{
names: ['cubic meter', 'cubic meters', 'cubic metre', 'cubic metres', 'stere', 'steres'],
symbols: ['m³', 'm3'],
ratio: 1,
},
...expandMacro(Macros.volumeSi, {names: ['meter', 'meters'], symbols: ['m3', 'm³'], ratio: 1}),
{
names: ['liter', 'liters', 'litre', 'litres'],
symbols: ['l', 'L'],
ratio: 1e-3,
},
...expandMacro(Macros.si, {names: ['liter', 'liters', 'litre', 'litres'], symbols: ['l', 'L'], ratio: 1e-3}),
// https://en.wikipedia.org/wiki/Cubic_mile
{names: ['cubic mile', 'cubic miles'], symbols: ['cu mi', 'mi3', 'mi³'], ratio: 4.2e3},
// https://en.wikipedia.org/wiki/Acre-foot
{names: ['acre-foot', 'acre-feet'], symbols: ['ac⋅ft', 'ac ft'], ratio: 1233.481_837_547_52},
// https://en.wikipedia.org/wiki/Cubic_yard
{names: ['cubic yard', 'cubic yards'], symbols: ['cu yd', 'yd3', 'yd³'], ratio: 0.76},
// https://en.wikipedia.org/wiki/Cubic_foot
{names: ['cubic foot', 'cubic feet'], symbols: ['cu ft', 'ft3', 'ft³'], ratio: 0.028},
{names: ['board foot', 'board feet'], ratio: 0.002_359_737},
// https://en.wikipedia.org/wiki/Cubic_inch
{names: ['cubic inch', 'cubic inches'], symbols: ['cu in', 'in3', 'in³'], ratio: 0.000_016_387_064},
{names: ['measurement ton', 'measurement tons'], symbols: ['MTON'], ratio: 1.133},
{names: ['imperial barrel', 'imperial barrels'], symbols: ['imp bbl'], ratio: 0.16},
// https://en.wikipedia.org/wiki/Bushel#Imperial_bushel
{names: ['imperial bushel', 'imperial bushels'], symbols: ['imp bsh', 'imp bu'], ratio: 0.036_368_72},
{names: ['imperial peck', 'imperial pecks'], symbols: ['pk', 'imp pk'], ratio: 0.009_092_18},
{names: ['imperial gallon', 'imperial gallons'], symbols: ['imp gal'], ratio: 0.004_546_09},
{names: ['imperial quart', 'imperial quarts'], symbols: ['imp qt'], ratio: 0.001_136_522_5},
{names: ['imperial pint', 'imperial pints'], symbols: ['imp pt'], ratio: 0.000_568_261_25},
// https://en.wikipedia.org/wiki/Fluid_ounce
{names: ['imperial fluid ounce', 'imperial fluid ounces'], symbols: ['imp fl oz'], ratio: 28.413_062_5e-6},
// https://en.wikipedia.org/wiki/United_States_customary_units#Fluid_volume
{names: ['teaspoon', 'teaspoons', 'US teaspoon', 'US teaspoons'], symbols: ['tsp'], ratio: 4.928_921_593_75e-6},
{names: ['tablespoon', 'tablespoons', 'US tablespoon', 'US tablespoons'], symbols: ['tbsp'], ratio: 14.786_764_781_25e-6},
// https://en.wikipedia.org/wiki/Fluid_ounce
{names: ['US fluid ounce', 'US fluid ounces'], symbols: ['fl oz', 'fl. oz.', 'oz. fl.'], ratio: 29.573_529_562_5e-6},
// https://en.wikipedia.org/wiki/Cup_(unit)
{names: ['cup', 'cups', 'US legal cup', 'US legal cups'], symbols: ['c'], ratio: 236.588_236_5e-6},
// https://en.wikipedia.org/wiki/Pint
{names: ['pint', 'pints', 'US liquid pint', 'US liquid pints'], symbols: ['pt', 'p'], ratio: 4.731_764_73e-4},
// https://en.wikipedia.org/wiki/Quart
{names: ['quart', 'quarts', 'US liquid quart', 'US liquid quarts'], symbols: ['qt'], ratio: 9.463_529_46e-4},
// https://en.wikipedia.org/wiki/Gallon
{names: ['gallon', 'gallons', 'US liquid gallon', 'US liquid gallons'], symbols: ['gal'], ratio: 3.785_411_784e-3},
// https://en.wikipedia.org/wiki/United_States_customary_units#Dry_volume
// https://en.wikipedia.org/wiki/Dry_measure#US_units_of_dry_measure
// https://en.wikipedia.org/wiki/Bushel
{names: ['US bushel', 'US bushels'], symbols: ['US bsh', 'US bu'], ratio: 35.239_070_166_88e-3},
// https://en.wikipedia.org/wiki/Peck
{names: ['US peck'], symbols: ['US pk'], ratio: 8.809_767_541_72e-3},
// https://en.wikipedia.org/wiki/Gallon#US_dry_gallon
{names: ['US dry gallon'], symbols: ['US dry gal'], ratio: 4.404_883_770_86e-3},
// https://en.wikipedia.org/wiki/Barrel_(unit)#Dry_goods_in_the_US
{names: ['US dry barrel', 'US dry barrels'], symbols: ['US dry bbl'], ratio: 115.6e-3},
// https://en.wikipedia.org/wiki/Quart#US_dry_quart
{names: ['US dry quart'], symbols: ['US dry qt'], ratio: 1.101_220_942_715e-3},
// https://en.wikipedia.org/wiki/Pint#US_dry_pint
{names: ['US dry pint'], symbols: ['US dry pt'], ratio: 550.610_471_357_5e-6},
],
}