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 { resetIdCounter, useCombobox } from 'downshift' | |
| import Image from 'next/image' | |
| import { useEffect, useRef, useState } from 'react' | |
| import debounce from 'lodash/debounce' | |
| import { DropDown, DropDownItem, SearchStyles } from './styled/DropDown' | |
| import useSearch from '../hooks/useSearch' | |
| function Search() { | |
| resetIdCounter() | |
| const [searchTerm, setSearchTerm] = useState<string | undefined>('') |
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 { client } from '../utils/httpClient'; | |
| type User = { | |
| _id: string; | |
| name: string; | |
| email: string; | |
| photo: string; | |
| credits: number; | |
| } | 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
| if (!Object.is || true) { | |
| Object.is = function ObjectIs(x, y) { | |
| var xNegZero = isItNegZero(x); | |
| var yNegZero = isItNegZero(y); | |
| if(xNegZero || yNegZero) { | |
| return xNegZero && yNegZero; | |
| } else if (isItNaN(x) && isItNaN(y)) { | |
| return true; | |
| } else { |
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 ProviderComposer({ contexts, children }) { | |
| return contexts.reduceRight( | |
| (kids, parent) => | |
| React.cloneElement(parent, { | |
| children: kids, | |
| }), | |
| children | |
| ); | |
| } |
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
| // Private variable | |
| var books = []; | |
| // Private functions | |
| // Sort the books in alphabetical order | |
| function sortBooks() { | |
| return books.sort((a, b) => (a > b ? 1 : -1)); | |
| } | |
| // Public functions |
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 webpack = require('webpack'); | |
| const path = require('path'); | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| const nodeEnv = process.env.NODE_ENV || 'development'; | |
| const isProd = nodeEnv === 'production'; | |
| const sourcePath = path.join(__dirname, './client'); | |
| const staticsPath = path.join(__dirname, './static'); |
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
| var MyChatController = (function(io, $, moment, Mustache) { | |
| var socket = io(); | |
| /* | |
| appController - Main chat control | |
| */ | |
| var appCtrl = { | |
| init: function() { | |
| console.log('App started.'); | |
| uiCtrl.setupEventListeners(); | |
| networkCtrl.init(); |
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
| var socket = io(); | |
| function scrollToBottom() { | |
| // Selectors | |
| var messages = jQuery('#messages'); | |
| var newMessage = messages.children('li:last-child'); | |
| // Heights | |
| var clientHeight = messages.prop('clientHeight'); | |
| var scrollTop = messages.prop('scrollTop'); | |
| var scrollHeight = messages.prop('scrollHeight'); |
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 balanceParens(string) { | |
| return !string.split('').reduce((previous, char) => { | |
| if (previous < 0) { return previous; } | |
| if (char === '(') { return ++previous; } | |
| if (char === ')') { return --previous; } | |
| return previous; | |
| }, 0); | |
| } | |
| balanceParens(")((())())()("); |