1.0.0 • Published 9 months ago

returndotjs v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Return.js

Returning, but better.

Instead of doing this..

function add(a, b) {
  return a + b
}

...you can now do this!

require('returndotjs')

functions.add = function(a, b) {
  _return(a + b)
}
const add = functions.add

Or this:

const { functions, _return } = require('returndotjs/safe')

functions.add = function(a, b) {
  _return(a + b)
}
const add = functions.add

And then...

console.log(add(1, 2))

which outputs 3!

Important Note

Using Return.js will work with the following examples:

require('returndotjs')

functions.hi = function () {
  _return("hi")
}

// or

functions.hi = () => {
  _return("hi")
}

But it won't work like this:

const hi = functions.hi = () => {
  _return("hi")
}

console.log(hi()) // undefined

or in any other way than the given examples that work.

1.0.0

9 months ago