The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / npm / html / api / view.html @ 5aef65a9

History | View | Annotate | Download (4.85 KB)

1
<!doctype html>
2
<html>
3
  <title>view</title>
4
  <meta http-equiv="content-type" value="text/html;utf-8">
5
  <link rel="stylesheet" type="text/css" href="../static/style.css">
6

    
7
  <body>
8
    <div id="wrapper">
9
<h1><a href="../api/view.html">view</a></h1> <p>View registry info</p>
10

    
11
<h2 id="SYNOPSIS">SYNOPSIS</h2>
12

    
13
<pre><code>npm.commands.view(args, [silent,] callback)</code></pre>
14

    
15
<h2 id="DESCRIPTION">DESCRIPTION</h2>
16

    
17
<p>This command shows data about a package and prints it to the stream
18
referenced by the <code>outfd</code> config, which defaults to stdout.</p>
19

    
20
<p>The &quot;args&quot; parameter is an ordered list that closely resembles the command-line
21
usage. The elements should be ordered such that the first element is
22
the package and version (package@version). The version is optional. After that,
23
the rest of the parameters are fields with optional subfields (&quot;field.subfield&quot;)
24
which can be used to get only the information desired from the registry.</p>
25

    
26
<p>The callback will be passed all of the data returned by the query.</p>
27

    
28
<p>For example, to get the package registry entry for the <code>connect</code> package,
29
you can do this:</p>
30

    
31
<pre><code>npm.commands.view([&quot;connect&quot;], callback)</code></pre>
32

    
33
<p>If no version is specified, &quot;latest&quot; is assumed.</p>
34

    
35
<p>Field names can be specified after the package descriptor.
36
For example, to show the dependencies of the <code>ronn</code> package at version
37
0.3.5, you could do the following:</p>
38

    
39
<pre><code>npm.commands.view([&quot;ronn@0.3.5&quot;, &quot;dependencies&quot;], callback)</code></pre>
40

    
41
<p>You can view child field by separating them with a period.
42
To view the git repository URL for the latest version of npm, you could
43
do this:</p>
44

    
45
<pre><code>npm.commands.view([&quot;npm&quot;, &quot;repository.url&quot;], callback)</code></pre>
46

    
47
<p>For fields that are arrays, requesting a non-numeric field will return
48
all of the values from the objects in the list.  For example, to get all
49
the contributor names for the &quot;express&quot; project, you can do this:</p>
50

    
51
<pre><code>npm.commands.view([&quot;express&quot;, &quot;contributors.email&quot;], callback)</code></pre>
52

    
53
<p>You may also use numeric indices in square braces to specifically select
54
an item in an array field.  To just get the email address of the first
55
contributor in the list, you can do this:</p>
56

    
57
<pre><code>npm.commands.view([&quot;express&quot;, &quot;contributors[0].email&quot;], callback)</code></pre>
58

    
59
<p>Multiple fields may be specified, and will be printed one after another.
60
For exampls, to get all the contributor names and email addresses, you
61
can do this:</p>
62

    
63
<pre><code>npm.commands.view([&quot;express&quot;, &quot;contributors.name&quot;, &quot;contributors.email&quot;], callback)</code></pre>
64

    
65
<p>&quot;Person&quot; fields are shown as a string if they would be shown as an
66
object.  So, for example, this will show the list of npm contributors in
67
the shortened string format.  (See <code>npm help json</code> for more on this.)</p>
68

    
69
<pre><code>npm.commands.view([&quot;npm&quot;, &quot;contributors&quot;], callback)</code></pre>
70

    
71
<p>If a version range is provided, then data will be printed for every
72
matching version of the package.  This will show which version of jsdom
73
was required by each matching version of yui3:</p>
74

    
75
<pre><code>npm.commands.view([&quot;yui3@&#39;&gt;0.5.4&#39;&quot;, &quot;dependencies.jsdom&quot;], callback)</code></pre>
76

    
77
<h2 id="OUTPUT">OUTPUT</h2>
78

    
79
<p>If only a single string field for a single version is output, then it
80
will not be colorized or quoted, so as to enable piping the output to
81
another command.</p>
82

    
83
<p>If the version range matches multiple versions, than each printed value
84
will be prefixed with the version it applies to.</p>
85

    
86
<p>If multiple fields are requested, than each of them are prefixed with
87
the field name.</p>
88

    
89
<p>Console output can be disabled by setting the &#39;silent&#39; parameter to true.</p>
90

    
91
<h2 id="RETURN-VALUE">RETURN VALUE</h2>
92

    
93
<p>The data returned will be an object in this formation:</p>
94

    
95
<pre><code>{ &lt;version&gt;:
96
  { &lt;field&gt;: &lt;value&gt;
97
  , ... }
98
, ... }</code></pre>
99

    
100
<p>corresponding to the list of fields selected.</p>
101
</div>
102
<p id="footer">view &mdash; npm@1.2.10</p>
103
<script>
104
;(function () {
105
var wrapper = document.getElementById("wrapper")
106
var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
107
  .filter(function (el) {
108
    return el.parentNode === wrapper
109
        && el.tagName.match(/H[1-6]/)
110
        && el.id
111
  })
112
var l = 2
113
  , toc = document.createElement("ul")
114
toc.innerHTML = els.map(function (el) {
115
  var i = el.tagName.charAt(1)
116
    , out = ""
117
  while (i > l) {
118
    out += "<ul>"
119
    l ++
120
  }
121
  while (i < l) {
122
    out += "</ul>"
123
    l --
124
  }
125
  out += "<li><a href='#" + el.id + "'>" +
126
    ( el.innerText || el.text || el.innerHTML)
127
    + "</a>"
128
  return out
129
}).join("\n")
130
toc.id = "toc"
131
document.body.appendChild(toc)
132
})()
133
</script>
134
</body></html>