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
| /* | |
| Shows that strongly typed vars is possible in js! And do not worry about speed. :) Robust type system is more important than yet another benchmark :P. And i'll plan to make deploy system which checks all types and removes all 'ugly' `with`. This code definitely should be complexer, but i keep it simple. | |
| P.S. `with` rulezzz | |
| P.P.S. As you see its too easy to make field of class strongly typed too. | |
| */ | |
| (function($G){ | |
| if(Object.defineProperty && !{}.__defineGetter__) | |
| { | |
| Object.prototype.__defineGetter__ = function(name, _fn) |
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
| // yield in es3 | |
| // original code | |
| (function() | |
| { | |
| var _gen = function(a) | |
| { | |
| var d = ''; | |
| for(;;) { |
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
| /* | |
| uses compilation to optimize `Function#bind`, but not real `bind` which in fact - `carry` | |
| inlines consts. | |
| */ | |
| var defaultThis = (function(){ return this })(); | |
| this._fastBind = (function() | |
| { | |
| var _quoteString = function(s) |
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 _addProps = function(a, name) | |
| { | |
| a[name + '.a'] = name + '.a'; | |
| a['d'] = name + '.d'; | |
| }; | |
| var _create = function(proto) | |
| { | |
| var C = function(){}; | |
| C.prototype = proto; |
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 _copyFile = function( | |
| iName, | |
| oName, | |
| _ret | |
| ) | |
| { | |
| var CHUNK_SIZE = 65536; | |
| var _copy = function(iF, oF, size, _ret) |
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
| /* Reordered binary search and cache-misses. Thanks for idea, http://www.linux.org.ru/people/ckotinko/profile. */ | |
| var n = 800000; | |
| var ENABLE_TYPED_ARRAYS = 1; | |
| var MAKE_SOLID = 1; | |
| var $G = this; | |
| var MyArray = | |
| ENABLE_TYPED_ARRAYS && ( |
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
| /* | |
| `String.prototype._matchWithPoss(re, p)` (c) New BSD License | |
| @param re {RegExp} | |
| @param p ?= 0 {Number} start position to match | |
| Matches regExp with subgroups and back references as build-in `String.prototype.match` but adds info about subgroups positions in string. | |
| Example: | |
| console.log(' 123abcABC123abc'._matchWithPoss(/(?:\d+)([a-z]+)[A-Z]+(\d+\1)/, 1)); | |
| [ | |
| { // 0 - whole matched substring with matched position | |
| "s": "123abcABC123abc", |
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
| /* | |
| Very simple. Uses [gs]etters and caller. Precache '_method in Class' relations using unique `Class.jbId_` and `_method.jbOwnerClassIdMap_`. | |
| */ | |
| (function() | |
| { | |
| var nextClassId = 1; | |
| var _methodInClass = function(_fn, Class) | |
| { | |
| var classId = Class.jbId_; |
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
| /* | |
| Declarative style evaluation. | |
| Advantages | |
| order of evaluation is not important | |
| evaluation is lazy i.e. its evaluated only if required | |
| auto memorization of evaluation (only for pure fns) | |
| expressions are writed as in math, no mutable values | |
| */ | |
| Object.prototype._let = #(name, _calc) { |
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
| String.prototype._quoteCString = #{ | |
| -> @replace(/\\/g, '\\\\').replace(/\"/g, '\\"') | |
| } | |
| fix _ltmlToHtml = #(s) { | |
| fix _skipSpaces = #(p) { | |
| -> p + s.slice(p).match(/^\s*/)[0].length // skip | |
| } | |
| fix _passAttr = #(p) { | |
| switch(s.charAt(p)) |