"Fossies" - the Fresh Open Source Software Archive 
Member "Atom/resources/app/apm/node_modules/npm/lib/install/node.js" (16 Apr 2018, 1464 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
3 var defaultTemplate = {
4 package: {
5 version: '',
6 dependencies: {},
7 devDependencies: {},
8 optionalDependencies: {}
9 },
10 loaded: false,
11 children: [],
12 requiredBy: [],
13 requires: [],
14 missingDeps: {},
15 missingDevDeps: {},
16 phantomChildren: {},
17 path: null,
18 realpath: null,
19 location: null,
20 userRequired: false,
21 existing: false,
22 isTop: false
23 }
24
25 function isLink (node) {
26 return node && node.isLink
27 }
28
29 var create = exports.create = function (node, template) {
30 if (!template) template = defaultTemplate
31 Object.keys(template).forEach(function (key) {
32 if (template[key] != null && typeof template[key] === 'object' && !(template[key] instanceof Array)) {
33 if (!node[key]) node[key] = {}
34 return create(node[key], template[key])
35 }
36 if (node[key] != null) return
37 node[key] = template[key]
38 })
39 if (isLink(node.parent)) {
40 node.isLink = true
41 }
42 return node
43 }
44
45 exports.reset = function (node) {
46 reset(node, {})
47 }
48
49 function reset (node, seen) {
50 if (seen[node.path]) return
51 seen[node.path] = true
52 var child = create(node)
53
54 // FIXME: cleaning up after read-package-json's mess =(
55 if (child.package._id === '@') delete child.package._id
56
57 child.isTop = false
58 child.requiredBy = []
59 child.requires = []
60 child.missingDeps = {}
61 child.missingDevDeps = {}
62 child.phantomChildren = {}
63 child.location = null
64
65 child.children.forEach(function (child) { reset(child, seen) })
66 }