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(global, modules, factory){ | |
global.module = function(){ | |
return modules[name] || (modules[name]={define:factory()}); | |
}; | |
})(this, {}, function(){ | |
return (function(prefixe, normalize, err){ | |
return (function moduleBind(modules, context, prefix) { | |
return (function(get, set, identity){ | |
return function module(name, requires, invoke) { | |
return arguments.length === 1 ? get(prefixe(prefix,name, true)) : (function(instance, context){ |
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 merge(target, source){ | |
if(source !== undefined && (source=isArrayLike(source)?source:[source])) | |
for(var i=0;i<Math.max(target.length, source.length);i++) | |
target.splice(i,1, source[i]||target[i]); | |
return target; | |
} |
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 decorator(context, callbacks){ | |
return (function(context, callbacks, $finally) { | |
function execute(callbacks, context, args, value) { | |
return callbacks.length ? | |
execute(callbacks, context, args, callbacks.pop().apply(context, args, value)) || value:value; | |
}; | |
return { | |
context: context, | |
invoke: function(fn, args, context){ |
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
/* | |
Author: Rubén López Gómez | |
Gist: https://gist.github.com/rubeniskov/0ddfa4f1b01176d418dd | |
*/ | |
var sufix = function() { | |
return Array.prototype.slice.call(arguments).map(function(v, i, parts) { | |
return parts[i + 1] ? | |
v.replace(new RegExp(parts[i + 1] + '$', 'i'), '') : | |
[v.charAt(0).toUpperCase(), v.slice(1)].join(''); |
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
// http://jsperf.com/symbolmask | |
var symbolMask = function(am, ar, aa, as){ | |
var ir, ia, is, i, j, k, | |
s = /[\+\,\s]/, | |
m = 0, r = '', | |
l = 1, e = []; | |
for(i=0; i<am.length; i++) | |
if (s.test(am[i])) { | |
(l = am[i] !== '+') && (r = []); |
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 base64 = (function(bin) { | |
for (var i = 0, l = bin.chars.length; i < l; i++) | |
bin.tabs[bin.chars.charAt(i)] = i; | |
return bin; | |
})({ | |
chars: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+_', | |
tabs: {} | |
}), | |
encode = function(objectID) { | |
var oid = objectID.toUpperCase(), |
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 video = (new Array(100).join(',').split(',').map(function(v,i){return i})), | |
sprite = function(start, length, split) { | |
split = split != null ? split : 5; | |
start = start != null ? start : 0; | |
length = length != null ? start + length : undefined; | |
var r = [], | |
frames = video.slice(start, length); | |
for (var i = 0; i < frames.length; i++) | |
frames[i] % split === 0 && r.push(frames[i]); | |
return r; |
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 getErrorObject() { | |
try { | |
throw Error('') | |
} catch (err) { | |
return err; | |
} | |
} | |
var test = console.log; | |
console.log = function() { | |
test.apply(this, [getErrorObject().stack.split("\n")[4]].concat(arguments)); |
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 detectPropertyDescriptor(descriptor){ | |
var keys = Object.keys(descriptor).join(' '); | |
return (/(configureable|enumerable)/).test(keys) && (/(set|get)|(value)/).test(keys); | |
} |
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 indexOf(buffer, pattern) { | |
for (var i = 0; i < buffer.length - pattern.length; i++) { | |
if (buffer.slice(i, i + pattern.length).map(function(v, i) { | |
return pattern[i] === v; | |
}).filter(Boolean).length === pattern.length) | |
return i; | |
} | |
return -1 | |
})(temp1.data, [222, 2, 0, 76, 97]); |