This file contains 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
// add your variants of | |
a ? b : c | |
// in comments :) | |
// a is boolean | |
// b and c - any type | |
// lazy evaluation isnt important |
This file contains 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 match = [] | |
var _finalizeExpr = function(match) { | |
var vs = match[0] | |
var _iter = match[1] | |
var _done = match[2] | |
var i = 0 | |
var _iterWrappper = function() { | |
if(i === vs.length) { |
This file contains 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
/* | |
case insensitive names! | |
*/ | |
var Basic = function(obj) { | |
var _transform = (function(){ | |
var cache = Object.create(null) | |
return function(name){ | |
return (cache[name] // lisp! | |
|| (cache[name] = |
This file contains 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
/* | |
Generic breakable _each | |
*/ | |
Object.prototype._each = function(_fn) { | |
for(var i in this) { | |
if(!{}.hasOwnProperty.call(this, i)) | |
continue | |
var ret = _fn(this[i], i, this) | |
if(ret != null) |
This file contains 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)) |
This file contains 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 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 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 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 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) |