Skip to content

Instantly share code, notes, and snippets.

View chaoticbit's full-sized avatar
🏠
Working from home

Atharva Dandekar chaoticbit

🏠
Working from home
  • Salesforce.com
  • San Francisco, CA, United States
View GitHub Profile
@chaoticbit
chaoticbit / hooks.js
Created November 6, 2020 07:19
React Hooks
import { useEffect, useRef, useReducer } from 'react';
export const useFetch = (url) => {
const cache = useRef({});
const initialState = {
status: 'idle',
error: null,
data: [],
};
@chaoticbit
chaoticbit / file-utils.js
Last active February 13, 2019 04:07
JS Utils
/**
Method to remove directory and files recursively &
check if user wants to delete the directory or just the files in it.
**/
const fs = require('fs');
const path = require('path');
function rmDir(dir, rmSelf = true) {
let files;
try {
files = fs.readdirSync(dir);