@naturalcycles/js-lib
Advanced tools
Comparing version 14.193.0 to 14.194.0
@@ -26,10 +26,20 @@ export function _randomInt(minIncl, maxIncl) { | ||
/** | ||
* _inRange(-10, 1, 5) // false | ||
* _inRange(1, 1, 5) // true | ||
* _inRange(3, 1, 5) // true | ||
* _inRange(5, 1, 5) // false | ||
* _inRange(7, 1, 5) // false | ||
* _isBetween(-10, 1, 5) // false | ||
* _isBetween(1, 1, 5) // true | ||
* _isBetween(3, 1, 5) // true | ||
* _isBetween(5, 1, 5) // false | ||
* _isBetween(7, 1, 5) // false | ||
*/ | ||
export function _inRange(x, minIncl, maxExcl) { | ||
return x >= minIncl && x < maxExcl; | ||
export function _isBetween(x, min, max, incl = '[)') { | ||
if (incl === '[)') { | ||
return x >= min && x < max; | ||
} | ||
else if (incl === '[]') { | ||
return x >= min && x <= max; | ||
} | ||
else if (incl === '(]') { | ||
return x > min && x <= max; | ||
} | ||
// () | ||
return x > min && x < max; | ||
} | ||
@@ -36,0 +46,0 @@ export function _clamp(x, minIncl, maxIncl) { |
@@ -1,2 +0,3 @@ | ||
import type { Inclusiveness, LocalDateInput, LocalDateUnit } from './localDate'; | ||
import { Inclusiveness } from '../types'; | ||
import type { LocalDateInput, LocalDateUnit } from './localDate'; | ||
import { LocalDate } from './localDate'; | ||
@@ -3,0 +4,0 @@ export type DateIntervalConfig = DateInterval | DateIntervalString; |
import { Iterable2 } from '../iter/iterable2'; | ||
import type { IsoDateString, IsoDateTimeString, MonthId, SortDirection, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types'; | ||
import type { Inclusiveness, IsoDateString, IsoDateTimeString, MonthId, SortDirection, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types'; | ||
import { LocalTime } from './localTime'; | ||
export type LocalDateUnit = LocalDateUnitStrict | 'week'; | ||
export type LocalDateUnitStrict = 'year' | 'month' | 'day'; | ||
export type Inclusiveness = '()' | '[]' | '[)' | '(]'; | ||
export type LocalDateInput = LocalDate | Date | IsoDateString; | ||
@@ -8,0 +7,0 @@ export type LocalDateFormatter = (ld: LocalDate) => string; |
@@ -1,3 +0,2 @@ | ||
import type { IsoDateString, IsoDateTimeString, MonthId, SortDirection, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types'; | ||
import type { Inclusiveness } from './localDate'; | ||
import type { Inclusiveness, IsoDateString, IsoDateTimeString, MonthId, SortDirection, UnixTimestampMillisNumber, UnixTimestampNumber } from '../types'; | ||
import { LocalDate } from './localDate'; | ||
@@ -4,0 +3,0 @@ export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second'; |
@@ -1,3 +0,2 @@ | ||
import type { UnixTimestampNumber } from '../types'; | ||
import type { Inclusiveness } from './localDate'; | ||
import type { UnixTimestampNumber, Inclusiveness } from '../types'; | ||
import type { LocalTimeInput } from './localTime'; | ||
@@ -4,0 +3,0 @@ import { LocalTime } from './localTime'; |
@@ -1,2 +0,2 @@ | ||
import { SortDirection } from '../types'; | ||
import type { Inclusiveness, SortDirection } from '../types'; | ||
export declare function _randomInt(minIncl: number, maxIncl: number): number; | ||
@@ -20,9 +20,9 @@ /** | ||
/** | ||
* _inRange(-10, 1, 5) // false | ||
* _inRange(1, 1, 5) // true | ||
* _inRange(3, 1, 5) // true | ||
* _inRange(5, 1, 5) // false | ||
* _inRange(7, 1, 5) // false | ||
* _isBetween(-10, 1, 5) // false | ||
* _isBetween(1, 1, 5) // true | ||
* _isBetween(3, 1, 5) // true | ||
* _isBetween(5, 1, 5) // false | ||
* _isBetween(7, 1, 5) // false | ||
*/ | ||
export declare function _inRange(x: number, minIncl: number, maxExcl: number): boolean; | ||
export declare function _isBetween(x: number, min: number, max: number, incl?: Inclusiveness): boolean; | ||
export declare function _clamp(x: number, minIncl: number, maxIncl: number): number; | ||
@@ -29,0 +29,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._clamp = exports._inRange = exports._runLessOften = exports._randomArrayItem = exports._randomInt = void 0; | ||
exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._clamp = exports._isBetween = exports._runLessOften = exports._randomArrayItem = exports._randomInt = void 0; | ||
function _randomInt(minIncl, maxIncl) { | ||
@@ -32,12 +32,22 @@ return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl); | ||
/** | ||
* _inRange(-10, 1, 5) // false | ||
* _inRange(1, 1, 5) // true | ||
* _inRange(3, 1, 5) // true | ||
* _inRange(5, 1, 5) // false | ||
* _inRange(7, 1, 5) // false | ||
* _isBetween(-10, 1, 5) // false | ||
* _isBetween(1, 1, 5) // true | ||
* _isBetween(3, 1, 5) // true | ||
* _isBetween(5, 1, 5) // false | ||
* _isBetween(7, 1, 5) // false | ||
*/ | ||
function _inRange(x, minIncl, maxExcl) { | ||
return x >= minIncl && x < maxExcl; | ||
function _isBetween(x, min, max, incl = '[)') { | ||
if (incl === '[)') { | ||
return x >= min && x < max; | ||
} | ||
else if (incl === '[]') { | ||
return x >= min && x <= max; | ||
} | ||
else if (incl === '(]') { | ||
return x > min && x <= max; | ||
} | ||
// () | ||
return x > min && x < max; | ||
} | ||
exports._inRange = _inRange; | ||
exports._isBetween = _isBetween; | ||
function _clamp(x, minIncl, maxIncl) { | ||
@@ -44,0 +54,0 @@ return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x; |
@@ -246,1 +246,2 @@ import type { Promisable } from './typeFest'; | ||
export type SortDirection = 'asc' | 'desc'; | ||
export type Inclusiveness = '()' | '[]' | '[)' | '(]'; |
{ | ||
"name": "@naturalcycles/js-lib", | ||
"version": "14.193.0", | ||
"version": "14.194.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "prepare": "husky install", |
@@ -1,2 +0,3 @@ | ||
import type { Inclusiveness, LocalDateInput, LocalDateUnit } from './localDate' | ||
import { Inclusiveness } from '../types' | ||
import type { LocalDateInput, LocalDateUnit } from './localDate' | ||
import { LocalDate, localDateRange } from './localDate' | ||
@@ -3,0 +4,0 @@ |
import { _assert } from '../error/assert' | ||
import { Iterable2 } from '../iter/iterable2' | ||
import type { | ||
Inclusiveness, | ||
IsoDateString, | ||
@@ -15,3 +16,2 @@ IsoDateTimeString, | ||
export type LocalDateUnitStrict = 'year' | 'month' | 'day' | ||
export type Inclusiveness = '()' | '[]' | '[)' | '(]' | ||
@@ -18,0 +18,0 @@ const MDAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] |
import { _assert } from '../error/assert' | ||
import { _ms } from '../time/time.util' | ||
import type { | ||
Inclusiveness, | ||
IsoDateString, | ||
@@ -11,3 +12,2 @@ IsoDateTimeString, | ||
} from '../types' | ||
import type { Inclusiveness } from './localDate' | ||
import { LocalDate } from './localDate' | ||
@@ -14,0 +14,0 @@ |
@@ -1,3 +0,2 @@ | ||
import type { UnixTimestampNumber } from '../types' | ||
import type { Inclusiveness } from './localDate' | ||
import type { UnixTimestampNumber, Inclusiveness } from '../types' | ||
import type { LocalTimeInput } from './localTime' | ||
@@ -4,0 +3,0 @@ import { LocalTime } from './localTime' |
@@ -1,2 +0,2 @@ | ||
import { SortDirection } from '../types' | ||
import type { Inclusiveness, SortDirection } from '../types' | ||
@@ -32,10 +32,23 @@ export function _randomInt(minIncl: number, maxIncl: number): number { | ||
/** | ||
* _inRange(-10, 1, 5) // false | ||
* _inRange(1, 1, 5) // true | ||
* _inRange(3, 1, 5) // true | ||
* _inRange(5, 1, 5) // false | ||
* _inRange(7, 1, 5) // false | ||
* _isBetween(-10, 1, 5) // false | ||
* _isBetween(1, 1, 5) // true | ||
* _isBetween(3, 1, 5) // true | ||
* _isBetween(5, 1, 5) // false | ||
* _isBetween(7, 1, 5) // false | ||
*/ | ||
export function _inRange(x: number, minIncl: number, maxExcl: number): boolean { | ||
return x >= minIncl && x < maxExcl | ||
export function _isBetween( | ||
x: number, | ||
min: number, | ||
max: number, | ||
incl: Inclusiveness = '[)', | ||
): boolean { | ||
if (incl === '[)') { | ||
return x >= min && x < max | ||
} else if (incl === '[]') { | ||
return x >= min && x <= max | ||
} else if (incl === '(]') { | ||
return x > min && x <= max | ||
} | ||
// () | ||
return x > min && x < max | ||
} | ||
@@ -42,0 +55,0 @@ |
@@ -329,1 +329,3 @@ import type { Promisable } from './typeFest' | ||
export type SortDirection = 'asc' | 'desc' | ||
export type Inclusiveness = '()' | '[]' | '[)' | '(]' |
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
958972
28765