@naturalcycles/js-lib
Advanced tools
Comparing version 14.192.1 to 14.193.0
@@ -12,2 +12,14 @@ export function _randomInt(minIncl, maxIncl) { | ||
} | ||
/** | ||
* Convenience function to "throttle" some code - run it less often. | ||
* | ||
* @example | ||
* | ||
* if (_runLessOften(10)) { | ||
* // this code will run only 10% of the time | ||
* } | ||
*/ | ||
export function _runLessOften(percent) { | ||
return Math.random() * 100 < percent; | ||
} | ||
// todo: _.random to support floats | ||
@@ -14,0 +26,0 @@ /** |
@@ -10,2 +10,12 @@ import { SortDirection } from '../types'; | ||
/** | ||
* Convenience function to "throttle" some code - run it less often. | ||
* | ||
* @example | ||
* | ||
* if (_runLessOften(10)) { | ||
* // this code will run only 10% of the time | ||
* } | ||
*/ | ||
export declare function _runLessOften(percent: number): boolean; | ||
/** | ||
* _inRange(-10, 1, 5) // false | ||
@@ -12,0 +22,0 @@ * _inRange(1, 1, 5) // true |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._clamp = exports._inRange = exports._randomArrayItem = exports._randomInt = void 0; | ||
exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._clamp = exports._inRange = exports._runLessOften = exports._randomArrayItem = exports._randomInt = void 0; | ||
function _randomInt(minIncl, maxIncl) { | ||
@@ -17,2 +17,15 @@ return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl); | ||
exports._randomArrayItem = _randomArrayItem; | ||
/** | ||
* Convenience function to "throttle" some code - run it less often. | ||
* | ||
* @example | ||
* | ||
* if (_runLessOften(10)) { | ||
* // this code will run only 10% of the time | ||
* } | ||
*/ | ||
function _runLessOften(percent) { | ||
return Math.random() * 100 < percent; | ||
} | ||
exports._runLessOften = _runLessOften; | ||
// todo: _.random to support floats | ||
@@ -19,0 +32,0 @@ /** |
{ | ||
"name": "@naturalcycles/js-lib", | ||
"version": "14.192.1", | ||
"version": "14.193.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "prepare": "husky install", |
@@ -16,2 +16,15 @@ import { SortDirection } from '../types' | ||
/** | ||
* Convenience function to "throttle" some code - run it less often. | ||
* | ||
* @example | ||
* | ||
* if (_runLessOften(10)) { | ||
* // this code will run only 10% of the time | ||
* } | ||
*/ | ||
export function _runLessOften(percent: number): boolean { | ||
return Math.random() * 100 < percent | ||
} | ||
// todo: _.random to support floats | ||
@@ -18,0 +31,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
958267
28732