This file contains 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
src/serviceWorker.ts |
This file contains 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 { useState, useEffect } from "react"; | |
/* H/T: | |
Avoiding Race Conditions and Memory Leaks in React useEffect | |
https://javascript.plainenglish.io/avoiding-race-conditions-and-memory-leaks-in-react-useeffect-2034b8a0a3c7 | |
*/ | |
interface IUseFetchWithAbortResponse { | |
fetchedData: unknown; | |
isLoading: boolean; |
This file contains 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
// This function takes a Generic of FoodType | |
function makeABunchOf<FoodType>(food: FoodType, howMany: number): FoodType[] { | |
const foodArray = Array.from({ length: howMany }, () => food); | |
return foodArray; | |
} | |
// Make our Food Types | |
interface Pizza { name: string; slices: number; } | |
interface Sandwich { name: string; veggie: boolean; } | |
// Make some Food |
This file contains 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
export const getNUmberSuffix = (number: number): string => { | |
const thExceptions = (number: number) => | |
[11, 12, 13].some((exception) => exception === number); | |
const lastDigit = number % 10; | |
if (thExceptions(number) || lastDigit === 0 || lastDigit > 3) | |
return `${number}th`; | |
if (lastDigit === 1) return `${number}st`; | |
if (lastDigit === 2) return `${number}nd`; | |
return `${number}rd`; |
This file contains 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
export const truncateText = (text, characterLimit, addEllipsis = true) => { | |
if (text.length <= characterLimit) { | |
return text | |
} else { | |
const specialChars = ['.',',','!','?','-','—',' '] | |
let truncatedText = text.substring(0, characterLimit) | |
if (addEllipsis) { | |
const lastTruncatedChar = () => truncatedText.charAt(truncatedText.length - 1) | |
const hasSpecialLastChar = () => specialChars.includes(lastTruncatedChar()) |
This file contains 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
{ | |
"git.autofetch": true, | |
"editor.fontFamily": "Fira Code", | |
"editor.fontSize": 13, | |
"editor.fontLigatures": true, | |
"workbench.iconTheme": "vscode-icons", | |
"files.exclude": { | |
"**/node_modules": true, | |
"**/gems": true, | |
"**/._*": true, |
This file contains 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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
//Read the package.json (optional) | |
pkg: grunt.file.readJSON('package.json'), | |
// Metadata. | |
meta: { |
This file contains 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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
//Read the package.json (optional) | |
pkg: grunt.file.readJSON('package.json'), | |
// Metadata. | |
meta: { |
This file contains 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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' | |
} | |
}, |
This file contains 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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
//Read the package.json (optional) | |
pkg: grunt.file.readJSON('package.json'), | |
// Metadata. | |
meta: { |
NewerOlder