chocolate
Version:
A full stack Node.js web framework built using Coffeescript
72 lines (65 loc) • 2.13 kB
JavaScript
// Generated by CoffeeScript 1.12.6
(function() {
var Data, Document, _, _module;
_ = require('../../general/chocodash');
Data = require('../../general/locco/data');
Document = _.prototype({
constructor: function(definition) {
var helpers, i, len, methodName, ref;
helpers = {
set: function(key, value) {
_["do"].set(this.definition, key, value);
return this.value(this.definition);
}
};
ref = ["pop", "push", "reverse", "shift", "sort", "splice", "unshift"];
for (i = 0, len = ref.length; i < len; i++) {
methodName = ref[i];
helpers[methodName] = (function(methodName) {
return function() {
var result;
Array.prototype.unshift.call(arguments, this.definition);
result = _["do"][methodName].apply(null, arguments);
this.value(this.definition);
return result;
};
})(methodName);
}
return this.signal = new _.Signal(definition, helpers);
},
use: function() {
var i, len, methodName, ref, results;
this.set = function(key, value) {
return this.signal.set(key, value);
};
this["delete"] = function(key) {
return this.signal["delete"](key);
};
this.get = function() {
return this.signal.value();
};
ref = ["pop", "push", "reverse", "shift", "sort", "splice", "unshift"];
results = [];
for (i = 0, len = ref.length; i < len; i++) {
methodName = ref[i];
results.push(this[methodName] = (function(methodName) {
return function() {
var output;
output = this.signal[methodName].apply(this.signal, arguments);
return output;
};
})(methodName));
}
return results;
}
});
_module = typeof window !== "undefined" && window !== null ? window : module;
if (_module.exports != null) {
_module.exports = Document;
} else {
if (window.Locco == null) {
window.Locco = {};
}
window.Locco.Document = Document;
}
}).call(this);