This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir hello-ts-node | |
cd hello-ts-node | |
yarn init | |
yarn add typescript @types/node ts-node-dev | |
yarn tsc --init | |
echo "console.log('hi')" > index.ts | |
yarn ts-node-dev index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calculate = ({degrees, sourceUnit}) => { | |
const formulas = { | |
'C': degrees => degrees * 9 / 5 + 2 ** 5, | |
'F': degrees => (degrees - 32) * 5 / 9 | |
}; | |
const formula = formulas[sourceUnit] || formulas['C']; | |
const result = formula(degrees); | |
console.log(`▇⛓☀️ Blockchain calculation performed. degrees [${degrees}]. sourceUnit [${sourceUnit}]. result [${result}]`); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calculate = function calculate(_ref) { | |
var degrees = _ref.degrees, | |
sourceUnit = _ref.sourceUnit; | |
var formulas = { | |
'C': function C(degrees) { | |
return degrees * 9 / 5 + Math.pow(2, 5); | |
}, | |
'F': function F(degrees) { | |
return (degrees - 32) * 5 / 9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calculate = ({ degrees, sourceUnit }) => { | |
const formulas = { | |
'C': degrees => degrees * 9 / 5 + Math.pow(2, 5), | |
'F': degrees => (degrees - 32) * 5 / 9 | |
}; | |
const formula = formulas[sourceUnit] || formulas['C']; | |
const result = formula(degrees); | |
console.log(`▇⛓☀️ Blockchain calculation performed. degrees [${degrees}]. sourceUnit [${sourceUnit}]. result [${result}]`); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//eslint-disable-next-line | |
'use strict'; | |
const webpack = require('webpack'); | |
const path = require('path'); | |
module.exports = { | |
entry: './index.js', | |
target: 'node', | |
module: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |