Skip to content

Instantly share code, notes, and snippets.

@keeto
keeto / Array.Reduce.js
Created November 9, 2009 13:09
MooTools implementation for Array.reduce() and Array.reduceRight()
/*
Script: Array.Reduce.js
MooTools implementation for Array.reduce() and Array.reduceRight()
Acknowledgement:
- Implementation code ported and reworked from Mozilla's Array.reduce() and Array.reduceRight() algorithms.
cf: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce,
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
*/
@keeto
keeto / Collection.js
Created December 2, 2009 22:09
Collection Native for MooTools
function Collection(list, build){
this.list = $splat(list || []);
this.length = this.list.length;
this.build = build || true;
if (this.build) this.rebuild();
}
new Native({name: 'Collection', initialize: Collection, generics: false});
(function() {
@keeto
keeto / Class.AfterImplement.js
Created December 3, 2009 21:42
Adds an afterImplement feature to Class
/*
Script: Class.AfterImplement.js
Adds an afterImplement feature to Class: a function
fired after every implemented item.
License & Copyright:
Copyright 2009, Mark Obcena <keetology.com>
MIT-Style License
*/
@keeto
keeto / Accessors.js
Created January 10, 2010 12:58
An accessors mixin for getters and setters.
/*
Script: Accessors.js
An accessors mixin for getters and setters.
License & Copyright:
Copyright 2009, Mark Obcena <keetology.com>
MIT-Style License
*/
var Accessors = new Class({
@keeto
keeto / Signal.js
Created January 27, 2010 15:49
Signal.js: Makes chaining functions easy!
/*
Script: Signal.js
Makes chaining functions easy!
License & Copyright:
Copyright 2009, Mark Obcena <keetology.com>
MIT-Style License
*/
(function(global){
@keeto
keeto / Function.docStringMethod.js
Created April 2, 2010 07:20
Function docStrings in JavaScript
// As a Function method..
(function(){
Function.prototype.docString = function(){
var doc = this[this.toSource ? 'toSource' : 'toString']().match(/['"]\*(.*)\*['"]/);
return (doc) ? doc[1].replace(/^\s+|\s+$/g, '') : '';
};
})();
/*
Script: Template.jx
Basic templating system.
License:
MIT-style license.
Acknowledgements:
Original inspired by Charlie Savages' simple templating engine.
@keeto
keeto / Class.mock.js
Created May 25, 2010 19:15
Class.mock Generic for MooTools
Class.extend({
mock: function(klass, options){
options = options || {};
klass = klass.prototype;
var proto = {};
for (var i in klass) (function(key, value){
proto[key] = options[key];
if (proto[key]) return;
switch ($type(value)){
case 'function':
@keeto
keeto / Mediator.js
Created June 26, 2010 17:40
Mediator: Object grouping and brokering
/*
Script: Mediator
Object grouping and brokering
Copyright and License:
Copyright 2010, Mark Obcena. MIT-Style License
*/
(function(){
@keeto
keeto / Function.Typed.js
Created June 27, 2010 06:49
Function.Typed: MultiMethod Helper
/*
Script: Function.Typed.js
Helper for multimethods.
Copyright and License:
Copyrighted 2010, Mark Obcena. MIT-Style License
Credits:
Inspired by "Multimethods in Python"
[http://alexgaynor.net/2010/jun/26/multimethods-python/]