diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3b359..f188e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/numbers/README.md b/packages/numbers/README.md index c61cc97..1aea59f 100644 --- a/packages/numbers/README.md +++ b/packages/numbers/README.md @@ -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) @@ -118,7 +118,7 @@ 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) @@ -126,16 +126,16 @@ getDiff(1, 2) 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 ``` diff --git a/packages/numbers/index.js b/packages/numbers/index.js index b51b0df..88a69f7 100644 --- a/packages/numbers/index.js +++ b/packages/numbers/index.js @@ -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') @@ -15,7 +15,7 @@ module.exports = { addTrailingZeros, getAverage, getDiff, - getRandomIn, + getRandomInRange, getSum, isEven, roundTo, diff --git a/test/test.js b/test/test.js index ebdbf79..f355039 100644 --- a/test/test.js +++ b/test/test.js @@ -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)) }) }) diff --git a/utils/numbers/getRandomIn.js b/utils/numbers/getRandomInRange.js similarity index 100% rename from utils/numbers/getRandomIn.js rename to utils/numbers/getRandomInRange.js