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
| const vm = require('vm'); | |
| const fs = require('fs'); | |
| let callback; | |
| function testQuery(callback) { | |
| setTimeout(function () { callback(100500); }, 2000); | |
| } | |
| function testResult(result) { | |
| callback(result); // В данном случае callback это функция переданная при инициализации |
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
| const Promise = require('bluebird') | |
| // link to API (just sign up to get the key )): | |
| // https://rapidapi.com/divad12/api/numbers-1 | |
| const https = require('https') | |
| //======================= jsonGet Function =======================// | |
| function jsonGet (day=1, month=0){ |
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
| let promise1 = () => { | |
| return new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| resolve('promise1 done') | |
| }, 5000) | |
| }) | |
| } | |
| let promise2 = () => { | |
| return new Promise((resolve, reject) => { |
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 sortObjectProps(o) { | |
| var sorted = {}, | |
| key, a = []; | |
| for (key in o) { | |
| if (o.hasOwnProperty(key)) { | |
| a.push(key); | |
| } | |
| } |