0.0.1 • Published 10 months ago

@santi100/product-series v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Santi's Powerful Product Series Library

Build Status npm homepage GitHub stars License Bundlephobia stats

  • 📘 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.

    NameTypeDescriptionOptional?
    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.

    NameTypeDescriptionOptional?
    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, end with a step of step.

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: 14400