@santi100/product-series
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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.

    Name Type Description Optional?
    arr number[] 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) => number A math function to process every number in the range. No
    start number Inclusive start of the range. No
    end number Inclusive 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

Package Sidebar

Install

npm i @santi100/product-series

Weekly Downloads

3

Version

0.0.1

License

MIT

Unpacked Size

35.6 kB

Total Files

39

Last publish

Collaborators

  • santi100a