diff options
author | Matt Godbolt <matt@godbolt.org> | 2018-08-17 21:28:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-17 21:28:17 -0500 |
commit | 2d23accb8707a4942ca8ce456cb5b14b36a040dd (patch) | |
tree | 9baf7b19e79c63a45d85ca81c06c899cfbe05506 /lib/utils.js | |
parent | 245ae4d08e09c6199b7d9f511e6cfff7463b3c4b (diff) | |
parent | e7c6f813ddc9581d0704c455420cb5352ab6f72d (diff) | |
download | compiler-explorer-2d23accb8707a4942ca8ce456cb5b14b36a040dd.tar.gz compiler-explorer-2d23accb8707a4942ca8ce456cb5b14b36a040dd.zip |
Merge pull request #1055 from mattgodbolt/ogtest
og: tags
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/utils.js b/lib/utils.js index 53218b25b..037d3236c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -123,3 +123,23 @@ exports.getHash = function getHash(object, HashVersion = 'Compiler Explorer Defa .update(asString) .digest('hex'); }; + +/*** + * Gets every pair of source, lang available + * @param content {Array} + * @returns {Array} + */ +exports.glGetEditorSources = function glGetEditorSources(content) { + let sources = []; + _.each(content, element => { + if (element.type === 'component') { + if (element.componentName === 'codeEditor') { + sources.push({source: element.componentState.source, language: element.componentState.lang}); + } + } else { + sources = glGetEditorSources(element.content).concat(sources); + } + }); + return sources; + +}; |