* Inject properties from unit. * @private * @param {String} unit * @param {Number|String} value * @returns {Amount}
(unit, value)
| 205 | */ |
| 206 | |
| 207 | from(unit, value) { |
| 208 | switch (unit) { |
| 209 | case 'sat': |
| 210 | return this.fromSatoshis(value); |
| 211 | case 'ubtc': |
| 212 | case 'bits': |
| 213 | return this.fromBits(value); |
| 214 | case 'mbtc': |
| 215 | return this.fromMBTC(value); |
| 216 | case 'btc': |
| 217 | return this.fromBTC(value); |
| 218 | } |
| 219 | throw new Error(`Unknown unit "${unit}".`); |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Instantiate amount from options. |
no test coverage detected