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 moving = (element, emptyCell) => { | |
| const oldNode = element.childNodes[0]; | |
| element.removeChild(oldNode); | |
| element.setAttribute('class', 'p-3 table-active'); | |
| emptyCell.setAttribute('class', 'p-3'); | |
| emptyCell.append(oldNode); | |
| return; | |
| }; |
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
| export default () => { | |
| // BEGIN (write your solution here) | |
| const makeActive = (element) => { | |
| const link = element.getAttribute('href').substr(1); | |
| const currentTab = element.parentNode.parentNode.getElementsByClassName('nav-link active')[0]; | |
| const currentLink = currentTab.getAttribute('href').substr(1); | |
| const currentDiv = document.getElementById(link); | |
| const findDiv = document.getElementById(link); | |
| currentDiv.setAttribute('class', 'tab-pane'); | |
| findDiv.setAttribute('class', 'tab-pane active'); |
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 readFileAsync = file => new Promise((resolve, reject) => { | |
| fs.readFile(file, (err, data) => err ? reject(err) : resolve(data)); | |
| }); | |
| const records = async () => { | |
| const readBook = await readFileAsync('phonebook.txt'); | |
| const count = readBook.toString().split('\n').length - 1; | |
| return `Welcome to The Phonebook\nRecords count: ${count}`; | |
| }; |
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 getToken = body => body.match(/value="(\w+)"/)[1]; | |
| export default (registrationFormUrl, submitFormUrl, nickname, callback) => { | |
| // BEGIN (write your solution here) | |
| const {protocol, hostname, path, pathname, port} = url.parse(submitFormUrl); | |
| http.get(registrationFormUrl, res => { | |
| const body = []; | |
| res.on('data', chunk => { |
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
| export default (backendUrl, currentUrl) => { | |
| return new Promise((resolve, reject) => { | |
| get(backendUrl) | |
| .then(response => { | |
| if (response.status !== 200) { | |
| reject(new Error(response.status)); | |
| return; | |
| } | |
| const parseJs = JSON.parse(response.data); | |
| Promise.all(parseJs.map(element => { |
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
| export default (queryPar) => { | |
| const postData = querystring.stringify(queryPar.data); | |
| const { protocol, hostname, pathname, port, query } = url.parse(queryPar.url, true); | |
| const options = { | |
| protocol, | |
| host: hostname, | |
| path: `${pathname}${getSearch(query, queryPar.params)}`, | |
| port, | |
| method: queryPar.method, | |
| headers: { |
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 noop = () => {}; | |
| const once = (fn) => { | |
| let called = false; | |
| return (...args) => { | |
| if (called) return; | |
| called = true; | |
| fn(...args); | |
| }; |
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 noop = () => {}; | |
| const once = (fn) => { | |
| let called = false; | |
| return (...args) => { | |
| if (called) return; | |
| called = true; | |
| fn(...args); | |
| }; |
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 propertyActions = [ | |
| { | |
| name: 'body', | |
| check: arg => typeof arg === 'string', | |
| }, | |
| { | |
| name: 'children', | |
| check: arg => arg instanceof Array, | |
| }, | |
| { |
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 getAttr = (attrib) => { | |
| if (attrib.length === 0) { | |
| return []; | |
| } | |
| const keys = Object.keys(attrib); | |
| return keys.map(element => ` ${element}="${attrib[element]}"`).join(''); | |
| }; | |
| const makeObj = { | |
| tag: [], |