Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.
/ block-scope Public archive

Simple helper to create block scopes, that are more readable than anonymous functions

License

Notifications You must be signed in to change notification settings

nosco/block-scope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

block-scope

A simple helper tool to create block scopes, that are easier to read than self-invoked anonymous functions.

If you feel you have seen something like this before, then it's probably because it is partly inspired by: RequireJS' define.

What's different from anonymous functions?

A self-invoked anonymous function looks something like this:

(function(that, argument1, argument2) {

  // Code that needs local scope.
  // Now imagine keeping the overview of arguments,
  // when the block of code gets large.

})(this, argument1, argument2);

A block-scope function looks something like this:

blockScope(argument1, argument2, function(argument1, argument2) {

  // Code that needs local scope.
  // This creates a nice overview of what is put in
  // and what names it get, inside the function

});

To install

npm install block-scope

Example

You can find an example in ./examples/example1.js

About

Simple helper to create block scopes, that are more readable than anonymous functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published