Skip to content

Instantly share code, notes, and snippets.

View Joe1220's full-sized avatar

Joe1220

View GitHub Profile
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2015",
"sourceMap": true
},
"include": ["index.ts"],
"exclude": ["node_modules"]
}
var binarySearch = function (array, target) {
var guess, min = 0, max = array.length - 1;
while(min <= max) {
guess = Math.floor((min + max) / 2);
if(array[guess] === target) {
return guess;
} else if(array[guess] < target) {
min = guess + 1;
} else {
var binarySearch = function (array, target) {
var guess, min = 0, max = array.length - 1;
while(min <= max) {
guess = Math.floor((min + max) / 2);
if(array[guess] === target) {
return guess;
}
}
};
var binarySearch = function (array, target) {
var guess, min = 0, max = array.length - 1;
};
var index = binarySearch([1, 2, 3, 4, 5], 4);
import { connect } from "react-redux";
import { actionCreators as procutsActions } from "redux/modules/products";
import Container from "./container";
const mapStateToProps = (state, ownProps) => {
const { products: { items } } = state;
const { routing: { location } } = state;
return {
location: location.pathname,
items
import { connect } from "react-redux";
import { actionCreators as procutsActions } from "redux/modules/products";
import Container from "./container";
const mapStateToProps = (state, ownProps) => {
const { products: { items } } = state;
return {
items
};
};
import React, { Component } from "react";
import data from "MOCK_DATA.json";
import App from "./presenter";
class Container extends Component {
constructor() {
super();
this.state = {
products: [],
cart: [],
import React, { Component } from "react";
import { Route, Switch } from "react-router-dom";
import Nav from "components/Nav/Nav";
import Cart from "components/Cart/Cart";
import Main from "components/Main/Main";
import Item from "components/Item/Item";
class App extends Component {
import React from "react";
import ReactDOM from "react-dom";
import App from "components/App";
import { Provider } from "react-redux";
import { ConnectedRouter } from 'react-router-redux';
import store, { history } from 'redux/configureStore';
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
import { combineReducers, createStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import { routerReducer, routerMiddleware } from "react-router-redux";
import products from "redux/modules/products";
import createHistory from "history/createBrowserHistory";
import { composeWithDevTools } from "redux-devtools-extension";
const env = process.env.NODE_ENV;
const history = createHistory()