new Steradian()
Creates an empty instance of Steradian.
Use an instance of Steradian to construct new Quantities, Units,
and Systems, and perform conversions between them.
Examples
// this instance comes pre-loaded with SI and Imperial.
const Sr = require('steradian');
// the main module is also a function.
const Steradian = require('steradian');
// constructed instances are empty and fully customizable.
const Sr = Steradian();
Methods
-
convert(quantity, targetUnitsOrSystem) → {Quantity}
-
Converts the given quantity to the target Units or System. If targetUnitsOrSystem is a string, then it must correspond to a defined Unit or System.
Parameters:
Name Type Description quantity
Quantity targetUnitsOrSystem
string | Unit | UnitExpression | System Returns:
Quantity -
derivedUnit(def) → {DerivedUnit}
-
Creates a new DerivedUnit from the given DerivedUnitDefinition.
Parameters:
Name Type Description def
DerivedUnitDefinition Returns:
DerivedUnit -
quantity(unitExpression, value) → {Quantity}
-
Constructs a Quantity from the given unitExpression and value.
Parameters:
Name Type Description unitExpression
string | Unit | UnitExpression A Unit name, Unit instance or UnitExpression from which to construct a Quantity. value
number the numeric value associated with the Quantity. Returns:
Quantity -
system(idOrDefOrSystem) → {System}
-
Gets a System by the specified name, or creates a new System according to the given SystemDefinition.
Parameters:
Name Type Description idOrDefOrSystem
string | SystemDefinition | System Returns:
System -
unit(idOrDef) → {Unit}
-
Gets a Unit (either BaseUnit or DerivedUnit) by the specified name, or creates a new BaseUnit according to the given BaseUnitDefinition.
Parameters:
Name Type Description idOrDef
string | BaseUnitDefinition String representing the id of the Unit to retrieve, or Object containing definition of a new Unit. Returns:
Unit