Skip to content

Instantly share code, notes, and snippets.

View funfunction's full-sized avatar

S.A. funfunction

View GitHub Profile
/**
@func
calculate if credit card number is valid
@param {number|string} ccn Credit Card Number
@return {boolean}
*/
const isCcValidLuhn = ccn => {
const sum = ccn
.toString()
@funfunction
funfunction / logForeachParam.js
Last active January 10, 2022 16:23
logForeachParam
/**
@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
/**
@func
true if var is null or undefined
@param {*} v
@return {boolean}
*/
export const isNil = v => v === undefined || v === null;
//@tests
// 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",
/**
@func
Map object factory
@return {Map}
*/
export const createLruMap = () => new Map();
/**
/**
@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);
/**
@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
/*
@file
@legend
n = node
@tasks
minnode method is missing
*/
/**
@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[]}
*/