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
| module M { | |
| function B(){ return 'B'; }; | |
| export this A(){ A = B; return 'A'; }; | |
| } | |
| M(); // 'A' | |
| M(); // ? | |
| // If the second call yields 'B' then this should be ok as well: |
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
| function require(module){ | |
| if (module.cached) return module.cached; | |
| module(module.cached = {}); | |
| return module.cached; | |
| }; | |
| function MODULE1(exports){ | |
| }; | |
| function MODULE2(exports){ |
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
| (function(){ | |
| var a, b, c; | |
| function A(){ | |
| if (a) return a; | |
| var exports = a = {}; | |
| var n = 'foo'; | |
| var x = function(){ |
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
| // Deferred Labeled Modules.js | |
| require: 'Foo'; | |
| function LoadSomething(){ | |
| var a = 'A'; // Synchronous | |
| alert('Will now start loading the Foo module'); | |
| defer: { |
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
| var currentInstance; | |
| function parent(){ | |
| currentInstance.parent(); | |
| } | |
| function wrapMethod(method){ | |
| return function(){ | |
| var previousInstance = currentInstance; | |
| currentInstance = this; |
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
| var loader = require('../path/to/link'); | |
| loader.alias('package', '../path/to/package.js'); | |
| loader.alias('package2', '../path/to/package2.js'); | |
| loader.base('../path/to/my/root/folder/'); | |
| loader.load('main'); |
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
| public static class UrlHelperExtensions | |
| { | |
| public static string SmartAction(this UrlHelper url, object values) | |
| { | |
| return SmartAction(url, null, values); | |
| } | |
| public static string SmartAction(this UrlHelper url, RouteValueDictionary valueCollection) | |
| { | |
| return SmartAction(url, null, valueCollection); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| var originalFunction = obj.myMethod; | |
| obj.myMethod = function(){ | |
| // Before | |
| console.log('before myMethod on ', this); | |
| var result = originalFunction.apply(this, arguments); | |
| // After | |
| console.log('after myMethod on ', this); | |
| return result; | |
| }; |
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
| // EXAMPLE: a compound iterator with sequencing | |
| // Python style | |
| function cat() { | |
| let is = arguments; | |
| return { | |
| next: { | |
| let length; | |
| while ((length = is.length) > 0) { | |
| try { |