Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": ["es2015"] }
18 changes: 18 additions & 0 deletions job.es5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

// job.js

var Job = function Job(title) {
_classCallCheck(this, Job);

this.title = title;
};

var validJobs = exports.validJobs = ["programmer", "that's it"];
exports.default = Job;
9 changes: 9 additions & 0 deletions job.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// job.js
class Job{
constructor(title){
this.title = title;
}
}

export var validJobs = ["programmer", "that's it"]
export default Job;
23 changes: 23 additions & 0 deletions output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

var _job = require('./job.es5.js');

var _job2 = _interopRequireDefault(_job);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // person.js

var Person = function Person(name, job) {
_classCallCheck(this, Person);

this.name = name;
this.job = job;
};

;

var programmer = new _job2.default("Programmer");
var bob = new Person("Bobby", programmer);
console.log('validJobs are ' + _job.validJobs);
console.log(bob.name + ' is a ' + bob.job.title);
14 changes: 14 additions & 0 deletions person.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// person.js
import Job from './job.js'
import {validJobs} from './job.js'
class Person{
constructor(name, job){
this.name = name;
this.job = job;
}
};

var programmer = new Job("Programmer");
var bob = new Person("Bobby", programmer)
console.log(`validJobs are ${validJobs}`);
console.log(`${bob.name} is a ${bob.job.title}`);