Giter VIP home page Giter VIP logo

scope-chains-closures's Introduction

Workshopper

Join the chat at https://gitter.im/nodeschool/workshoppers

Workshopper is no longer maintained

In mid-term workshopper will be replaced with workshopper-adventure. Please try to build new workshoppers against workshopper-adventure. Thanks. (your maintainer)

Readme until now:

A terminal workshop runner framework

NPM NPM

Learn You The Node.js For Much Win!

Workshopper is used by learnyounode, and other Node.js command-line workshop applications.

*Documentation is being written for the v1 rewrite right now! Ping @rvagg if you need anything. learnyounode is now using this new version, for now you can use it to see how this works.

For now, @linclark has written a good introduction on creating your own workshop, available here.

High-level overview

Workshopper is essentially a test-runner with a fancy terminal UI. The Workshopper package itself is largely concerned with the menu system and some of the basic command-line parsing. Much of the work for executing the exercise validation is handled by workshopper-exercise.

Contributors

workshopper is proudly brought to you by the following hackers:

Maintainers

License

Workshopper is Copyright (c) 2013-2015 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Workshopper builds on the excellent work by @substack and @maxogden who created stream-adventure which serves as the original foundation for Workshopper and learnyounode. Portions of Workshopper may also be Copyright (c) 2013 @substack and @maxogden given that it builds on their original code.

scope-chains-closures's People

Contributors

andremw avatar finnp avatar jesstelford avatar jkbits1 avatar mainarthur avatar martinheidegger avatar pfranz avatar someoneweird avatar tapsboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scope-chains-closures's Issues

A bit confused after 1. Scopes

Hi,

I found some parts of the 1. Scopes exercise a bit confusing. I finished the exercise thinking that let and const could only be used in block scopes, and not in lexical scopes. I now know this is wrong on more than one level.

Also I was thrown off by the footnote This workshop will concentrate only on Lexical Scoping. After reading the footnote I reached a section called "Block Scopes", and was wondering if there was a type of block scope that was a lexical scope.

This could all just be me, but I thought it was worth mentioning.

Thanks for the workshop :)

Can't navigate to the next lessons. Waited long, restarted console and box and no change

It doesn't seem I can use up-down arrows to go to next lesson. Its always stuck on lesson 1. I waited long and tried it and no luck. I also restarted console and run it as admin too and yet, I can't move to the next session.
Its stuck on lesson one (Scopes) and I can't get into lesson 2 Scope Chains.
As a side note: Others courses worked just fine.
Environment: I'm on Windows 10.

Exception while start on node 4.1.1

$ scope-chains-closures
...\npm\node_modules\scope-chains-closures\node_modules\adventure\lib\menu.js:51
process.stdin.setRawMode(true);
^

TypeError: process.stdin.setRawMode is not a function
at module.exports (...\npm\node_modules\scope-chains-closures\node_modules\adventure\lib\menu.js:51:19)
at Shop.showMenu (...\npm\node_modules\scope-chains-closures\node_modules\adventure\index.js:267:16)
at Shop.execute (...\npm\node_modules\scope-chains-closures\node_modules\adventure\index.js:131:14)
at Object. (...\npm\node_modules\scope-chains-closures\runner.js:26:6)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)

The closures lesson doesn't validate properly

With the following code

function foo () {
    var bar = 2;
    quuz = 13;
    function zip () {
        var quux = 9;
        bar = true;
    }
    return zip;
}

I get the output

not ok 2 The structure is correct
  ---
    operator: equal
    expected:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
    actual:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'

Cannot run the workshopper

When running this workshopper I see the following error in console

Once complete, execute @workshoppers/scope-chains-closures verify <your-file.js> to verify your
solution.

## Notes

  * [1]: There are also 4 other scopes in the language: Global, `with`, `catch`,
  *      and `eval`. These tend not to be used much, so we will ignore them.
  * 
  * 
  * [2]: This workshop will concentrate only on Lexical Scoping.


events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: shutdown ENOTCONN
    at ReadStream.Socket._final (net.js:366:25)
    at callFinal (_stream_writable.js:612:10)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

and when verifying the solution it says

ERROR: No adventure is currently selected. Select an adventure from the menu.

I assume that it is because of the above error

EPEERINVALID error when installing

Hi guys,
Just got this error when trying to install it.
I'll try to fix it by myself, if I succeed - I'll make a pull request.
npm log attached below

D:\workspace\node-learn>npm install -g scope-chains-closures
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
C:\Users\ekotsiuba\AppData\Roaming\npm\sccjs -> C:\Users\ekotsiuba\AppData\Roaming\npm\node_modules\scope-chains-closures\runner.js
C:\Users\ekotsiuba\AppData\Roaming\npm\scope-chains-closures -> C:\Users\ekotsiuba\AppData\Roaming\npm\node_modules\scope-chains-closures\runner.js
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "scope-chains-closures"
npm ERR! node v4.4.7
npm ERR! npm  v2.15.8
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants typescript@* || > 1.6.0-dev || > 1.7.0-dev || > 1.8.0-dev || > 1.9.0-dev || > 2.0.0-dev || > 2.1.0-dev || > 2.2.0-dev
npm ERR! peerinvalid Peer [email protected] wants typescript@>=1.7.3

npm ERR! Please include the following file with any support request:
npm ERR!     D:\workspace\node-learn\npm-debug.log

npm-debug.txt

DeprecationWarning

When the first workshop is selected, the following warning shows at the end of output:

(node:19020) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.

Scoping vs Scopes suggestion

Hi,

just a comment regarding scopes and scoping. I find some points in workshop to be little confusing, so I'll try to articulate it in couple of sentences.

  1. there are Lexical(static) and Dynamic Scoping
  2. there are Block, Function, Modul...Scopes

Scoping is related to how the scope chain is created. In Lexical or Static Scoping, "parent" scope of some "child" scope is determined by the place in source code where it is defined. So, the scope chain is created at the place where the certain scope (function/block) is defined. On the other hand, Lexical Scoping is contrasted by Dynamic Scoping, where scope chain is created dynamically in the place where the function is called (http://c2.com/cgi/wiki?DynamicScoping). All popular programming languages that I am aware of are Lexically Scoped.

Now, scope itself could be defined by block, function, module, etc.

So, I think it is not correct to say that variable created by var is lexically scoped and variable created with let โ€“ block scoped. Lexical scoping cannot be contrasted with block scope. var creates function scoped variables and let creates block scoped variables. Variables created with let are still Lexically Scoped, because its parent scope is determined the same way as for variables created with var, by the place where it is defined.

Can't execute workshop

When I launch the workshop, for every item of the menu, I get this error

fs.js:140
  throw new ERR_INVALID_CALLBACK();
  ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:140:9)
    at Object.fs.writeFile (fs.js:1258:14)
    at Shop.save (/usr/local/lib/node_modules/scope-chains-closures/node_modules/adventure/index.js:288:8)
    at Shop.select (/usr/local/lib/node_modules/scope-chains-closures/node_modules/adventure/index.js:246:10)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/scope-chains-closures/node_modules/adventure/index.js:278:14)
    at EventEmitter.emit (events.js:182:13)
    at Menu.<anonymous> (/usr/local/lib/node_modules/scope-chains-closures/node_modules/adventure/lib/menu.js:49:22)
    at Menu.emit (events.js:182:13)
    at Menu.ondata [as _ondata] (/usr/local/lib/node_modules/scope-chains-closures/node_modules/terminal-menu/index.js:215:18)
    at DestroyableTransform._transform (/usr/local/lib/node_modules/scope-chains-closures/node_modules/terminal-menu/index.js:50:18)

Conclusions

In the final lesson you write:

"While garbage collection occurs, it blocks the
main thread, which means other Javascript cannot be executed until the event
completes. Be conscious of how janky your application may become due to
extensive Garbage Collection events!"

There's no guidance here at all in what "janky" means, what it smells like, how to avoid it, etc etc etc.
Does it mean have just one closure? Can you have 10,000? When does it get janky? What do we use in place of closures?

I realize this is a really brief lesson, but more information seems necessary for many users to glean anything useful about Garbage collection.

Issues with tests for scopes challenge

The challenge asks us to create a function foo and lexically scope a variable bar.
My solution was

var foo = function(){
  var bar;
}

However one of the tests fail. I think the above solution is also right and should be accepted.
Correct me if I am wrong.

Unable to complete Closures exercise

My code is:

function foo(){
var bar;
function zip() {
bar = true;
}
return zip;
}

It fails with:

operator: equal
expected:
  '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
actual:
  '(global)\n\tfoo()\n\t- bar = ?\n\treturn zip\n\t\tzip()\n\t\t- bar = ?'

Move to workshopper org?

As part of an effort to update and maintain the NodeSchool curriculum, we have been asking Core Curriculum workshopper owners if they would consider moving their projects under the workshopper organization.

Would you be willing to migrate scope-chains-closures over? Discussion is linked here: workshopper/org#10 and please let me know if you have any questions!

Unable to install

I enter npm install -g scope-chains-closures into the terminal and I get the following:

path.js:1180
          cwd = process.cwd();
                        ^

Error: ENOENT: no such file or directory, uv_cwd
    at Object.resolve (path.js:1180:25)
    at Function.Module._resolveLookupPaths (module.js:419:17)
    at Function.Module._resolveFilename (module.js:522:22)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /usr/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)

Windows 7 : typeError: process.stdin.setRawMode is not a function

When I try to install this it gives this error. My node version is 4.1.2

$ sccjs
C:\Users\AJAY\AppData\Roaming\npm\node_modules\scope-chains-closures\node_modules\adventure\lib\menu.js:51
process.stdin.setRawMode(true);
^

TypeError: process.stdin.setRawMode is not a function
at module.exports (C:\Users\AJAY\AppData\Roaming\npm\node_modules\scope-chains-closures\node_modules\adventure\lib\menu.js:51:19)
at Shop.showMenu (C:\Users\AJAY\AppData\Roaming\npm\node_modules\scope-chains-closures\node_modules\adventure\index.js:267:16)
at Shop.execute (C:\Users\AJAY\AppData\Roaming\npm\node_modules\scope-chains-closures\node_modules\adventure\index.js:131:14)
at Object. (C:\Users\AJAY\AppData\Roaming\npm\node_modules\scope-chains-closures\runner.js:26:6)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:118:18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.