Projekt

Obecné

Profil

Stáhnout (1.16 KB) Statistiky
| Větev: | Revize:
1
# object-inspect
2

    
3
string representations of objects in node and the browser
4

    
5
[![testling badge](https://ci.testling.com/substack/object-inspect.png)](https://ci.testling.com/substack/object-inspect)
6

    
7
[![build status](https://secure.travis-ci.org/substack/object-inspect.png)](http://travis-ci.org/substack/object-inspect)
8

    
9
# example
10

    
11
## circular
12

    
13
``` js
14
var inspect = require('object-inspect');
15
var obj = { a: 1, b: [3,4] };
16
obj.c = obj;
17
console.log(inspect(obj));
18
```
19

    
20
## dom element
21

    
22
``` js
23
var inspect = require('object-inspect');
24

    
25
var d = document.createElement('div');
26
d.setAttribute('id', 'beep');
27
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
28

    
29
console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));
30
```
31

    
32
output:
33

    
34
```
35
[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
36
```
37

    
38
# methods
39

    
40
``` js
41
var inspect = require('object-inspect')
42
```
43

    
44
## var s = inspect(obj, opts={})
45

    
46
Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
47

    
48
Additional options:
49
  - `quoteStyle`: must be "single" or "double", if present
50

    
51
# install
52

    
53
With [npm](https://npmjs.org) do:
54

    
55
```
56
npm install object-inspect
57
```
58

    
59
# license
60

    
61
MIT
(6-6/8)