Socket
Socket
Sign inDemoInstall

immutable-math

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    immutable-math

Some maths for immutable collections.


Version published
Weekly downloads
13
increased by8.33%
Maintainers
1
Install size
192 kB
Created
Weekly downloads
 

Readme

Source

immutable-math

MIT licensed github-issues

Some mathematatics for Immutable.js for aggregations and stuff.

Documentation here.

install

npm install immutable-math

Usage

Functions in this library use partially applied functions. For example, one way to use average is to call it, passing in any parameters required (average requires no extra params), then call the returned function passing in your data.

const numbers = fromJS([1,1,1,5]);
return average()(numbers); // returns 2

For any immutable-math functions that return an Iterable, this design of using a partially applied function allows for easy chaining by using them inside of an update() method, if your input Iterable has an update function.

return fromJS([1,1,1,5])
    .update(exampleFunction()) // using an exampleFunction from immutable-math in a chain
    .sort()
    .toJS();

You can also define a function to perform a specific operation, and use it multiple times by passing in different input data.

const numbersA = fromJS([
	{num: 1},
	{num: 1},
	{num: 1},
	{num: 5}
]);

const numbersB = fromJS([
	{num: 3},
	{num: 5}
]);

const averageByNum = averageBy(ii => ii.get('num'));
const averageA = numbersA.update(averageByNum); // averageA is 2
const averageB = numbersB.update(averageByNum); // averageB is 4

Keywords

FAQs

Last updated on 14 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc