Skip to content

Commit

Permalink
fix: rename getRandomInRange
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmaeuer committed Feb 13, 2023
1 parent 80a318b commit 4b6666d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ by [**SWR Audio Lab**](https://lab.swr.de/)

## Changelog

- 2023-02-08 - v1.1.1
- 2023-02-13 - v1.1.1
- feat: add `addTrailingZeros` to numbers package
- feat: add `addLeadingZero` to numbers package
- feat: add `getDiff` to numbers package
- feat: add `getAverage` to numbers package
- feat: add `getSum` to numbers package
- feat: add `getRandomIn` to numbers package
- feat: add `getRandomInRange` to numbers package
- feat: add `roundTo` to numbers package

- 2022-12-19 - v1.1.0
Expand Down
10 changes: 5 additions & 5 deletions packages/numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Common number and math helpers.
- [`addTrailingZeros` - add trailing zeros to number](#addtrailingzeros---add-trailing-zeros-to-number)
- [`getAverage` - get average from array of numbers](#getaverage---get-average-from-array-of-numbers)
- [`getDiff` - get difference of two numbers](#getdiff---get-difference-of-two-numbers)
- [`getRandomIn` - get random int between min and max](#getrandomin---get-random-int-between-min-and-max)
- [`getRandomInRange` - get random int between min and max](#getrandominrange---get-random-int-between-min-and-max)
- [`getSum` - get sum from array of numbers](#getsum---get-sum-from-array-of-numbers)
- [`isEven` - check if a value is even](#iseven---check-if-a-value-is-even)
- [`roundTo` - round float to a specified decimal place](#roundto---round-float-to-a-specified-decimal-place)
Expand Down Expand Up @@ -118,24 +118,24 @@ getDiff(1, 2)
// -1
```

## `getRandomIn` - get random int between min and max
## `getRandomInRange` - get random int between min and max

- `min` (required) - Min value (inclusive)
- `max` (required) - Max value (inclusive)

Import the library:

```js
const { getRandomIn } = require('@swrlab/utils/packages/numbers')
const { getRandomInRange } = require('@swrlab/utils/packages/numbers')
```

Then use the toolkit:

```js
getRandomIn(1, 5)
getRandomInRange(1, 5)
// 1,2,3,4 or 5

getRandomIn(5, 9)
getRandomInRange(5, 9)
// 5,6,7,8 or 9
```

Expand Down
4 changes: 2 additions & 2 deletions packages/numbers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const addLeadingZero = require('../../utils/numbers/addLeadingZero')
const addTrailingZeros = require('../../utils/numbers/addTrailingZeros')
const getAverage = require('../../utils/numbers/getAverage')
const getDiff = require('../../utils/numbers/getDiff')
const getRandomIn = require('../../utils/numbers/getRandomIn')
const getRandomInRange = require('../../utils/numbers/getRandomInRange')
const getSum = require('../../utils/numbers/getSum')
const isEven = require('../../utils/numbers/isEven')
const roundTo = require('../../utils/numbers/roundTo')
Expand All @@ -15,7 +15,7 @@ module.exports = {
addTrailingZeros,
getAverage,
getDiff,
getRandomIn,
getRandomInRange,
getSum,
isEven,
roundTo,
Expand Down
10 changes: 5 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ describe('Test Numbers Package', () => {
})
})

describe('Test getRandomIn', () => {
it('getRandomIn(1, 5) = 1,2,3,4 or 5', () => {
expect([1, 2, 3, 4, 5]).to.include(numbers.getRandomIn(1, 5))
describe('Test getRandomInRange', () => {
it('getRandomInRange(1, 5) = 1,2,3,4 or 5', () => {
expect([1, 2, 3, 4, 5]).to.include(numbers.getRandomInRange(1, 5))
})

it('getRandomIn(5, 9) = 5,6,7,8 or 9', () => {
expect([5, 6, 7, 8, 9]).to.include(numbers.getRandomIn(5, 9))
it('getRandomInRange(5, 9) = 5,6,7,8 or 9', () => {
expect([5, 6, 7, 8, 9]).to.include(numbers.getRandomInRange(5, 9))
})
})

Expand Down
File renamed without changes.

0 comments on commit 4b6666d

Please sign in to comment.