Skip to content

Instantly share code, notes, and snippets.

Avatar

Melody funfunction

View GitHub Profile
View genRandNums.js
/**
@func
generate an arr of random nums
- containing numbers only between the supplied min and max
@param {number} min - smallest num in arr
@param {number} max - largest num in arr
@param {number} len - length of the arr to create
@return {number[]}
*/
View bstClass.js
/*
@file
@legend
n = node
@tasks
minnode method is missing
*/
View timeInLoop.js
/**
@func
log how long it takes to run a block of code
- for a supplied number of times
@warning
the supplied func runs in a loop
- so first make sure there are no log statements in the func
- either comment them out, or replace them with lMock...
- const l = s => undefined; //lMock
View isNotObj.js
/**
@func complement
confirm that the supplied value is not an obj
@param {*} v expect anything but an obj
@return {boolean}
*/
export const isNotObj = v => !isObj(v);
View lruCacheMap.js
/**
@func
Map object factory
@return {Map}
*/
export const createLruMap = () => new Map();
/**
View VisualStudioCode_settings_editorFontColors.js
// place this into your Visual Studio Code (VSC) settings json file (I have it in my Workspace settings, not User settings)
// res: explanation and contact here... https://dev.to/functional_js/visual-studio-code-my-color-syntax-settings-2kl6
//colors ////////////////////////////////////////////////////////
"workbench.colorTheme": "Default High Contrast",
// "workbench.colorTheme":"Default Dark+",
//already black, but as an example
"workbench.colorCustomizations": {
"sideBar.background": "#000",
"editorLineNumber.foreground": "#203752",
"terminal.background": "#07000c",
View isNil.js
/**
@func
true if var is null or undefined
@param {*} v
@return {boolean}
*/
export const isNil = v => v === undefined || v === null;
//@tests
View logForeachParam.js
/**
@func
with a supplied func and a supplied arr of args
- the func will invoke once for each arg in the arr
apply the func to each arg in the arr
@cons
this variant only supports funcs that are unary (argument count of one)
@param {(v: *) => *} fn - the func to be invoked for each elem in the arr
View isCcValidLuhn.js
/**
@func
calculate if credit card number is valid
@param {number|string} ccn Credit Card Number
@return {boolean}
*/
const isCcValidLuhn = ccn => {
const sum = ccn
.toString()