Skip to content

Instantly share code, notes, and snippets.

@shimdh
shimdh / btree.js
Created April 17, 2014 00:51
Modified for node.js from behavior tree for browser.
"use strict";
var Base = function() {
// dummy
};
Base.extend = function(_instance, _static) { // subclass
var extend = Base.prototype.extend;
// build the prototype
Base._prototyping = true;
var proto = new this;
@shimdh
shimdh / allExist.js
Created April 14, 2014 05:43
checking all keys exist in collection.
"use strict";
var _ = require('underscore');
require('underscore-contrib');
module.exports = function(collection) {
return _.every(_.map(collection, function(key) {
return _.exists(key);
}));
};
@shimdh
shimdh / forEach.js
Last active August 29, 2015 13:58
Fast forEach method than native method in Node.js
"use strict";
module.exports = function(obj, func, context) {
var kIndex,
length;
for (kIndex = 0, length = obj.length; kIndex < length; kIndex++) {
func.call(context, obj[kIndex], kIndex, obj);
}
};