UNPKG

@neutrium/thermo

Version:

The base module of the NeutriumJS thermodynamics package.

34 lines (33 loc) 1.21 kB
"use strict"; var EquationOfState = (function () { function EquationOfState() { } /* * Determines the calculation mode given the provided property inputs * * @param {array} inputs An array of the input properties e.g ['p', 't']. * @param {array} modes An array of the supported modes e.g. [['p','t'], ['p','rho']]. * @return {integer} The index of the mode matched from modes or -1 */ EquationOfState.prototype.findModeIndex = function (inputs) { var inputList = Object.keys(inputs), noInputs = inputList.length, noModes = this.modes.length; for (var i = 0; i < noModes; i++) { var mode = this.modes[i], matched = true; for (var j = 0, len = mode.length; j < len; j++) { if (inputList.indexOf(mode[j]) === -1) { // An property of this mode is not matched in inputs matched = false; break; } } if (matched) { return i; } else { return -1; } } }; return EquationOfState; }()); exports.EquationOfState = EquationOfState;