Skip to content
/ eachVar Public

let {each,varName,be,iterable} = eachVar(x => /* do thing */ )

Notifications You must be signed in to change notification settings

jnvm/eachVar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

David

eachVar

Instead of this:

let thing = some.operator('thing')
let aThing = some.operator('aThing')
let thisThing = some.operator('thisThing')
let thatThing = some.operator('thatThing')
let theOtherThing = some.operator('theOtherThing')
//...and so on!

Do this:

const eachVar = require('eachvar')
let {thing, aThing, thisThing, 
	thatThing, theOtherThing} = eachVar(some.operator)

...and through the magic of destructuring and proxies, never stutter variables in code again!

More signal, less noise.

How It Works

eachVar(iterateeFunction) is a function which invokes its input function with a string of each variable name on the left of the destructuring assignment in order, removing the need to repeat them on each side of the equal sign, and maybe encouraging more meaningful names.

Or you could describe it as an iterator across variable names.

More Examples

const eachVar = require('eachvar')
const dryquire = eachVar(require)
const {fs, crypto, util, http, os, repl, express, "package.json":{scripts}} = dryquire
const {sqlA, sqlB, sqlC, sqlD} = eachVar(s => fs.readFileSync(`${__dirname}/${s}.sql`))

see also

About

let {each,varName,be,iterable} = eachVar(x => /* do thing */ )

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published