JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30653F
  • License MIT

Package Exports

  • jkg-array-column-sum
  • jkg-array-column-sum/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jkg-array-column-sum) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Import the "getColumnSum" function into your component or service by adding the following code:

import getColumnSum from 'jkg-array-column-sum';

Call the "getColumnSum" function with a array, column names like ['column-name-1','column-name-2',...] & format type: to get total value, like this:

Test Cases for method:

var data = [ ['id','date','Amount'], ['1','111','123'], ['2','121','13'] ];

var result = getColumnSum(data,[],false) // By default it will consider defined columns 'Amount','Additions','Subtractions' // Output > 136

var result = getColumnSum(data,['Amount'],false) // Output > 136

var result = getColumnSum(data,['Amount'],true) // Output > Array ["", "Total", 136]

var result = getColumnSum(data,['Amounts'],false) // Output > 0

var result = getColumnSum(data,['Amounts'],true) // Output > Array []