forked from loiane/javascript-datastructures-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17-ES2015-ES6-Modules.js
60 lines (48 loc) · 1.51 KB
/
17-ES2015-ES6-Modules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['./17-CalcArea.js', './17-Book.js'], factory);
} else if (typeof exports !== "undefined") {
factory(require('./17-CalcArea.js'), require('./17-Book.js'));
} else {
var mod = {
exports: {}
};
factory(global.CalcArea, global.Book);
global.ES2015ES6Modules = mod.exports;
}
})(this, function (_CalcArea, _Book) {
'use strict';
var area = _interopRequireWildcard(_CalcArea);
var _Book2 = _interopRequireDefault(_Book);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
}
}
newObj.default = obj;
return newObj;
}
}
// @ts-check
// import { circleArea, squareArea } from './17-CalcArea'; // {2}
// import { circleArea as circle } from './17-CalcArea';
// console.log(circleArea(2));
// console.log(squareArea(2));
/* Different way of importing the module */
// import * as area from './17-CalcArea';
// import Book from './17-Book';
console.log(area.circle(2)); // we need the .js to run this code in the browser
console.log(area.square(2));
var myBook = new _Book2.default('some title');
myBook.printTitle();
});