├── .gitignore
├── 2_client_side
├── client
│ ├── app
│ │ ├── main.js
│ │ └── utils
│ │ │ └── index.js
│ └── index.html
├── dist
│ ├── app.bundle.js
│ └── index.html
├── gulpfile.js
├── lib
│ └── app.js
└── package.json
├── 3_server_side
├── client
│ ├── app
│ │ ├── main.js
│ │ └── utils
│ │ │ └── index.js
│ └── index.html
├── dist
│ ├── app.bundle.js
│ └── index.html
├── gulpfile.js
├── lib
│ └── app.js
├── package.json
├── portable
│ └── index.js
└── server.js
├── 4_classes
├── client
│ ├── app
│ │ ├── Polygon.js
│ │ ├── Square.js
│ │ ├── main.js
│ │ └── utils
│ │ │ └── index.js
│ └── index.html
├── dist
│ ├── app.bundle.js
│ └── index.html
├── gulpfile.js
├── lib
│ └── app.js
├── package.json
├── portable
│ └── index.js
└── server.js
├── 5_generators
├── client
│ ├── app
│ │ ├── main.js
│ │ └── utils
│ │ │ └── index.js
│ └── index.html
├── dist
│ ├── app.bundle.js
│ └── index.html
├── gulpfile.js
├── lib
│ └── app.js
├── package.json
├── portable
│ └── index.js
└── server.js
├── 6_other_stuff
├── client
│ ├── app
│ │ ├── main.js
│ │ └── utils
│ │ │ └── index.js
│ └── index.html
├── dist
│ ├── app.bundle.js
│ └── index.html
├── gulpfile.js
├── lib
│ └── app.js
├── package.json
├── portable
│ └── index.js
└── server.js
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 | .DS_Store
--------------------------------------------------------------------------------
/2_client_side/client/app/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 |
5 | console.log('Client side code started');
6 |
7 | utils.count();
8 |
--------------------------------------------------------------------------------
/2_client_side/client/app/utils/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | count
5 | };
6 |
7 | function count() {
8 | var count = 0;
9 | setInterval(() => console.log(count++), 400);
10 | }
11 |
--------------------------------------------------------------------------------
/2_client_side/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/2_client_side/dist/app.bundle.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/2_client_side/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var babelify = require('babelify');
5 | var browserify = require('browserify');
6 | var source = require('vinyl-source-stream');
7 |
8 | gulp.task('build', function () {
9 | browserify({
10 | entries: './client/app/main.js',
11 | debug: true
12 | })
13 | .transform(babelify)
14 | .bundle()
15 | .pipe(source('app.bundle.js'))
16 | .pipe(gulp.dest('./dist'));
17 | });
18 |
19 | gulp.task('copy', function () {
20 | gulp.src('client/index.html')
21 | .pipe(gulp.dest('./dist'));
22 | });
23 |
24 | gulp.task('watch', function () {
25 | gulp.watch('client/**/*.js', ['build']);
26 | gulp.watch('client/*.html', ['copy']);
27 | });
28 |
29 | gulp.task('default', ['copy', 'build', 'watch']);
30 |
--------------------------------------------------------------------------------
/2_client_side/lib/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var express = require('express');
4 | var app = express();
5 | var iso = require('../portable')
6 |
7 | var server = require('http').createServer(app);
8 | app.use('/', express.static(__dirname + '/../dist', { maxAge: 1000000 }));
9 | server.listen(9000, () => console.log('App started'));
10 | console.log(iso.validateId('USER_sdfwe23'));
11 |
--------------------------------------------------------------------------------
/2_client_side/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-starter",
3 | "version": "1.0.0",
4 | "description": "Starting project for babel, browserify, gulp projects",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "author": "",
9 | "license": "MIT",
10 | "devDependencies": {
11 | "babel": "^5.2.6",
12 | "babelify": "^6.0.2",
13 | "browserify": "^10.0.0",
14 | "gulp": "^3.8.11",
15 | "vinyl-source-stream": "^1.1.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/3_server_side/client/app/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var iso = require('../../portable');
5 |
6 | console.log('Client side code started');
7 |
8 | console.log(iso.validateId('werwef4wg'));
9 |
10 | utils.count();
11 |
--------------------------------------------------------------------------------
/3_server_side/client/app/utils/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | count
5 | };
6 |
7 | function count() {
8 | var count = 0;
9 | setInterval(() => console.log(count++), 400);
10 | }
11 |
--------------------------------------------------------------------------------
/3_server_side/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/3_server_side/dist/app.bundle.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/3_server_side/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var babelify = require('babelify');
5 | var browserify = require('browserify');
6 | var source = require('vinyl-source-stream');
7 |
8 | gulp.task('build', function () {
9 | browserify({
10 | entries: './client/app/main.js',
11 | debug: true
12 | })
13 | .transform(babelify)
14 | .bundle()
15 | .pipe(source('app.bundle.js'))
16 | .pipe(gulp.dest('./dist'));
17 | });
18 |
19 | gulp.task('copy', function () {
20 | gulp.src('client/index.html')
21 | .pipe(gulp.dest('./dist'));
22 | });
23 |
24 | gulp.task('watch', function () {
25 | gulp.watch('client/**/*.js', ['build']);
26 | gulp.watch('client/*.html', ['copy']);
27 | });
28 |
29 | gulp.task('default', ['copy', 'build', 'watch']);
30 |
--------------------------------------------------------------------------------
/3_server_side/lib/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var express = require('express');
4 | var app = express();
5 | var iso = require('../portable')
6 |
7 | var server = require('http').createServer(app);
8 | app.use('/', express.static(__dirname + '/../dist', { maxAge: 1000000 }));
9 | server.listen(9000, () => console.log('App started'));
10 | console.log(iso.validateId('USER_sdfwe23'));
11 |
--------------------------------------------------------------------------------
/3_server_side/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-starter",
3 | "version": "1.0.0",
4 | "description": "Starting project for babel, browserify, gulp projects",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "MIT",
11 | "devDependencies": {
12 | "babelify": "^6.0.2",
13 | "browserify": "^10.0.0",
14 | "gulp": "^3.8.11",
15 | "vinyl-source-stream": "^1.1.0"
16 | },
17 | "dependencies": {
18 | "babel": "^5.2.6",
19 | "express": "^4.12.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/3_server_side/portable/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | validateId
5 | };
6 |
7 | const ID_PREFIX = 'USER_';
8 | function validateId(id) {
9 | return typeof id == 'string' && id.indexOf(ID_PREFIX) === 0;
10 | }
11 |
--------------------------------------------------------------------------------
/3_server_side/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('babel/register');
4 |
5 | require('./lib/app');
6 |
--------------------------------------------------------------------------------
/4_classes/client/app/Polygon.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | class Polygon {
4 | constructor(width, height) {
5 | this.name = 'Polygon';
6 | this.width = width;
7 | this.height = height;
8 | }
9 |
10 | sayName() {
11 | console.log('Hi, my name is ' + this.name);
12 | }
13 | }
14 |
15 | module.exports = Polygon;
--------------------------------------------------------------------------------
/4_classes/client/app/Square.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Polygon = require('./Polygon');
4 |
5 | class Square extends Polygon {
6 | constructor(length=10) {
7 | super(length, length);
8 | this.name = 'Square';
9 | }
10 |
11 | get area() {
12 | return this.height * this.width;
13 | }
14 | }
15 |
16 | module.exports = Square;
--------------------------------------------------------------------------------
/4_classes/client/app/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var iso = require('../../portable');
5 | var Square = require('./Square');
6 |
7 |
8 | console.log('Client side code started');
9 |
10 | var s1 = new Square(5);
11 | var s2 = new Square();
12 |
13 | console.log(s1.area, s2.area);
14 | s1.sayName();
--------------------------------------------------------------------------------
/4_classes/client/app/utils/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | count
5 | };
6 |
7 | function count() {
8 | var count = 0;
9 | setInterval(() => console.log(count++), 400);
10 | }
11 |
--------------------------------------------------------------------------------
/4_classes/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/4_classes/dist/app.bundle.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/4_classes/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var babelify = require('babelify');
5 | var browserify = require('browserify');
6 | var source = require('vinyl-source-stream');
7 |
8 | gulp.task('build', function () {
9 | browserify({
10 | entries: './client/app/main.js',
11 | debug: true
12 | })
13 | .transform(babelify)
14 | .bundle()
15 | .pipe(source('app.bundle.js'))
16 | .pipe(gulp.dest('./dist'));
17 | });
18 |
19 | gulp.task('copy', function () {
20 | gulp.src('client/index.html')
21 | .pipe(gulp.dest('./dist'));
22 | });
23 |
24 | gulp.task('watch', function () {
25 | gulp.watch('client/**/*.js', ['build']);
26 | gulp.watch('client/*.html', ['copy']);
27 | });
28 |
29 | gulp.task('default', ['copy', 'build', 'watch']);
30 |
--------------------------------------------------------------------------------
/4_classes/lib/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var express = require('express');
4 | var app = express();
5 | var iso = require('../portable')
6 |
7 | var server = require('http').createServer(app);
8 | app.use('/', express.static(__dirname + '/../dist', { maxAge: 1000000 }));
9 | server.listen(9000, () => console.log('App started'));
10 |
--------------------------------------------------------------------------------
/4_classes/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-starter",
3 | "version": "1.0.0",
4 | "description": "Starting project for babel, browserify, gulp projects",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "MIT",
11 | "devDependencies": {
12 | "babelify": "^6.0.2",
13 | "browserify": "^10.0.0",
14 | "gulp": "^3.8.11",
15 | "vinyl-source-stream": "^1.1.0"
16 | },
17 | "dependencies": {
18 | "babel": "^5.2.6",
19 | "express": "^4.12.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/4_classes/portable/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | validateId
5 | };
6 |
7 | const ID_PREFIX = 'USER_';
8 | function validateId(id) {
9 | return typeof id == 'string' && id.indexOf(ID_PREFIX) === 0;
10 | }
11 |
--------------------------------------------------------------------------------
/4_classes/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('babel/register');
4 |
5 | require('./lib/app');
6 |
--------------------------------------------------------------------------------
/5_generators/client/app/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var iso = require('../../portable');
5 |
6 | console.log('Client side code started');
7 |
8 | //move to new lesson (4?)
9 | console.log(iso.fibonacci.next());
10 | console.log(iso.fibonacci.next());
11 | console.log(iso.fibonacci.next());
12 | console.log(iso.fibonacci.next());
13 | console.log(iso.fibonacci.next());
14 | console.log(iso.fibonacci.next());
15 | console.log(iso.fibonacci.next());
16 | console.log(iso.fibonacci.next());
17 | console.log(iso.fibonacci.next());
--------------------------------------------------------------------------------
/5_generators/client/app/utils/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | count
5 | };
6 |
7 | function count() {
8 | var count = 0;
9 | setInterval(() => console.log(count++), 400);
10 | }
11 |
--------------------------------------------------------------------------------
/5_generators/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/5_generators/dist/app.bundle.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/5_generators/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var babelify = require('babelify');
5 | var browserify = require('browserify');
6 | var source = require('vinyl-source-stream');
7 |
8 | gulp.task('build', function () {
9 | browserify({
10 | entries: './client/app/main.js',
11 | debug: true
12 | })
13 | .transform(babelify)
14 | .bundle()
15 | .pipe(source('app.bundle.js'))
16 | .pipe(gulp.dest('./dist'));
17 | });
18 |
19 | gulp.task('copy', function () {
20 | gulp.src('client/index.html')
21 | .pipe(gulp.dest('./dist'));
22 | });
23 |
24 | gulp.task('watch', function () {
25 | gulp.watch('client/**/*.js', ['build']);
26 | gulp.watch('client/*.html', ['copy']);
27 | });
28 |
29 | gulp.task('default', ['copy', 'build', 'watch']);
30 |
--------------------------------------------------------------------------------
/5_generators/lib/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var express = require('express');
4 | var app = express();
5 | var iso = require('../portable')
6 |
7 | var server = require('http').createServer(app);
8 | app.use('/', express.static(__dirname + '/../dist', { maxAge: 1000000 }));
9 | server.listen(9000, () => console.log('App started'));
10 |
--------------------------------------------------------------------------------
/5_generators/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-starter",
3 | "version": "1.0.0",
4 | "description": "Starting project for babel, browserify, gulp projects",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "MIT",
11 | "devDependencies": {
12 | "babelify": "^6.0.2",
13 | "browserify": "^10.0.0",
14 | "gulp": "^3.8.11",
15 | "vinyl-source-stream": "^1.1.0"
16 | },
17 | "dependencies": {
18 | "babel": "^5.2.6",
19 | "express": "^4.12.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/5_generators/portable/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | validateId,
5 | fibonacci: fibonacci()
6 | };
7 |
8 | const ID_PREFIX = 'USER_';
9 | function validateId(id) {
10 | return typeof id == 'string' && id.indexOf(ID_PREFIX) === 0;
11 | }
12 |
13 | function* fibonacci() {
14 | var n1 = 1;
15 | var n2 = 1;
16 | while (true) {
17 | var current = n2;
18 | n2 = n1;
19 | n1 += current;
20 | var reset = yield current;
21 | if (reset) {
22 | n1 = 1;
23 | n2 = 1;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/5_generators/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('babel/register');
4 |
5 | require('./lib/app');
6 |
--------------------------------------------------------------------------------
/6_other_stuff/client/app/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var iso = require('../../portable');
5 |
6 | const MAX_HEIGHT = 450;
7 | const MIN_HEIGHT = 200;
8 |
9 | console.log('Client side code started');
10 |
11 | function isInRange(n) {
12 | return n <= MAX_HEIGHT && n >= MIN_HEIGHT;
13 | }
14 |
15 | //MAX_HEIGHT = 250;
16 |
17 | console.log('is 300 in range', isInRange(300));
18 | console.log('is 100 in range', isInRange(100));
19 |
20 |
21 | for (let i = 0; i < 10; i++) {
22 | console.log(i);
23 | }
24 | //console.log('outside', i);
25 |
26 | function doStuff(person) {
27 | var {name, age, job} = person;
28 | console.log(name + '(' + age + ') works as a ' + job);
29 | }
30 |
31 | doStuff({
32 | name: 'Jason',
33 | job: 'Developer',
34 | age: 31
35 | });
36 |
37 | /*
38 | function callback(resonse) {
39 | var [status, body] = response;
40 | ... etc
41 | }
42 | */
43 |
44 |
45 | var arr = [{name: 'Jane'}, {name: 'Jason'}, {name: 'Mike'}];
46 |
47 |
48 | //var strArr = arr.map(_.property('name'));
49 | var strArr = arr.map((x) => x.name);
50 | console.log(strArr);
51 |
52 |
53 | /* Maintaining lexical scope
54 |
55 | SomeClass.prototype.someMethod = function() {
56 | this.points.forEach((point) => {
57 | this.x++;
58 | this.y++;
59 | });
60 | }
61 |
62 | */
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/6_other_stuff/client/app/utils/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | count
5 | };
6 |
7 | function count() {
8 | var count = 0;
9 | setInterval(() => console.log(count++), 400);
10 | }
11 |
--------------------------------------------------------------------------------
/6_other_stuff/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/6_other_stuff/dist/app.bundle.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= MIN_HEIGHT;
14 | }
15 |
16 | //MAX_HEIGHT = 250;
17 |
18 | console.log('is 300 in range', isInRange(300));
19 | console.log('is 100 in range', isInRange(100));
20 |
21 | for (var i = 0; i < 10; i++) {
22 | console.log(i);
23 | }
24 | //console.log('outside', i);
25 |
26 | function doStuff(person) {
27 | var name = person.name;
28 | var age = person.age;
29 | var job = person.job;
30 |
31 | console.log(name + '(' + age + ') works as a ' + job);
32 | }
33 |
34 | doStuff({
35 | name: 'Jason',
36 | job: 'Developer',
37 | age: 31
38 | });
39 |
40 | /*
41 | function callback(resonse) {
42 | var [status, body] = response;
43 | ... etc
44 | }
45 | */
46 |
47 | var arr = [{ name: 'Jane' }, { name: 'Jason' }, { name: 'Mike' }];
48 |
49 | //var strArr = arr.map(_.property('name'));
50 | var strArr = arr.map(function (x) {
51 | return x.name;
52 | });
53 | console.log(strArr);
54 |
55 | /* Maintaining lexical scope
56 |
57 | SomeClass.prototype.someMethod = function() {
58 | this.points.forEach((point) => {
59 | this.x++;
60 | this.y++;
61 | });
62 | }
63 |
64 | */
65 |
66 | },{"../../portable":3,"./utils":2}],2:[function(require,module,exports){
67 | 'use strict';
68 |
69 | module.exports = {
70 | count: count
71 | };
72 |
73 | function count() {
74 | var count = 0;
75 | setInterval(function () {
76 | return console.log(count++);
77 | }, 400);
78 | }
79 |
80 | },{}],3:[function(require,module,exports){
81 | 'use strict';
82 |
83 | module.exports = {
84 | validateId: validateId
85 | };
86 |
87 | var ID_PREFIX = 'USER_';
88 | function validateId(id) {
89 | return typeof id == 'string' && id.indexOf(ID_PREFIX) === 0;
90 | }
91 |
92 | },{}]},{},[1])
93 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvVXNlcnMvamFzb25pYW5ncmVlbi9wZXJzb25hbC90dXRzL2JhYmVsL2JhYmVsLXNyYy81X290aG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9IGFyci5tYXAoXy5wcm9wZXJ0eSgnbmFtZScpKTtcbnZhciBzdHJBcnIgPSBhcnIubWFwKCh4KSA9PiB4Lm5hbWUpO1xuY29uc29sZS5sb2coc3RyQXJyKTtcblxuXG4vKiBNYWludGFpbmluZyBsZXhpY2FsIHNjb3BlXG5cblNvbWVDbGFzcy5wcm90b3R5cGUuc29tZU1ldGhvZCA9IGZ1bmN0aW9uKCkge1xuICAgIHRoaXMucG9pbnRzLmZvckVhY2goKHBvaW50KSA9PiB7XG4gICAgICAgIHRoaXMueCsrO1xuICAgICAgICB0aGlzLnkrKztcbiAgICB9KTtcbn1cblxuKi9cblxuXG5cblxuXG5cblxuXG5cblxuXG5cblxuXG5cbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gICAgY291bnRcbn07XG5cbmZ1bmN0aW9uIGNvdW50KCkge1xuICAgIHZhciBjb3VudCA9IDA7XG4gICAgc2V0SW50ZXJ2YWwoKCkgPT4gY29uc29sZS5sb2coY291bnQrKyksIDQwMCk7XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICAgIHZhbGlkYXRlSWRcbn07XG5cbmNvbnN0IElEX1BSRUZJWCA9ICdVU0VSXyc7XG5mdW5jdGlvbiB2YWxpZGF0ZUlkKGlkKSB7XG4gICAgcmV0dXJuIHR5cGVvZiBpZCA9PSAnc3RyaW5nJyAmJiBpZC5pbmRleE9mKElEX1BSRUZJWCkgPT09IDA7XG59XG4iXX0=
94 |
--------------------------------------------------------------------------------
/6_other_stuff/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Babel starters kit
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/6_other_stuff/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var babelify = require('babelify');
5 | var browserify = require('browserify');
6 | var source = require('vinyl-source-stream');
7 |
8 | gulp.task('build', function () {
9 | browserify({
10 | entries: './client/app/main.js',
11 | debug: true
12 | })
13 | .transform(babelify)
14 | .bundle()
15 | .pipe(source('app.bundle.js'))
16 | .pipe(gulp.dest('./dist'));
17 | });
18 |
19 | gulp.task('copy', function () {
20 | gulp.src('client/index.html')
21 | .pipe(gulp.dest('./dist'));
22 | });
23 |
24 | gulp.task('watch', function () {
25 | gulp.watch('client/**/*.js', ['build']);
26 | gulp.watch('client/*.html', ['copy']);
27 | });
28 |
29 | gulp.task('default', ['copy', 'build', 'watch']);
30 |
--------------------------------------------------------------------------------
/6_other_stuff/lib/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var express = require('express');
4 | var app = express();
5 | var iso = require('../portable')
6 |
7 | var server = require('http').createServer(app);
8 | app.use('/', express.static(__dirname + '/../dist', { maxAge: 1000000 }));
9 | server.listen(9000, () => console.log('App started'));
10 |
--------------------------------------------------------------------------------
/6_other_stuff/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-starter",
3 | "version": "1.0.0",
4 | "description": "Starting project for babel, browserify, gulp projects",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "MIT",
11 | "devDependencies": {
12 | "babelify": "^6.0.2",
13 | "browserify": "^10.0.0",
14 | "gulp": "^3.8.11",
15 | "vinyl-source-stream": "^1.1.0"
16 | },
17 | "dependencies": {
18 | "babel": "^5.2.6",
19 | "express": "^4.12.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/6_other_stuff/portable/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | validateId
5 | };
6 |
7 | const ID_PREFIX = 'USER_';
8 | function validateId(id) {
9 | return typeof id == 'string' && id.indexOf(ID_PREFIX) === 0;
10 | }
11 |
--------------------------------------------------------------------------------
/6_other_stuff/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('babel/register');
4 |
5 | require('./lib/app');
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, Tuts+
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [Start Coding ES6 With Babel][published url]
2 | ## Instructor: [Jason Green][instructor url]
3 |
4 | JavaScript has evolved a lot over the years. The latest version of the language, ECMASCript 6 (ES6 for short) was recently finalized and it brings a lot of improvements for developers. Of course, brower support is still spotty.
5 |
6 | What if you don't want to wait for modern browser adoption or to update your server to node 0.12? In this course we'll discover how we can write full stack ES6 today. We'll use Babel, along with other build tools like Browserify and Gulp to transpile our ES6 into plain ES5, which is supported by the vast majority of browsers.
7 |
8 | # Source Files Description:
9 |
10 | These source files are broken up into 5 folders (cooresponding to lessons 2 through 6 of the course). To try any one of them, simply clone this repo, navigate to the particular lesson directory, and run the following commands.
11 | ```
12 | npm install
13 | gulp
14 | #open a new tab
15 | node server.js
16 | ```
17 | Then navigate to `http://localhost:9000` in your browser to see the result.
18 |
19 | ------
20 |
21 | These are source files for the Tuts+ course: [Start Coding ES6 With Babel][published url]
22 |
23 | Available on [Tuts+](https://tutsplus.com). Teaching skills to millions worldwide.
24 |
25 | [published url]: https://code.tutsplus.com/courses/start-coding-es6-with-babel
26 | [instructor url]: https://tutsplus.com/authors/jason-green
27 |
--------------------------------------------------------------------------------