Permalink
Cannot retrieve contributors at this time
21 lines (21 sloc)
924 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@azure/core-util/dist-esm/src/random.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) Microsoft Corporation. | |
// Licensed under the MIT license. | |
/** | |
* Returns a random integer value between a lower and upper bound, | |
* inclusive of both bounds. | |
* Note that this uses Math.random and isn't secure. If you need to use | |
* this for any kind of security purpose, find a better source of random. | |
* @param min - The smallest integer value allowed. | |
* @param max - The largest integer value allowed. | |
*/ | |
export function getRandomIntegerInclusive(min, max) { | |
// Make sure inputs are integers. | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
// Pick a random offset from zero to the size of the range. | |
// Since Math.random() can never return 1, we have to make the range one larger | |
// in order to be inclusive of the maximum value after we take the floor. | |
const offset = Math.floor(Math.random() * (max - min + 1)); | |
return offset + min; | |
} | |
//# sourceMappingURL=random.js.map |