import { addWithinRange , invMod , invModBigInt , isBetween , lerp1D , Lerp1DOptions , modExp , modExpBigInt , posMod , posModBigInt , } from '@lib/math' ; export interface Range < T = number > { low : T ; high : T ; } declare global { interface Number { param m posMod ( m ) : number ; isBetween ( l , h ) : boolean ; isBetweenRange ( range ) : boolean ; invMod ( n ) : number ; modExp ( b , n ) : number ; lerp ( to , options ? ) : number [ ] ; iterate ( from ? ) : number [ ] ; addWithinRange ( add , fromOrTo ? , to ? ) : number ; } interface BigInt { param m posMod ( m ) : bigint ; isBetween ( l , h ) : boolean ; invMod ( n ) : bigint ; modExp ( b , n ) : bigint ; } interface String { toInt ( radix ? ) : number | undefined ; tryInt ( radix ? ) : number ; } } Number . prototype . addWithinRange = function ( this , add , fromOrTo ? , optionalTo ? ) : number { return addWithinRange ( this , add , fromOrTo , optionalTo ) ; } ; Number . prototype . iterate = function ( this , from = 0 ) : number [ ] { return lerp1D ( from , this , { excludeStart : false , excludeEnd : true } ) ; } ; Number . prototype . lerp = function ( this , to , options ? ) : number [ ] { return lerp1D ( this , to , options ) ; } ; Number . prototype . posMod = function ( this , m ) : number { return posMod ( this , m ) ; } ; BigInt . prototype . posMod = function ( this , m ) : bigint { return posModBigInt ( this , m ) ; } ; Number . prototype . isBetween = function ( this , l , h ) : boolean { return isBetween ( this , l , h ) ; } ; Number . prototype . isBetweenRange = function ( this , range ) : boolean { return isBetween ( this , range . low , range . high ) ; } ; BigInt . prototype . isBetween = function ( this , l , h ) : boolean { return isBetween ( this , l , h ) ; } ; Number . prototype . invMod = function ( this , n ) : number { return invMod ( this , n ) ; } ; BigInt . prototype . invMod = function ( this , n ) : bigint { return invModBigInt ( this , n ) ; } ; Number . prototype . modExp = function ( this , b , n ) : number { return modExp ( this , b , n ) ; } ; BigInt . prototype . modExp = function ( this , b , n ) : bigint { return modExpBigInt ( this , b , n ) ; } ; String . prototype . toInt = function ( this , radix = 10 ) : number | undefined { const result = parseInt ( this , radix ) ; return isNaN ( result ) ? undefined : result ; } ; String . prototype . tryInt = function ( this , radix = 10 ) : number { const result = parseInt ( this , radix ) ; if ( isNaN ( result ) ) { throw new Error ( `Number::tryInt Converting '${ this }' resulted in NaN!` ) ; } return result ; } ;