Skip to content

Instantly share code, notes, and snippets.

import React from 'react'
import Topbar from './Topbar'
import Sidebar from './Sidebar'
import About from './About'
import Contact from './Contact'
import PrivacyPolicy from './PrivacyPolicy'
import Dashboard from './Dashboard'
import { Router } from '@reach/router'
function App() {
function AuthValidator({ token, children, ...rest }) {
if (isAuthed(token)) {
return children({ authenticated: true })
}
return children({ authenticated: false })
}
const DeactivatorInput = ({ style, ...rest }) => (
<input
{...rest}
function AuthValidator({ token, render, ...rest }) {
if (isAuthed(token)) {
return render({ authenticated: true })
}
return render({ authenticated: false })
}
const DeactivatorInput = ({ style, ...rest }) => (
<input
{...rest}
import React from 'react'
function isAuthed(token) {
// some auth logic
}
const withAuthValidation = (WrappedComponent) => {
return (props) => {
if (isAuthed(props.token)) {
return <WrappedComponent {...props} />
{
"../javascript-algorithms/src/algorithms/math/fourier-transform/__test__": {
"name": "fourier-transform",
"category": "algorithms",
"subcategory": "math",
"totalFiles": 1,
"filesList": ["FourierTester.js"]
},
"../javascript-algorithms/src/algorithms/sets/cartesian-product/__test__": {
"name": "cartesian-product",
function createMissingTestsObject(str, dir) {
const indexToSrc = str.indexOf('src')
let category = str.substring(indexToSrc + 4)
let subcategory = category.substring(category.indexOf('/') + 1)
subcategory = subcategory.substring(0, subcategory.indexOf('/'))
category = category.substring(0, category.indexOf('/'))
return {
name: str.substring(str.lastIndexOf('/') + 1),
category,
function findEmptyTests(basepath) {
let emptyTests = {}
if (isDirectory(basepath)) {
const dir = fs.readdirSync(basepath)
for (let index = 0; index < dir.length; index++) {
const filename = dir[index]
const filepath = `${basepath}/${filename}`
function hasTest(testDir) {
for (let index = 0; index < testDir.length; index++) {
const filename = testDir[index]
if (filename.endsWith('.test.js')) {
return true
}
}
return false
}
function isDirectory(filePath) {
return fs.statSync(filePath).isDirectory()
}
import fs from 'fs'
const rootDir = '../javascript-algorithms/src'