0.0.1 • Published 2 years ago
@santi100/product-series v0.0.1
Santi's Powerful Product Series Library
- 📘 Comes with built-in TypeScript definitions
- 🚀 Lightweight and fast
- 👴 Compliant with ECMAScript 3
API
function product(arr: number[]): number;Product of the numbers in an array.
Name Type Description Optional? arrnumber[]An array of numbers. No Returns the product of all numbers in the array.
function product(fn: (n: number) => number, start: number, end: number): number;Product of numbers in
start,end.Name Type Description Optional? fn(n: number) => numberA math function to process every number in the range. No startnumberInclusive start of the range. No endnumberInclusive end of the range. No Returns the product of
start,endwith a step ofstep.
Usage
import product from '@santi100/product-series'; // ESM
const product = require('@santi100/product-series'); // CJS
// Example 1: Product of numbers in an array
const arr = [1, 2, 3, 4, 5];
const result1 = product(arr);
console.log(result1); // Output: 120
// Example 2: Product of numbers in a range
const fn = (n: number) => n ** 2;
const start = 1;
const end = 5;
const result2 = product(fn, start, end);
console.log(result2); // Output: 144000.0.1
2 years ago