This package has been deprecated

Author message:

renamed to eachvar

drier

1.0.3 • Public • Published

David

Drier

Does repetition in code bother you to what others call an unreasonable degree?

Is DRY (Don't Repeat Yourself) such a governing rule when you write code that you regularly apply it to real life scenarios?

Do blocks of code with even this level of repetition offend you at a visceral level?

let thing = operator('thing')
let aThing = operator('aThing')
let thisThing = operator('thisThing')
let thatThing = operator('thatThing')
let theOtherThing = operator('theOtherThing')

Be offended no more: just make it drier!

let {thing, aThing, thisThing,
    thatThing, theOtherThing} = require('drier')(operator)

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

How It Works

drier is a function which invokes its input function with a string of each variable name on the left of the destructuring assignment, removing the need to repeat them, and maybe encouraging more meaningful names.

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

More Examples

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

see also

Package Sidebar

Install

npm i drier

Weekly Downloads

2

Version

1.0.3

License

MIT

Last publish

Collaborators

  • jnvm