biofriction-wp-theme/node_modules/undertaker/lib/helpers/buildTree.js

30 lines
519 B
JavaScript
Raw Permalink Normal View History

2021-10-26 14:18:09 +02:00
'use strict';
var map = require('collection-map');
var metadata = require('./metadata');
function buildTree(tasks) {
return map(tasks, function(task) {
var meta = metadata.get(task);
if (meta) {
return meta.tree;
}
var name = task.displayName || task.name || '<anonymous>';
meta = {
name: name,
tree: {
label: name,
type: 'function',
nodes: [],
},
};
metadata.set(task, meta);
return meta.tree;
});
}
module.exports = buildTree;