1.0.1 • Published 4 years ago

sum-of v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

sum-of

Returns the sum of the values of the same property off all objects in the supplied list

Build Status Coverage Status Maintainability Language grade: JavaScript tested with jest code style: prettier

Install

$ npm install sum-of

Usage

const sumOf = require("sum-of");

const objects = [{ a: 2 }, { a: 3, b: 1 }];

sumOf(["a"], objects); //=> 5

API

sumOf ⇒ Number

Returns the sum of the values of the same property off all objects in the supplied list

Returns: Number - sum of the selected properties
Sig: a -> a -> Number

ParamTypeDescription
pathString[]the path to work with
objectsObject[]objects to retrieve values from

Example

sumOf(["a"], [{ a: 2 }, { a: 3, b: 1 }]); //=> 5

License

MIT © saxjst

1.0.1

4 years ago

1.0.0

4 years ago