Created
March 16, 2015 20:08
-
-
Save A-gambit/e7e9e15325c3947238e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // твоя задача написать require | |
| //сейчас ту? да :) | |
| // browser.js | |
| // nodejs | |
| var require = { | |
| data: [], | |
| import: function(path){ | |
| var res = this.data.filter(function(item){ | |
| return item.path == path | |
| }); | |
| return res[0].value | |
| }, | |
| export: function(path, value){ | |
| this.data.push({path: path, value: value}) | |
| } | |
| } | |
| // a.js | |
| (function(){ | |
| var a = require.import('b') | |
| a() | |
| })() | |
| // b.js | |
| (function(){ | |
| var b = function () { | |
| return console.log('b') | |
| } | |
| , path = "b" | |
| require.export(path, b) | |
| })() | |
| //ну мы же не експортим б что бы его рекваерить как я его вызову там же нет к примеру или что то в этому духе | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment