aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2018-08-17 21:28:17 -0500
committerGitHub <noreply@github.com>2018-08-17 21:28:17 -0500
commit2d23accb8707a4942ca8ce456cb5b14b36a040dd (patch)
tree9baf7b19e79c63a45d85ca81c06c899cfbe05506 /lib/utils.js
parent245ae4d08e09c6199b7d9f511e6cfff7463b3c4b (diff)
parente7c6f813ddc9581d0704c455420cb5352ab6f72d (diff)
downloadcompiler-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.js20
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;
+
+};