Skip to content

Commit

Permalink
feat(math): add minNonZero2/3()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 23, 2020
1 parent 0567b93 commit 49c88d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/math/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- This file is generated - DO NOT EDIT! -->

# ![@thi.ng/math](https://media.thi.ng/umbrella/banners/thing-math.svg?1581297777)
# ![@thi.ng/math](https://media.thi.ng/umbrella/banners/thing-math.svg?1582480837)

[![npm version](https://img.shields.io/npm/v/@thi.ng/math.svg)](https://www.npmjs.com/package/@thi.ng/math)
![npm downloads](https://img.shields.io/npm/dm/@thi.ng/math.svg)
Expand Down Expand Up @@ -38,7 +38,7 @@ Partially ported from Clojure version of
yarn add @thi.ng/math
```

Package sizes (gzipped): ESM: 3.4KB / CJS: 3.9KB / UMD: 3.2KB
Package sizes (gzipped): ESM: 3.5KB / CJS: 4.0KB / UMD: 3.3KB

## Dependencies

Expand Down
19 changes: 19 additions & 0 deletions packages/math/src/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@ export const max4id = (a: number, b: number, c: number, d: number) =>
? 2
: 3;

/**
* Returns the non-zero minimum value of the given `a`, `b` args.
*
* @param a
* @param b
*/
export const minNonZero2 = (a: number, b: number) =>
a !== 0 ? (b !== 0 ? Math.min(a, b) : a) : b;

/**
* Returns the non-zero minimum value of the given `a`, `b`, `c` args.
*
* @param a
* @param b
* @param c
*/
export const minNonZero3 = (a: number, b: number, c: number) =>
minNonZero2(minNonZero2(a, b), c);

/**
* See `smax()`.
*
Expand Down

0 comments on commit 49c88d9

Please sign in to comment.