hypnotable-footer
Add a footer to your Hypnotable! Great for totals or other reductions of data.
Last updated 6 years ago by dguttman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hypnotable-footer 
SYNC missed versions from official npm registry.

Hypnotable Footer

Add a footer to your Hypnotable! Great for totals or other reductions of data.

Usage

Install: npm i -S hypnotable-footer

Columns now take a reduce function. The object returned by reduce will be fed into property and then template:

var columns = [
  {
    title: 'Repos per Follower',
    property: function(user) {
      return user.public_repos / user.followers
    },
    template: function(val) {
      return val.toFixed(3)
    },
    reduce: function(user, memo) {
      memo = memo || {public_repos: 0, followers: 0}
      memo.public_repos += user.public_repos
      memo.followers += user.followers
      return memo
    }
  },
  {
    title: 'Repos',
    property: 'public_repos',
    className: 'repositories',
    reduce: function(user, memo) {
      memo = memo || {public_repos: 0}
      memo.public_repos += user.public_repos
      return memo
    }
  }
]

var ht = hypnotable(columns)
var htf = require('hypnotable-footer')(ht.el, columns)

data.pipe(ht)
data.pipe(htf)

Example

npm run example

License

MIT

Current Tags

  • 1.0.2                                ...           latest (6 years ago)

3 Versions

  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |