JSPM

math-foreach

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q15217F
  • License UNLICENSED

Simple Array Math Library

Package Exports

  • math-foreach

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (math-foreach) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

math-foreach

Simple Array Math Library

npm version dependencies Build Status lifetimeDownloadCount Pledge To Arupex!

Methods are all static, except chain methods, which can be accessed using constructor of constructor(array, optionalAccessor)

#Install

npm install math-foreach --save

#Usage

var MFE = require('math-foreach');
chainObj = new MFE(array, optionalAccessorStr);

Data Styles

var dataStyle1 = [
                   {
                     "value": 0
                   },
                   {
                     "value": 1
                   },
                   {
                     "value": 2
                   }
                 ]
                 
 var dataStyle2 = [0, 1, 2]

Simple Array Style Calls

 math.normalize(dataStyle2));   // rerange 0-1
 math.multiply(dataStyle2, 5)); // multiplyiesvalues by 5
 math.add(dataStyle2, 5));      // adds 2 to values
 math.median(dataStyle2));      // determines median
 math.mode(dataStyle2));        // determines mode
 math.avg(dataStyle2));         // determines average
 math.min(dataStyle2));         // determines min
 math.max(dataStyle2));         // determines max
 math.values(dataStyle1, 'value') // returns dataStyle2
 

Object Array Style Calls

math.normalize(dataStyle2, 'value');   // rerange 0-1
math.multiply(dataStyle2, 5, 'value'); // multiplyiesvalues by 5
math.add(dataStyle2, 5, 'value');      // adds 2 to values
math.median(dataStyle2, 'value');      // determines median
math.mode(dataStyle2, 'value');        // determines mode
math.avg(dataStyle2, 'value');         // determines average
math.min(dataStyle2, 'value');         // determines min
math.max(dataStyle2, 'value');         // determines max

Chain Calls

  let obj = new MathForEach(myArray, optionalAccessor);
  
  obj
    .chainDerivative(1)
    .chainNormalize()
    .chainMedian()
    .toValue();

#API

 positiveShift(array, optionalAccessor)
 normalize(array, optionalAccessor)
 multiply(array, optionalAccessor)
 add(array, optionalAccessor)
 mode(array, optionalAccessor)
 median(array, optionalAccessor)
 avg(array, optionalAccessor)
 min(array, optionalAccessor)
 max(array, optionalAccessor)
 
 derivativeNth(array, nth, optionalAccessor)
 onlyAbove(array, optionalAccessor)
 onlyEqual(array, optionalAccessor)
 onlyBelow(array, optionalAccessor)
 onlyBelow(array, optionalAccessor)
 

Chains

    chainDerivative(nth, optionalAccessor)
    chainNormalize(optionalAccessor, shiftMin)
    chainPositiveShift(optionalAccessor)
    chainDiff(array2, optionalAccessor)
    chainOnlyAbove(targetValue, optionalAccessor, dontInclude)
    chainOnlyBelow(targetValue, optionalAccessor, dontInclude)
    chainOnlyEqual(targetValue, optionalAccessor, dontInclude)
    chainAdd(targetValue, optionalAccessor)
    chainMultiply(targetValue, optionalAccessor)
    chainAvg(optionalAccessor)
    chainMin(optionalAccessor)
    chainMax(optionalAccessor)
    chainMedian(optionalAccessor)
    chainMode(optionalAccessor)