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
| // Отметить идентификаторы, доступные через замыкания | |
| // Ответ: weapon, name | |
| function Samurai(name) { | |
| var weapon = 'katana'; | |
| this.getWeapon = function() { | |
| return weapon; | |
| }; | |
| this.getName = function() { | |
| return 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
| const classof = object => Object.prototype.toString.call(object).slice(8, -1); |
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
| // ответить | |
| // текущему клиенту | |
| socket.emit(EVENT_NAME, data); | |
| // клиентам этой сессии | |
| const sockets = io.sockets.sockets; | |
| const clients = Object.keys(sockets); | |
| clients.forEach(client => { | |
| if (sockets[client].handshake.sid !== socket.handshake.sid) return; | |
| sockets[client].emit(EVENT_NAME, data); | |
| }); |
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
| // SERVER | |
| const axios = require('axios'); | |
| module.exports = () => { | |
| const io = require('socket.io')(); | |
| io.listen(3000); | |
| io.on('connection', function(socket) { | |
| socket.on('SEARCH_REQUEST', query => { | |
| axios |
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 metadata = { | |
| title: 'Scratchpad', | |
| translations: [ | |
| { | |
| locale: 'de', | |
| title: 'Javascript-Umgebung' | |
| } | |
| ], | |
| url: '/en-US/dosc/Tools/Scratchpad' | |
| }; |
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
| import fs from 'fs'; | |
| const print1 = path => { | |
| fs.readFile(path, (err, content) => console.log(content.toString())); | |
| } | |
| const print2 = path => fs.readFile( | |
| path, | |
| 'utf-8', | |
| (error, data) => console.log(data), |
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
| //@flow | |
| import React, { useState, useEffect } from 'react'; | |
| type IProps = { | |
| initial?: number, | |
| }; | |
| export default function HookExample({ initial = 0 }: IProps) { | |
| const [fuckingCount, setFuckingCount] = useState(initial); |
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
| import React, { useState, useEffect } from 'react'; | |
| function useFriendStatus(friendID) { | |
| const [isOnline, setIsOnline] = useState(null); | |
| function handleStatusChange(status) { | |
| setIsOnline(status.isOnline); | |
| } | |
| useEffect(() => { |
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
| import { Select, Spin } from 'antd'; | |
| import { IProfile } from 'modules/user/types'; | |
| import React, { useState } from 'react'; | |
| import debounce from 'lodash/debounce'; | |
| import uniqWith from 'lodash/uniqWith'; | |
| const { Option } = Select; | |
| interface IResponse { |