"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/flatten-tree.js" (11 Apr 2017, 745 Bytes) of package /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 var validate = require('aproba')
    3 var moduleName = require('../utils/module-name.js')
    4 
    5 module.exports = function (tree) {
    6   validate('O', arguments)
    7   var seen = {}
    8   var flat = {}
    9   var todo = [[tree, '/']]
   10   while (todo.length) {
   11     var next = todo.shift()
   12     var pkg = next[0]
   13     seen[pkg.path] = true
   14     var path = next[1]
   15     flat[path] = pkg
   16     if (path !== '/') path += '/'
   17     for (var ii = 0; ii < pkg.children.length; ++ii) {
   18       var child = pkg.children[ii]
   19       if (!seen[child.path]) {
   20         todo.push([child, flatName(path, child)])
   21       }
   22     }
   23   }
   24   return flat
   25 }
   26 
   27 var flatName = module.exports.flatName = function (path, child) {
   28   validate('SO', arguments)
   29   return path + (moduleName(child) || 'TOP')
   30 }