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
const fs = require('fs/promises') | |
const { execSync } = require('node:child_process') | |
const readJsonFile = async (filepath, encoding = 'utf8') => | |
JSON.parse(await fs.readFile(filepath, { encoding })) | |
const upgradePackage = (dependency, type = 'non-dev') => { | |
const addFlags = type === 'non-dev' ? '' : ' --dev' | |
execSync(`yarn remove ${dependency}`); | |
execSync(`yarn add ${dependency}${addFlags}`); |
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
// lookup <- one time cost | |
let dict = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
// gives the two days based on the number | |
const getDay = (num) => ([(num % 7), (num / (7 - (num % 7)))]).map((val) => dict[val]); | |
// based on the days as mentioned above | |
const getNum = (arr) => [1] | |
.concat(arr.map((val) => dict.lastIndexOf(val))) | |
.reduce((acc, val) => (acc * val)); |