This file contains hidden or 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
pragma solidity ^0.4.24; | |
import "./IERC20.sol"; | |
contract TransferToMany { | |
address owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
This file contains hidden or 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
pragma solidity ^0.4.24; | |
contract SimpleContract { | |
uint public paymentCount = 0; | |
event PaymentReceived(uint value, address sender); | |
address public owner; | |
constructor() public { |
This file contains hidden or 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
pragma solidity ^0.4.24; | |
contract PayToSignatureHash { | |
mapping(bytes32 => uint) public balances; | |
function payToHash(bytes32 hash) public payable { | |
balances[hash] += msg.value; | |
} |
This file contains hidden or 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
function wait(waitTime) { | |
return new Promise(resolve => setTimeout(() => { | |
console.log(`waited ${waitTime} ms`) | |
resolve() | |
}, waitTime)); | |
} | |
async function serial() { | |
console.time('serial'); | |
await wait(1000); |
This file contains hidden or 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
function randomNumber() { | |
const rand = Math.random() * 100; | |
return new Promise(resolve => setTimeout(() => { | |
resolve(rand) | |
}, 1000)) | |
} | |
async function addExampleSerial() { | |
console.time('add-serial'); | |
const number1 = await randomNumber(); |
This file contains hidden or 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
function fetchData(data) { | |
return new Promise(resolve => setTimeout(() => { | |
resolve(data) | |
}, 1000)) | |
} | |
function getLoggedInUser() { | |
return fetchData('user1'); | |
} |
This file contains hidden or 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
/* given an object of type T, | |
* log the value of a property, specified by the argument key | |
*/ | |
function logValue<T>(obj: T, key: keyof T) { | |
console.log(obj[key]); | |
} | |
function simpleTest() { | |
const Micah = {name: 'Micah'}; | |
logValue(Micah, "name") |
This file contains hidden or 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
interface Person { | |
name: string; | |
age: number; | |
} | |
interface Car { | |
modelName: string; | |
year: number; | |
} |
This file contains hidden or 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
interface Person { | |
name: string; | |
age: number; | |
} | |
interface Car { | |
modelName: string; | |
year: number; | |
} |
This file contains hidden or 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
function getPeople() { | |
return [{name: "Bob"}, {name: "Sam"}, {name: "Tom"}]; | |
} | |
function test1() { | |
const [firstPerson] = getPeople(); | |
console.log(firstPerson); | |
} | |
function test2() { | |
const [firstPerson, ...rest] = getPeople(); | |
console.log(rest); |