diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..7a870ac --- /dev/null +++ b/.babelrc @@ -0,0 +1 @@ +{ "presets": ["es2015"] } \ No newline at end of file diff --git a/job.es5.js b/job.es5.js new file mode 100644 index 0000000..ffd527b --- /dev/null +++ b/job.es5.js @@ -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; diff --git a/job.js b/job.js new file mode 100644 index 0000000..ebbd347 --- /dev/null +++ b/job.js @@ -0,0 +1,9 @@ +// job.js +class Job{ + constructor(title){ + this.title = title; + } +} + +export var validJobs = ["programmer", "that's it"] +export default Job; \ No newline at end of file diff --git a/output.js b/output.js new file mode 100644 index 0000000..4b497d4 --- /dev/null +++ b/output.js @@ -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); diff --git a/person.js b/person.js new file mode 100644 index 0000000..6545505 --- /dev/null +++ b/person.js @@ -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}`); \ No newline at end of file