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
| class NewMessages extends Rect.Component { | |
| updateInterval; | |
| componentDidMount() { | |
| this.updateInterval = setInterval(() => { | |
| this.props.getNewMessages(); | |
| }, 500); | |
| } | |
| componentWillUnmount() { |
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 * as React from 'react'; | |
| import { Loader } from 'path-to-loader'; | |
| import { Swiper } from 'path-to-swiper'; | |
| class PullToUpdate extends React.PureComponent { | |
| state = { | |
| translate: 0 | |
| }; | |
| rootNode = null; |
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 * as React from 'react'; | |
| class Swiper extends React.PureComponent { | |
| startPointX = 0; | |
| startPointY = 0; | |
| direction = null; | |
| clicked = false; | |
| onMoveStart = ({ event, x, y }) => { | |
| const { onMoveStart } = this.props; |
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
| users | |
| .filter(({ active }) => active) | |
| .map(({ age }) => (age + 100) % 27) | |
| .reduce((p, c) => c > 20 ? p.concat(c) : p, []); |
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
| reduce(map(filter(users, ({ active }) => active), ({ age }) => (age + 100) % 27), (p, c) => c > 20 ? p.concat(c) : p, []); |
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
| /** | |
| * Main function | |
| */ | |
| function find(collection, predicate, fromIndex) { | |
| let iteratee | |
| const iterable = Object(collection) | |
| if (!isArrayLike(collection)) { | |
| collection = keys(collection) | |
| iteratee = (key) => predicate(iterable[key], key, iterable) |
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 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
| const timerDateReduceLodash = new Date(); | |
| console.log('lodash reduce', reduce(numbers, (sum, n) => sum + n, 0)); | |
| console.log('lodash time', new Date() - timerDateReduceLodash); | |
| const timerDateReduceJS = new Date(); | |
| console.log('native reduce', numbers.reduce((sum, n) => sum + n, 0)); | |
| console.log('native time', new Date() - timerDateReduceJS); |
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 users = [ | |
| { 'user': 'barney', 'age': 36, 'active': true }, | |
| { 'user': 'fred', 'age': 40, 'active': false }, | |
| { 'user': 'pebbles', 'age': 1, 'active': true } | |
| ]; | |
| const timerDateFindLodash = new Date(); | |
| console.log('lodash find', find(users, ({ age }) => age < 40)); | |
| console.log('lodash time', new Date() - timerDateFindLodash); |
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
| // stop observing | |
| observer.disconnect(); | |
| // empties observer instance and returns records | |
| observer.takeRecords(); // -> MutationRecords |
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
| // target element that we will observe | |
| const target = document.querySelector('div'); | |
| // config object | |
| const config = { | |
| characterData: true, | |
| characterDataOldValue: true, | |
| childList: true, | |
| subtree: true | |
| }; |