-
Notifications
You must be signed in to change notification settings - Fork 7
Node Ecosystem
https://nodejs.org/docs/latest/api/modules.html#modules_the_module_wrapper
-
Node.js wraps a modules code in a function wrapper before it is executed
(function(exports, require, module, __filename, __dirname) { // Module code actually lives in here }); -
Keeps top-level variables scoped to the module rather than the global object
-
It helps to provide some global-looking variables that are actually specific to the module, such as:
- The module and exports objects that the implementor can use to export values from the module
- The convenience variables __filename and __dirname, containing the module's absolute filename and directory path
https://jrsinclair.com/articles/2016/gentle-introduction-to-javascript-tdd-intro/
- It forces one to think
- What are you trying to achieve?
- It makes debugging easier
- It makes coding more fun
- Where you write tests before you write application code
- Steps to TDD:
- Red: Write a test and make sure it fails
- Green: Write the simplest, easiest possible code to make the test pass
- Refactor: Optimize and/or simplify the application code, making sure that all the tests still pass
- Once you finish step 3, you start the cycle again by writing another test
- Writing tests
- Write the simplest test possible first
- Tests are written in the form: Describe [thing]. It should [do something]
- Checking: expect(actualValue).to.equal.(expectedValue)
- Use equal when comparing numbers, strings, or booleans, and use eql when comparing arrays or objects
- No module code until there’s a failing test
- When your tests pass, refactor your code
https://docs.travis-ci.com/user/languages/javascript-with-nodejs
-
The easiest way to specify Node.js versions is to use one or more of the latest releases in your .travis.yml
-
Optionally, your repository can contain a .nvmrc file in the repository root to specify which single version of Node.js to run your tests against
-
The default build script for projects using nodejs is:
- npm test
-
Travis CI uses npm or yarn to install your project dependencies
Note that there are no npm packages installed by default in the Travis CI environment
- V8 is Google’s open source high-performance JavaScript and WebAssembly engine
https://medium.com/sons-of-javascript/javascript-an-introduction-to-es6-1819d0d89a0f#.wb7rj1gin
- Arrow functions and let keyword; Block scopes
- Classes and inheritance; Default parameters
- Destructured assignment
- Generators; Iterators; Maps
- Promises; Rest parameters; Sets
- Spread operator; Template Literals
https://nodejs.org/en/docs/es6/
- All ES6 features are split into three groups for shipping, staged, and in progress features
https://docs.npmjs.com/files/package.json.html
- All you need to know about what’s required in your package.json file
https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/
https://docs.npmjs.com/misc/scripts
http://www.letscodejavascript.com/
https://docs.npmjs.com/about-npm/index.html