Huge commit, implement rough working version of the whole resolve process.

This commit is contained in:
André Cruz
2013-05-13 11:09:04 +01:00
parent adf14f79e0
commit e09a3b8cbf
33 changed files with 1247 additions and 224 deletions

View File

@@ -0,0 +1,35 @@
var createError = require('./createError');
function decompose(endpoint) {
var regExp = /^(?:([\w\-]|(?:[\w\.\-]+[\w\-])?)\|)?([^\|#]+)(?:#(.*))?$/;
var matches = endpoint.match(regExp);
if (!matches) {
throw createError('Invalid endpoint: "' + endpoint + '"', 'EINVEND');
}
return {
name: matches[1] || '',
source: matches[2],
target: matches[3] || '*'
};
}
function compose(decEndpoint) {
var composed = '';
if (decEndpoint.name) {
composed += decEndpoint.name + '|';
}
composed += decEndpoint.source;
if (decEndpoint.target) {
composed += '#' + decEndpoint.target;
}
return composed;
}
module.exports.decompose = decompose;
module.exports.compose = compose;