sum.js

Sum a list of number literals, nested object property values, or values returned from a custom function for Node.js and the browser.

Usage no npm install needed!

<script type="module">
  import sumJs from 'https://cdn.skypack.dev/sum.js';
</script>

README

sum.js

Build Status NPM version NPM downloads LICENSE

Sum a list of number literals, nested object property values, or values returned from a custom function for Node.js and the browser.

Examples

Number literals

sum([1, 2, 3, 4]);
//=> 10

Nested object properties

var strings = ['literal', 'constructor'];
sum(strings, 'length');
//=> 18

Custom function

sum([1, 2, 3, 4], function (n) { n * 60 });
//=> 600

Installation

component

$ component install wilmoore/sum.js

bower

$ bower install sum.js

npm

NPM

volo

$ volo add wilmoore/sum.js

manual

  1. download

     % curl -#O https://raw.github.com/wilmoore/sum.js/master/sum.min.js
     or
     % curl -#O https://raw.github.com/wilmoore/sum.js/master/sum.js
    
  2. use

     <script src="sum.min.js"></script>
     or
     <script src="sum.js"></script>
    

License

MIT