Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sumov

dimitrievski36MIT1.2.0

Computes the sum of all numeric values in an (multilevel) object

sum, object, array, multilevel, values

readme

Sumov

Computes the sum of all numeric values in an (multilevel) object.

To sum up to N levels of an object, just pass N as a second parameter.

Usage

const sumov = require('sumov');

let sum = sumov({a: 2, b: ["2", null, [], {a: {a: -1.0}}], c: {quick: "maths"}});
// => 3

//sum up to 2 levels
sum = sumov({a: 2, b: ["2", null, [], {a: {a: -1.0}}], c: {quick: "maths"}}, 2);
// => 4

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

Installation is done using the npm install command:

$ npm i --save sumov

See the package source for more details.