compound-ex4
Version:
Compound-ex4 - MVC framework for NodeJS (ExpressJs 4 version), fork compoundjs(https://github.com/1602/compound)
1,033 lines (1,032 loc) • 259 kB
JavaScript
(function() {
var root = this, modules, require_from, register, error;
if (typeof global == "undefined") {
var global;
if (typeof window != "undefined") {
global = window;
} else {
global = {};
}
}
modules = {};
require_from = function(parent, from) {
return function(name) {
if (modules[from] && modules[from][name]) {
modules[from][name].parent = parent;
if (modules[from][name].initialize) {
modules[from][name].initialize();
}
return modules[from][name].exports;
} else {
return error(name, from);
}
};
};
register = function(names, directory, callback) {
var module = {
exports: {},
initialize: function() {
callback.call(module.exports, global, module, module.exports, require_from(module, directory), undefined);
delete module.initialize;
},
parent: null
};
for (var from in names) {
modules[from] = modules[from] || {};
for (var j in names[from]) {
var name = names[from][j];
modules[from][name] = module;
}
}
};
error = function anonymous(name, from) {
var message = "Warn: could not find module " + name;
console.log(message);
};
register({
"0": [ "./events" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var extend = function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, hasProp = {}.hasOwnProperty;
this.Event = function() {
function Event(start_mark, end_mark) {
this.start_mark = start_mark;
this.end_mark = end_mark;
}
return Event;
}();
this.NodeEvent = function(superClass) {
extend(NodeEvent, superClass);
function NodeEvent(anchor, start_mark, end_mark) {
this.anchor = anchor;
this.start_mark = start_mark;
this.end_mark = end_mark;
}
return NodeEvent;
}(this.Event);
this.CollectionStartEvent = function(superClass) {
extend(CollectionStartEvent, superClass);
function CollectionStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style) {
this.anchor = anchor;
this.tag = tag;
this.implicit = implicit;
this.start_mark = start_mark;
this.end_mark = end_mark;
this.flow_style = flow_style;
}
return CollectionStartEvent;
}(this.NodeEvent);
this.CollectionEndEvent = function(superClass) {
extend(CollectionEndEvent, superClass);
function CollectionEndEvent() {
return CollectionEndEvent.__super__.constructor.apply(this, arguments);
}
return CollectionEndEvent;
}(this.Event);
this.StreamStartEvent = function(superClass) {
extend(StreamStartEvent, superClass);
function StreamStartEvent(start_mark, end_mark, encoding) {
this.start_mark = start_mark;
this.end_mark = end_mark;
this.encoding = encoding;
}
return StreamStartEvent;
}(this.Event);
this.StreamEndEvent = function(superClass) {
extend(StreamEndEvent, superClass);
function StreamEndEvent() {
return StreamEndEvent.__super__.constructor.apply(this, arguments);
}
return StreamEndEvent;
}(this.Event);
this.DocumentStartEvent = function(superClass) {
extend(DocumentStartEvent, superClass);
function DocumentStartEvent(start_mark, end_mark, explicit, version, tags) {
this.start_mark = start_mark;
this.end_mark = end_mark;
this.explicit = explicit;
this.version = version;
this.tags = tags;
}
return DocumentStartEvent;
}(this.Event);
this.DocumentEndEvent = function(superClass) {
extend(DocumentEndEvent, superClass);
function DocumentEndEvent(start_mark, end_mark, explicit) {
this.start_mark = start_mark;
this.end_mark = end_mark;
this.explicit = explicit;
}
return DocumentEndEvent;
}(this.Event);
this.AliasEvent = function(superClass) {
extend(AliasEvent, superClass);
function AliasEvent() {
return AliasEvent.__super__.constructor.apply(this, arguments);
}
return AliasEvent;
}(this.NodeEvent);
this.ScalarEvent = function(superClass) {
extend(ScalarEvent, superClass);
function ScalarEvent(anchor, tag, implicit, value, start_mark, end_mark, style) {
this.anchor = anchor;
this.tag = tag;
this.implicit = implicit;
this.value = value;
this.start_mark = start_mark;
this.end_mark = end_mark;
this.style = style;
}
return ScalarEvent;
}(this.NodeEvent);
this.SequenceStartEvent = function(superClass) {
extend(SequenceStartEvent, superClass);
function SequenceStartEvent() {
return SequenceStartEvent.__super__.constructor.apply(this, arguments);
}
return SequenceStartEvent;
}(this.CollectionStartEvent);
this.SequenceEndEvent = function(superClass) {
extend(SequenceEndEvent, superClass);
function SequenceEndEvent() {
return SequenceEndEvent.__super__.constructor.apply(this, arguments);
}
return SequenceEndEvent;
}(this.CollectionEndEvent);
this.MappingStartEvent = function(superClass) {
extend(MappingStartEvent, superClass);
function MappingStartEvent() {
return MappingStartEvent.__super__.constructor.apply(this, arguments);
}
return MappingStartEvent;
}(this.CollectionStartEvent);
this.MappingEndEvent = function(superClass) {
extend(MappingEndEvent, superClass);
function MappingEndEvent() {
return MappingEndEvent.__super__.constructor.apply(this, arguments);
}
return MappingEndEvent;
}(this.CollectionEndEvent);
}).call(this);
});
register({
"0": [ "./errors" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) return i;
}
return -1;
}, extend = function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, hasProp = {}.hasOwnProperty;
this.Mark = function() {
function Mark(line, column, buffer, pointer) {
this.line = line;
this.column = column;
this.buffer = buffer;
this.pointer = pointer;
}
Mark.prototype.get_snippet = function(indent, max_length) {
var break_chars, end, head, ref, ref1, start, tail;
if (indent == null) {
indent = 4;
}
if (max_length == null) {
max_length = 75;
}
if (this.buffer == null) {
return null;
}
break_chars = "\0\r\n
\u2028\u2029";
head = "";
start = this.pointer;
while (start > 0 && (ref = this.buffer[start - 1], indexOf.call(break_chars, ref) < 0)) {
start--;
if (this.pointer - start > max_length / 2 - 1) {
head = " ... ";
start += 5;
break;
}
}
tail = "";
end = this.pointer;
while (end < this.buffer.length && (ref1 = this.buffer[end], indexOf.call(break_chars, ref1) < 0)) {
end++;
if (end - this.pointer > max_length / 2 - 1) {
tail = " ... ";
end -= 5;
break;
}
}
return "" + (new Array(indent)).join(" ") + head + this.buffer.slice(start, end) + tail + "\n" + (new Array(indent + this.pointer - start + head.length)).join(" ") + "^";
};
Mark.prototype.toString = function() {
var snippet, where;
snippet = this.get_snippet();
where = " on line " + (this.line + 1) + ", column " + (this.column + 1);
if (snippet) {
return where;
} else {
return where + ":\n" + snippet;
}
};
return Mark;
}();
this.YAMLError = function(superClass) {
extend(YAMLError, superClass);
function YAMLError(message) {
this.message = message;
YAMLError.__super__.constructor.call(this);
this.stack = this.toString() + "\n" + (new Error).stack.split("\n").slice(1).join("\n");
}
YAMLError.prototype.toString = function() {
return this.message;
};
return YAMLError;
}(Error);
this.MarkedYAMLError = function(superClass) {
extend(MarkedYAMLError, superClass);
function MarkedYAMLError(context, context_mark, problem, problem_mark, note) {
this.context = context;
this.context_mark = context_mark;
this.problem = problem;
this.problem_mark = problem_mark;
this.note = note;
MarkedYAMLError.__super__.constructor.call(this);
}
MarkedYAMLError.prototype.toString = function() {
var lines;
lines = [];
if (this.context != null) {
lines.push(this.context);
}
if (this.context_mark != null && (this.problem == null || this.problem_mark == null || this.context_mark.line !== this.problem_mark.line || this.context_mark.column !== this.problem_mark.column)) {
lines.push(this.context_mark.toString());
}
if (this.problem != null) {
lines.push(this.problem);
}
if (this.problem_mark != null) {
lines.push(this.problem_mark.toString());
}
if (this.note != null) {
lines.push(this.note);
}
return lines.join("\n");
};
return MarkedYAMLError;
}(this.YAMLError);
}).call(this);
});
register({
"0": [ "./nodes" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var unique_id, extend = function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, hasProp = {}.hasOwnProperty;
unique_id = 0;
this.Node = function() {
function Node(tag, value, start_mark, end_mark) {
this.tag = tag;
this.value = value;
this.start_mark = start_mark;
this.end_mark = end_mark;
this.unique_id = "node_" + unique_id++;
}
return Node;
}();
this.ScalarNode = function(superClass) {
extend(ScalarNode, superClass);
ScalarNode.prototype.id = "scalar";
function ScalarNode(tag, value, start_mark, end_mark, style) {
this.tag = tag;
this.value = value;
this.start_mark = start_mark;
this.end_mark = end_mark;
this.style = style;
ScalarNode.__super__.constructor.apply(this, arguments);
}
return ScalarNode;
}(this.Node);
this.CollectionNode = function(superClass) {
extend(CollectionNode, superClass);
function CollectionNode(tag, value, start_mark, end_mark, flow_style) {
this.tag = tag;
this.value = value;
this.start_mark = start_mark;
this.end_mark = end_mark;
this.flow_style = flow_style;
CollectionNode.__super__.constructor.apply(this, arguments);
}
return CollectionNode;
}(this.Node);
this.SequenceNode = function(superClass) {
extend(SequenceNode, superClass);
function SequenceNode() {
return SequenceNode.__super__.constructor.apply(this, arguments);
}
SequenceNode.prototype.id = "sequence";
return SequenceNode;
}(this.CollectionNode);
this.MappingNode = function(superClass) {
extend(MappingNode, superClass);
function MappingNode() {
return MappingNode.__super__.constructor.apply(this, arguments);
}
MappingNode.prototype.id = "mapping";
return MappingNode;
}(this.CollectionNode);
}).call(this);
});
register({
"0": [ "./composer" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var MarkedYAMLError, events, nodes, extend = function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, hasProp = {}.hasOwnProperty;
events = require("./events");
MarkedYAMLError = require("./errors").MarkedYAMLError;
nodes = require("./nodes");
this.ComposerError = function(superClass) {
extend(ComposerError, superClass);
function ComposerError() {
return ComposerError.__super__.constructor.apply(this, arguments);
}
return ComposerError;
}(MarkedYAMLError);
this.Composer = function() {
function Composer() {
this.anchors = {};
}
Composer.prototype.check_node = function() {
if (this.check_event(events.StreamStartEvent)) {
this.get_event();
}
return !this.check_event(events.StreamEndEvent);
};
Composer.prototype.get_node = function() {
if (!this.check_event(events.StreamEndEvent)) {
return this.compose_document();
}
};
Composer.prototype.get_single_node = function() {
var document, event;
this.get_event();
document = null;
if (!this.check_event(events.StreamEndEvent)) {
document = this.compose_document();
}
if (!this.check_event(events.StreamEndEvent)) {
event = this.get_event();
throw new exports.ComposerError("expected a single document in the stream", document.start_mark, "but found another document", event.start_mark);
}
this.get_event();
return document;
};
Composer.prototype.compose_document = function() {
var node;
this.get_event();
node = this.compose_node();
this.get_event();
this.anchors = {};
return node;
};
Composer.prototype.compose_node = function(parent, index) {
var anchor, event, node;
if (this.check_event(events.AliasEvent)) {
event = this.get_event();
anchor = event.anchor;
if (!(anchor in this.anchors)) {
throw new exports.ComposerError(null, null, "found undefined alias " + anchor, event.start_mark);
}
return this.anchors[anchor];
}
event = this.peek_event();
anchor = event.anchor;
if (anchor !== null && anchor in this.anchors) {
throw new exports.ComposerError("found duplicate anchor " + anchor + "; first occurence", this.anchors[anchor].start_mark, "second occurrence", event.start_mark);
}
this.descend_resolver(parent, index);
if (this.check_event(events.ScalarEvent)) {
node = this.compose_scalar_node(anchor);
} else if (this.check_event(events.SequenceStartEvent)) {
node = this.compose_sequence_node(anchor);
} else if (this.check_event(events.MappingStartEvent)) {
node = this.compose_mapping_node(anchor);
}
this.ascend_resolver();
return node;
};
Composer.prototype.compose_scalar_node = function(anchor) {
var event, node, tag;
event = this.get_event();
tag = event.tag;
if (tag === null || tag === "!") {
tag = this.resolve(nodes.ScalarNode, event.value, event.implicit);
}
node = new nodes.ScalarNode(tag, event.value, event.start_mark, event.end_mark, event.style);
if (anchor !== null) {
this.anchors[anchor] = node;
}
return node;
};
Composer.prototype.compose_sequence_node = function(anchor) {
var end_event, index, node, start_event, tag;
start_event = this.get_event();
tag = start_event.tag;
if (tag === null || tag === "!") {
tag = this.resolve(nodes.SequenceNode, null, start_event.implicit);
}
node = new nodes.SequenceNode(tag, [], start_event.start_mark, null, start_event.flow_style);
if (anchor !== null) {
this.anchors[anchor] = node;
}
index = 0;
while (!this.check_event(events.SequenceEndEvent)) {
node.value.push(this.compose_node(node, index));
index++;
}
end_event = this.get_event();
node.end_mark = end_event.end_mark;
return node;
};
Composer.prototype.compose_mapping_node = function(anchor) {
var end_event, item_key, item_value, node, start_event, tag;
start_event = this.get_event();
tag = start_event.tag;
if (tag === null || tag === "!") {
tag = this.resolve(nodes.MappingNode, null, start_event.implicit);
}
node = new nodes.MappingNode(tag, [], start_event.start_mark, null, start_event.flow_style);
if (anchor !== null) {
this.anchors[anchor] = node;
}
while (!this.check_event(events.MappingEndEvent)) {
item_key = this.compose_node(node);
item_value = this.compose_node(node, item_key);
node.value.push([ item_key, item_value ]);
}
end_event = this.get_event();
node.end_mark = end_event.end_mark;
return node;
};
return Composer;
}();
}).call(this);
});
register({
"0": [ "./util" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var ref, ref1, ref2, slice = [].slice, hasProp = {}.hasOwnProperty;
this.StringStream = function() {
function StringStream() {
this.string = "";
}
StringStream.prototype.write = function(chunk) {
return this.string += chunk;
};
return StringStream;
}();
this.clone = function(_this) {
return function(obj) {
return _this.extend({}, obj);
};
}(this);
this.extend = function() {
var destination, i, k, len, source, sources, v;
destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
for (i = 0, len = sources.length; i < len; i++) {
source = sources[i];
for (k in source) {
v = source[k];
destination[k] = v;
}
}
return destination;
};
this.is_empty = function(obj) {
var key;
if (Array.isArray(obj) || typeof obj === "string") {
return obj.length === 0;
}
for (key in obj) {
if (!hasProp.call(obj, key)) continue;
return false;
}
return true;
};
this.inspect = (ref = (ref1 = (ref2 = require("util")) != null ? ref2.inspect : void 0) != null ? ref1 : global.inspect) != null ? ref : function(a) {
return "" + a;
};
this.pad_left = function(str, char, length) {
str = String(str);
if (str.length >= length) {
return str;
} else if (str.length + 1 === length) {
return "" + char + str;
} else {
return "" + (new Array(length - str.length + 1)).join(char) + str;
}
};
this.to_hex = function(num) {
if (typeof num === "string") {
num = num.charCodeAt(0);
}
return num.toString(16);
};
}).call(this);
});
register({
"0": [ "./constructor" ]
}, 0, function(global, module, exports, require, window) {
(function() {
var MarkedYAMLError, nodes, util, extend = function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, hasProp = {}.hasOwnProperty, indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) return i;
}
return -1;
};
MarkedYAMLError = require("./errors").MarkedYAMLError;
nodes = require("./nodes");
util = require("./util");
this.ConstructorError = function(superClass) {
extend(ConstructorError, superClass);
function ConstructorError() {
return ConstructorError.__super__.constructor.apply(this, arguments);
}
return ConstructorError;
}(MarkedYAMLError);
this.BaseConstructor = function() {
BaseConstructor.prototype.yaml_constructors = {};
BaseConstructor.prototype.yaml_multi_constructors = {};
BaseConstructor.add_constructor = function(tag, constructor) {
if (!this.prototype.hasOwnProperty("yaml_constructors")) {
this.prototype.yaml_constructors = util.extend({}, this.prototype.yaml_constructors);
}
return this.prototype.yaml_constructors[tag] = constructor;
};
BaseConstructor.add_multi_constructor = function(tag_prefix, multi_constructor) {
if (!this.prototype.hasOwnProperty("yaml_multi_constructors")) {
this.prototype.yaml_multi_constructors = util.extend({}, this.prototype.yaml_multi_constructors);
}
return this.prototype.yaml_multi_constructors[tag_prefix] = multi_constructor;
};
function BaseConstructor() {
this.constructed_objects = {};
this.constructing_nodes = [];
this.deferred_constructors = [];
}
BaseConstructor.prototype.check_data = function() {
return this.check_node();
};
BaseConstructor.prototype.get_data = function() {
if (this.check_node()) {
return this.construct_document(this.get_node());
}
};
BaseConstructor.prototype.get_single_data = function() {
var node;
node = this.get_single_node();
if (node != null) {
return this.construct_document(node);
}
return null;
};
BaseConstructor.prototype.construct_document = function(node) {
var data;
data = this.construct_object(node);
while (!util.is_empty(this.deferred_constructors)) {
this.deferred_constructors.pop()();
}
return data;
};
BaseConstructor.prototype.defer = function(f) {
return this.deferred_constructors.push(f);
};
BaseConstructor.prototype.construct_object = function(node) {
var constructor, object, ref, tag_prefix, tag_suffix;
if (node.unique_id in this.constructed_objects) {
return this.constructed_objects[node.unique_id];
}
if (ref = node.unique_id, indexOf.call(this.constructing_nodes, ref) >= 0) {
throw new exports.ConstructorError(null, null, "found unconstructable recursive node", node.start_mark);
}
this.constructing_nodes.push(node.unique_id);
constructor = null;
tag_suffix = null;
if (node.tag in this.yaml_constructors) {
constructor = this.yaml_constructors[node.tag];
} else {
for (tag_prefix in this.yaml_multi_constructors) {
if (node.tag.indexOf(tag_prefix === 0)) {
tag_suffix = node.tag.slice(tag_prefix.length);
constructor = this.yaml_multi_constructors[tag_prefix];
break;
}
}
if (constructor == null) {
if (null in this.yaml_multi_constructors) {
tag_suffix = node.tag;
constructor = this.yaml_multi_constructors[null];
} else if (null in this.yaml_constructors) {
constructor = this.yaml_constructors[null];
} else if (node instanceof nodes.ScalarNode) {
constructor = this.construct_scalar;
} else if (node instanceof nodes.SequenceNode) {
constructor = this.construct_sequence;
} else if (node instanceof nodes.MappingNode) {
constructor = this.construct_mapping;
}
}
}
object = constructor.call(this, tag_suffix != null ? tag_suffix : node, node);
this.constructed_objects[node.unique_id] = object;
this.constructing_nodes.pop();
return object;
};
BaseConstructor.prototype.construct_scalar = function(node) {
if (!(node instanceof nodes.ScalarNode)) {
throw new exports.ConstructorError(null, null, "expected a scalar node but found " + node.id, node.start_mark);
}
return node.value;
};
BaseConstructor.prototype.construct_sequence = function(node) {
var child, i, len, ref, results;
if (!(node instanceof nodes.SequenceNode)) {
throw new exports.ConstructorError(null, null, "expected a sequence node but found " + node.id, node.start_mark);
}
ref = node.value;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
results.push(this.construct_object(child));
}
return results;
};
BaseConstructor.prototype.construct_mapping = function(node) {
var i, key, key_node, len, mapping, ref, ref1, value, value_node;
if (!(node instanceof nodes.MappingNode)) {
throw new ConstructorError(null, null, "expected a mapping node but found " + node.id, node.start_mark);
}
mapping = {};
ref = node.value;
for (i = 0, len = ref.length; i < len; i++) {
ref1 = ref[i], key_node = ref1[0], value_node = ref1[1];
key = this.construct_object(key_node);
if (typeof key === "object") {
throw new exports.ConstructorError("while constructing a mapping", node.start_mark, "found unhashable key", key_node.start_mark);
}
value = this.construct_object(value_node);
mapping[key] = value;
}
return mapping;
};
BaseConstructor.prototype.construct_pairs = function(node) {
var i, key, key_node, len, pairs, ref, ref1, value, value_node;
if (!(node instanceof nodes.MappingNode)) {
throw new exports.ConstructorError(null, null, "expected a mapping node but found " + node.id, node.start_mark);
}
pairs = [];
ref = node.value;
for (i = 0, len = ref.length; i < len; i++) {
ref1 = ref[i], key_node = ref1[0], value_node = ref1[1];
key = this.construct_object(key_node);
value = this.construct_object(value_node);
pairs.push([ key, value ]);
}
return pairs;
};
return BaseConstructor;
}();
this.Constructor = function(superClass) {
var BOOL_VALUES, TIMESTAMP_PARTS, TIMESTAMP_REGEX;
extend(Constructor, superClass);
function Constructor() {
return Constructor.__super__.constructor.apply(this, arguments);
}
BOOL_VALUES = {
on: true,
off: false,
"true": true,
"false": false,
yes: true,
no: false
};
TIMESTAMP_REGEX = /^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[\x20\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\.([0-9]*))?(?:[\x20\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$/;
TIMESTAMP_PARTS = {
year: 1,
month: 2,
day: 3,
hour: 4,
minute: 5,
second: 6,
fraction: 7,
tz: 8,
tz_sign: 9,
tz_hour: 10,
tz_minute: 11
};
Constructor.prototype.construct_scalar = function(node) {
var i, key_node, len, ref, ref1, value_node;
if (node instanceof nodes.MappingNode) {
ref = node.value;
for (i = 0, len = ref.length; i < len; i++) {
ref1 = ref[i], key_node = ref1[0], value_node = ref1[1];
if (key_node.tag === "tag:yaml.org,2002:value") {
return this.construct_scalar(value_node);
}
}
}
return Constructor.__super__.construct_scalar.call(this, node);
};
Constructor.prototype.flatten_mapping = function(node) {
var i, index, j, key_node, len, len1, merge, ref, ref1, submerge, subnode, value, value_node;
merge = [];
index = 0;
while (index < node.value.length) {
ref = node.value[index], key_node = ref[0], value_node = ref[1];
if (key_node.tag === "tag:yaml.org,2002:merge") {
node.value.splice(index, 1);
if (value_node instanceof nodes.MappingNode) {
this.flatten_mapping(value_node);
merge = merge.concat(value_node.value);
} else if (value_node instanceof nodes.SequenceNode) {
submerge = [];
ref1 = value_node.value;
for (i = 0, len = ref1.length; i < len; i++) {
subnode = ref1[i];
if (!(subnode instanceof nodes.MappingNode)) {
throw new exports.ConstructorError("while constructing a mapping", node.start_mark, "expected a mapping for merging, but found " + subnode.id, subnode.start_mark);
}
this.flatten_mapping(subnode);
submerge.push(subnode.value);
}
submerge.reverse();
for (j = 0, len1 = submerge.length; j < len1; j++) {
value = submerge[j];
merge = merge.concat(value);
}
} else {
throw new exports.ConstructorError("while constructing a mapping", node.start_mark, "expected a mapping or list of mappings for merging but found " + value_node.id, value_node.start_mark);
}
} else if (key_node.tag === "tag:yaml.org,2002:value") {
key_node.tag = "tag:yaml.org,2002:str";
index++;
} else {
index++;
}
}
if (merge.length) {
return node.value = merge.concat(node.value);
}
};
Constructor.prototype.construct_mapping = function(node) {
if (node instanceof nodes.MappingNode) {
this.flatten_mapping(node);
}
return Constructor.__super__.construct_mapping.call(this, node);
};
Constructor.prototype.construct_yaml_null = function(node) {
this.construct_scalar(node);
return null;
};
Constructor.prototype.construct_yaml_bool = function(node) {
var value;
value = this.construct_scalar(node);
return BOOL_VALUES[value.toLowerCase()];
};
Constructor.prototype.construct_yaml_int = function(node) {
var base, digit, digits, i, len, part, ref, sign, value;
value = this.construct_scalar(node);
value = value.replace(/_/g, "");
sign = value[0] === "-" ? -1 : 1;
if (ref = value[0], indexOf.call("+-", ref) >= 0) {
value = value.slice(1);
}
if (value === "0") {
return 0;
} else if (value.indexOf("0b") === 0) {
return sign * parseInt(value.slice(2), 2);
} else if (value.indexOf("0x") === 0) {
return sign * parseInt(value.slice(2), 16);
} else if (value.indexOf("0o") === 0) {
return sign * parseInt(value.slice(2), 8);
} else if (value[0] === "0") {
return sign * parseInt(value, 8);
} else if (indexOf.call(value, ":") >= 0) {
digits = function() {
var i, len, ref1, results;
ref1 = value.split(/:/g);
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
part = ref1[i];
results.push(parseInt(part));
}
return results;
}();
digits.reverse();
base = 1;
value = 0;
for (i = 0, len = digits.length; i < len; i++) {
digit = digits[i];
value += digit * base;
base *= 60;
}
return sign * value;
} else {
return sign * parseInt(value);
}
};
Constructor.prototype.construct_yaml_float = function(node) {
var base, digit, digits, i, len, part, ref, sign, value;
value = this.construct_scalar(node);
value = value.replace(/_/g, "").toLowerCase();
sign = value[0] === "-" ? -1 : 1;
if (ref = value[0], indexOf.call("+-", ref) >= 0) {
value = value.slice(1);
}
if (value === ".inf") {
return sign * Infinity;
} else if (value === ".nan") {
return NaN;
} else if (indexOf.call(value, ":") >= 0) {
digits = function() {
var i, len, ref1, results;
ref1 = value.split(/:/g);
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
part = ref1[i];
results.push(parseFloat(part));
}
return results;
}();
digits.reverse();
base = 1;
value = 0;
for (i = 0, len = digits.length; i < len; i++) {
digit = digits[i];
value += digit * base;
base *= 60;
}
return sign * value;
} else {
return sign * parseFloat(value);
}
};
Constructor.prototype.construct_yaml_binary = function(node) {
var error, value;
value = this.construct_scalar(node);
try {
if (typeof window !== "undefined" && window !== null) {
return atob(value);
}
return (new Buffer(value, "base64")).toString("ascii");
} catch (_error) {
error = _error;
throw new exports.ConstructorError(null, null, "failed to decode base64 data: " + error, node.start_mark);
}
};
Constructor.prototype.construct_yaml_timestamp = function(node) {
var date, day, fraction, hour, index, key, match, millisecond, minute, month, second, tz_hour, tz_minute, tz_sign, value, values, year;
value = this.construct_scalar(node);
match = node.value.match(TIMESTAMP_REGEX);
values = {};
for (key in TIMESTAMP_PARTS) {
index = TIMESTAMP_PARTS[key];
values[key] = match[index];
}
year = parseInt(values.year);
month = parseInt(values.month) - 1;
day = parseInt(values.day);
if (!values.hour) {
return new Date(Date.UTC(year, month, day));
}
hour = parseInt(values.hour);
minute = parseInt(values.minute);
second = parseInt(values.second);
millisecond = 0;
if (values.fraction) {
fraction = values.fraction.slice(0, 6);
while (fraction.length < 6) {
fraction += "0";
}
fraction = parseInt(fraction);
millisecond = Math.round(fraction / 1e3);
}
if (values.tz_sign) {
tz_sign = values.tz_sign === "-" ? 1 : -1;
if (tz_hour = parseInt(values.tz_hour)) {
hour += tz_sign * tz_hour;
}
if (tz_minute = parseInt(values.tz_minute)) {
minute += tz_sign * tz_minute;
}
}
date = new Date(Date.UTC(year, month, day, hour, minute, second, millisecond));
return date;
};
Constructor.prototype.construct_yaml_pair_list = function(type, node) {
var list;
list = [];
if (!(node instanceof nodes.SequenceNode)) {
throw new exports.ConstructorError("while constructing " + type, node.start_mark, "expected a sequence but found " + node.id, node.start_mark);
}
this.defer(function(_this) {
return function() {
var i, key, key_node, len, ref, ref1, results, subnode, value, value_node;
ref = node.value;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
subnode = ref[i];
if (!(subnode instanceof nodes.MappingNode)) {
throw new exports.ConstructorError("while constructing " + type, node.start_mark, "expected a mapping of length 1 but found " + subnode.id, subnode.start_mark);
}
if (subnode.value.length !== 1) {
throw new exports.ConstructorError("while constructing " + type, node.start_mark, "expected a mapping of length 1 but found " + subnode.id, subnode.start_mark);
}
ref1 = subnode.value[0], key_node = ref1[0], value_node = ref1[1];
key = _this.construct_object(key_node);
value = _this.construct_object(value_node);
results.push(list.push([ key, value ]));
}
return results;
};
}(this));
return list;
};
Constructor.prototype.construct_yaml_omap = function(node) {
return this.construct_yaml_pair_list("an ordered map", node);
};
Constructor.prototype.construct_yaml_pairs = function(node) {
return this.construct_yaml_pair_list("pairs", node);
};
Constructor.prototype.construct_yaml_set = function(node) {
var data;
data = [];
this.defer(function(_this) {
return function() {
var item, results;
results = [];
for (item in _this.construct_mapping(node)) {
results.push(data.push(item));
}
return results;
};
}(this));
return data;
};
Constructor.prototype.construct_yaml_str = function(node) {