1 | # Hypnotable #
|
2 |
|
3 | Want a table? Have a stream of object data?
|
4 |
|
5 | var Hypnotable = require('hypnotable');
|
6 |
|
7 | var hyperquest = require('hyperquest');
|
8 | var JSONStream = require('JSONStream');
|
9 | var accounting = require('accounting');
|
10 |
|
11 | columns = [
|
12 | {
|
13 | property: 'screenName',
|
14 | title: 'Screen Name'
|
15 | }, {
|
16 | property: 'followers',
|
17 | title: 'Follower Count',
|
18 | template: accounting.formatNumber
|
19 | }
|
20 | ];
|
21 |
|
22 | var stream = hyperquest('/api/accounts.json');
|
23 | var parser = JSONStream.parse([true]);
|
24 | stream.pipe(parser);
|
25 |
|
26 | var ht = Hypnotable(columns, parser);
|
27 | document.body.appendChild(ht.el);
|