"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/copy-tree.js" (7 Feb 2017, 625 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict'
    2 
    3 module.exports = function (tree) {
    4   return copyTree(tree, {})
    5 }
    6 
    7 function copyTree (tree, cache) {
    8   if (cache[tree.path]) return cache[tree.path]
    9   var newTree = cache[tree.path] = Object.create(tree)
   10   copyModuleList(newTree, 'children', cache)
   11   newTree.children.forEach(function (child) {
   12     child.parent = newTree
   13   })
   14   copyModuleList(newTree, 'requires', cache)
   15   copyModuleList(newTree, 'requiredBy', cache)
   16   return newTree
   17 }
   18 
   19 function copyModuleList (tree, key, cache) {
   20   var newList = []
   21   tree[key].forEach(function (child) {
   22     newList.push(copyTree(child, cache))
   23   })
   24   tree[key] = newList
   25 }