GithubNPM
Options
All
  • Public
  • Public/Protected
  • All
Menu

The RxJS Ninja Number module contains operators for working with, and returning number values. The operators allow for filtering, querying, converting to and from String, and mathematical operations.

Number Module

References

average:alias of mean

Create Functions

  • fromFibonacci(iterations: number, emitDelay?: number): Observable<number>
  • Returns an Observable that emits a sequence of numbers in the Fibonacci sequence, starting from 0

    example

    Emit the first 5 numbers of the Fibonacci sequence immediately

    fromFibonacci(5).subscribe();
    

    Output: 0, 1, 1, 2, 3

    example

    Emit the first 10 numbers of the Fibonacci sequence once per second, and skip 0

    fromFibonacci(10, 1000).pipe(skip(1)).subscribe();
    

    Output: 1, 1, 2, 3, 5, 8, 13, 21, 34

    Parameters

    • iterations: number

      The number of iterations to do, must be greater than 0

    • emitDelay: number = 0

      If set the observable will emit per millisecond set, by default this is 0

    Returns Observable < number >

    Observable of a Fibonacci sequence of numbers starting from 0

  • fromNumber<T>(input?: Subscribable<Iterable<T> | T> | Iterable<T> | T): Observable<number>
  • Returns an Observable that emits numbers as a type-safe number generator from a source, if no source is passed it will generate an infinite sequence of positive numbers starting from 0

    example

    Return an Observable that emits numbers from an Array and multiply by 2

    fromNumber([1, 2, 3, 4]).pipe(mul(2)).subscribe();
    

    Output: 2, 4, 6, 8

    example

    Returns an Observable of numbers and take the first 1000, and reduce to an array

    fromNumber().pipe(take(1000), reduce((acc, val) => [...acc, val], [])).subscribe();
    

    Output: [0, 1, 2, 3, 4, ...]

    Type parameters

    • T: number

    Parameters

    • Optional input: Subscribable<Iterable<T> | T> | Iterable<T> | T

      Optional number source to emit from

    Returns Observable < number >

    Observable that emits numbers passed from arguments or array

Distribution Functions

  • max(): OperatorFunction<Iterable<number>, number>
  • Returns an Observable that emits the maximum number value from an Iterable of numbers

    example

    Return the max of the source number Array

    const source$ = from([ [1, 2, 3], [10, 15, 8], [5, 10, 100] ]);
    
    source$.pipe(max()).subscribe();
    

    Output: 3, 15, 100

    Returns OperatorFunction < Iterable < number > , number >

    Observable that emits a number that is the maximum value in the source Iterable

  • mean(precision?: Subscribable<number> | number): OperatorFunction<Iterable<number>, number>
  • Returns an Observable that emits the calculated mean number value from an Iterable of numbers

    example

    Return the mean of the source number arrays

    const source$ = from([ [1, 2, 3], [10, 15, 8], [5, 10, 100] ]);
    
    source$.pipe(mean()).subscribe();
    

    Output: 2, 11, 38.333

    Parameters

    • precision: Subscribable<number> | number = 3

      Precision to round the result to, default is 3

    Returns OperatorFunction < Iterable < number > , number >

    Observable that emits a number that is the mean of all values in the source Iterable

  • median(precision?: Subscribable<number> | number): OperatorFunction<Iterable<number>, number>
  • Returns an Observable that emits the median number value from an Iterable of numbers

    example

    Return the median of the source number Array

    const source$ = from([ [1, 2, 3], [10, 15, 8], [5, 10, 100] ]);
    
    source$.pipe(median()).subscribe();
    

    Output: 2, 15, 52.5

    Parameters

    • precision: Subscribable<number> | number = 3

    Returns OperatorFunction < Iterable < number > , number >

    Observable that emits a number that is the median value in the source Iterable

  • min(): OperatorFunction<Iterable<number>, number>
  • Returns an Observable that emits the minimum number value from an Iterable of numbers

    example

    Return the min of the source number Array

    const source$ = from([ [1, 2, 3], [10, 15, 8], [5, 10, 100] ]);
    
    source$.pipe(min()).subscribe();
    

    Output: 1, 8, 5

    Returns OperatorFunction < Iterable < number > , number >

    Observable that emits a number that is the minimum value in the source Iterable

Filter Functions

  • filterInRange(min: Subscribable<number> | number, max: Subscribable<number> | number, excludeBounds?: Subscribable<boolean> | boolean): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits numbers, where that number falls between the provided min and max values.

    remarks

    When filtering in range, the range numbers are included in the filter - to exclude them set excludeBoundingValues = true

    see

    The inRange operator returns a boolean value instead of the number

    see

    The filterOutOfRange can be used to get numbers that fall outside the min and max range

    example

    Return only numbers in and including the range of 0 to 10

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterInRange(0, 10)).subscribe();
    

    Output: 0, 1, 2, 3.4, 4.2, 10

    example

    Return only numbers in the range of 0 to 10 and also filter the min and max

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterInRange(0, 10, true)).subscribe();
    

    Output: 1, 2, 3.14, 4.2

    Parameters

    • min: Subscribable<number> | number

      The minimum range value

    • max: Subscribable<number> | number

      The maximum range value

    • Optional excludeBounds: Subscribable<boolean> | boolean

      Also filter the min and max values from the Observable

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that falls within the passed min and max range

  • filterIsFinite(): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits numbers from a source where they pass the check of Number.isFinite.

    remarks

    Certain operations such as dividing by zero or multiplying passed Number.MAX_VALUE in JavaScript can cause Infinity to be generated, this operator can help avoid those values

    see

    The isFinite operator returns a boolean value instead of the number

    example

    Return only finite values

    const input = [-Infinity, -2.3, 0, 1, Infinity, 3.14, 4.2, 10, 11, Number.MAX_VALUE * 2];
    from(input).pipe(filterIsFinite()).subscribe();
    

    Output: -2.3, 0, 2, 3.14, 4.2, 10, 11

    Returns MonoTypeOperatorFunction < number >

    Observable that emits numbers that are finite

  • filterIsFloat(): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits only valid finite floating point numbers from a source

    see

    The isFloat operator returns a boolean value instead of the number

    example

    Return only values that are floating point numbers

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterIsFloat()).subscribe();
    

    Output: -2.3, 3.14, 4.2

    Returns MonoTypeOperatorFunction < number >

    Observable that emits valid finite floating point numbers

  • filterIsInteger(): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits only integer numbers from a source that pass the check of Number.isInteger.

    see

    The isInteger operator returns a boolean value instead of the number

    example

    Return only values that are integer values

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterIsInteger()).subscribe()
    

    Output: -10, 0, 1, 2, 10, 11, 42

    Returns MonoTypeOperatorFunction < number >

    Observable that emits integer numbers

  • filterIsSafeInteger(): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits numbers that are within the safe number range for JavaScript number precision using Number.isSafeInteger

    see

    The isSafeInteger operator returns a boolean value instead of the number

    example

    Returns only integers within safe precision range

    // `Math.pow(2, 53)` is not within the safe integer range
    const input = [-10, -2.3, 0, 1, 2, 3.14, Math.pow(2, 53) - 1, Math.pow(2, 53), Infinity];
    from(input).pipe(filterIsSafeInteger()).subscribe()
    

    Output: -10, 0, 1, 2, 9007199254740991

    Returns MonoTypeOperatorFunction < number >

    Observable that emits integer numbers within Number.isSafeInteger equality check

  • filterNaN(): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits number values from a source filtering out any NaN values.

    see

    The isNaN and isNotNaN operator returns a boolean value instead of the number

    example

    Returns only valid numbers where the source may contain NaN values

    const input = [NaN, -2.3, 0, NaN, 2, 3.14, 4.2, NaN, 11, 42];
    from(input).pipe(filterNaN()).subscribe()
    

    Output: -2.3, 0, 2, 3.14, 4.2, 11, 42

    Returns MonoTypeOperatorFunction < number >

    Observable that emits valid numbers and excludes NaN values

  • filterOutOfRange(min: Subscribable<number> | number, max: Subscribable<number> | number, includeBounds?: Subscribable<boolean> | boolean): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits numbers, where that number falls outside the provided min and max values.

    remarks

    When filtering out-of-range, the range numbers are excluded from the filter - to include them set includeBounds = true

    see

    The inRange operator returns a boolean value instead of the number

    see

    The filterOutOfRange can be used to get numbers that fall outside the min and max range

    example

    Returns values outside the min and max range

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterOutOfRange(0, 10)).subscribe();
    

    Output: -10, -2.3, 11, 42

    example

    Returns values outside and including the min and max range

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(filterOutOfRange(0, 10, true)).subscribe();
    

    Output: -10, -2.3, 0, 10, 11, 42

    Parameters

    • min: Subscribable<number> | number

      The minimum range value

    • max: Subscribable<number> | number

      The maximum range value

    • Optional includeBounds: Subscribable<boolean> | boolean

      Optionally include the min and max values in the Observable

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that falls outside the min and max ranges

Formatting Functions

  • toExponential(exponential: Subscribable<number> | number): OperatorFunction<number, string>
  • Returns an Observable that emits a formatted string of a number raised to an exponential power using Number.toExponential

    example

    Return a string passed numbers to the exponential of 2

    const input = [-1, 0, 1, 2, 3.4];
    from(input).pipe(toExponential(2)).subscribe();
    

    Output: '-1.00e+0', '0.00e+0', '1.00e+0', '2.30e+0', '3.14e+0'

    Parameters

    • exponential: Subscribable<number> | number

      The exponential value to raise the number by

    Returns OperatorFunction < number , string >

    Observable that emits a formatted string of the exponential number

  • toFixed(digits?: Subscribable<number> | number): OperatorFunction<number, string>
  • Returns an Observable that emits a formatted string value from a source number using Number.toFixed

    example

    Return a string of a number to fixed position of 2

    const input = [1.8372, 2.12353, 3.14, 42.2];
    from(input).pipe(toFixed(2)).subscribe();
    

    Output: '1.834', '2.12', '3.14', '42.20'

    Parameters

    • Optional digits: Subscribable<number> | number

      Optional number of digits to fix to, if not passed treated as 0

    Returns OperatorFunction < number , string >

    Observable that emits a formatted string from a source number to a fixed decimal value

  • toHex(): OperatorFunction<number, string>
  • Returns an Observable that emits a string that is the hex value of a source number

    example

    Return a hex value of source number

    const input = [2, 16, 32, 75, 255];
    from(input).pipe(toHex()).subscribe();
    

    Output: '2', '10', '20', '4b', 'ff'

    Returns OperatorFunction < number , string >

    Observable that emits the hex value of a source number

  • toLocaleString(locales?: Subscribable<string | string[]> | string | string[], format?: Subscribable<Intl.NumberFormatOptions> | Intl.NumberFormatOptions): OperatorFunction<number, string>
  • Returns an Observable that emits a formatted string value from a source number using Number.toLocaleString with optional formatting options provided by Intl.NumberFormat

    example

    Return a string with Dutch number formatting

    of(1000000).pipe(toLocaleString('nl-NL')).subscribe();
    

    Output: '1.000.000'

    example

    Return a string with UK English number formatting

    of(1000000).pipe(toLocaleString('en-GB')).subscribe();
    

    Output: '1,000,000'

    example

    Return a string with UK English number formatting and Euro currency style

    of(1000000).pipe(toLocaleString('en-GB', { currency: 'EUR', style: 'currency' })).subscribe();
    

    Output: '€1,000,000.00'

    Parameters

    • Optional locales: Subscribable<string | string[]> | string | string[]

      The locale or locales that the number is being formatted for

    • Optional format: Subscribable<Intl.NumberFormatOptions> | Intl.NumberFormatOptions

      Formatting of the string based on Intl.NumberFormat

    Returns OperatorFunction < number , string >

    Observable that emits a formatted string from a source number

  • toPrecision(precision: Subscribable<number> | number): OperatorFunction<number, string>
  • Returns an Observable that emits a formatted string value from a source number using Number.toPrecision.

    example

    Return a string of numbers formatted to a precision of 4 places

    const input = [123.456, 0.004, 1.23e5];
    from(input).pipe(toPrecision(4)).subscribe();
    

    Output: '123.5', '0.004000', '1.230e+5'

    Parameters

    • precision: Subscribable<number> | number

      The number of decimal places to format the precision to.

    Returns OperatorFunction < number , string >

    Observable that emits a formatted string from a source number

  • toString(radix?: Subscribable<number> | number): OperatorFunction<number, string>
  • Returns an Observable that emits a formatted string value from a source number using Number.toString

    example

    Return string values of numbers using base 10 conversion

    const input = [1, 2, 3.14, 42];
    from(input).pipe(toString()).subscribe();
    

    Output: '1', '2', '3.14', '42'

    example

    Return string values of numbers using base 16 conversion

    const input = [8, 16, 32, 64];
    from(input).pipe(toString(16)).subscribe();
    

    Output: '8', '10', '20', '40'

    Parameters

    • radix: Subscribable<number> | number = 10

      The base number to format to. Default is 10.

    Returns OperatorFunction < number , string >

    Observable that emits a formatted string from a source number and passed radix value

Math Functions

  • add(num: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number that is the addition of the source number with input number

    example

    Returns a number that is the addition of source and input

    const input = [2, 3, 4, 5, 6];
    from(input).pipe(add(3)).subscribe();
    

    Output: 5, 6, 7, 8, 9

    Parameters

    • num: Subscribable<number> | number

      The number to add to the source value

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is the addition of source and input

  • div(num: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number that is the division of the source number with input number

    remarks

    If the input value is 0 this operator will throw an error

    example

    Returns a number that is the division of source and input

    const input = [4, 10, 12, 18, 20];
    from(input).pipe(div(2)).subscribe();
    

    Output: 2, 5, 6, 9, 10

    Parameters

    • num: Subscribable<number> | number

      The number to divide to the source value

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is the division of source and input

  • mod(modulus: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number that is the remainder of the Modulo operation of the source number by the divider

    example

    Return the remainder of modulus 3

    const input = [2, 3, 4, 5, 6];
    from(input).pipe(mod(3)).subscribe();
    

    Output: 2, 0, 1, 2, 0

    Parameters

    • modulus: Subscribable<number> | number

      The dividing number for the Modulo operation

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is reminder of a Modulo operation

  • mul(num: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number that is the multiplication of the source number with input number

    example

    Returns a number that is the multiplication of source and input

    const input = [2, 3, 4, 5, 6];
    from(input).pipe(mul(2)).subscribe();
    

    Output: 4, 6, 8, 10, 12

    Parameters

    • num: Subscribable<number> | number

      The number to multiply to the source value

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is the multiplication of source and input

  • pow(power: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number from a source number that is raised by the passed power using the exponentiation operator **

    example

    Return values raised to the power 2

    const input = [2, 4, 10, 16, 256];
    from(input).pipe(pow(2)).subscribe();
    

    Output: 4, 25, 100, 256, 655356

    Parameters

    • power: Subscribable<number> | number

      The number to raise the value by

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is the raised source value by the power

  • roundTo(precision: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number value rounded to the number of digits passed

    example

    Return a number to fixed position of 2

    const input = [1.8372, 2.12353, 3.14, 42.2];
    from(input).pipe(roundTo(2)).subscribe();
    

    Output: 1.84, 2.12, 3.14, 42.2

    Parameters

    • precision: Subscribable<number> | number

      Maximum number of digits to round the number to

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number number to a fixed decimal value

  • sub(num: Subscribable<number> | number): MonoTypeOperatorFunction<number>
  • Returns an Observable that emits a number that is the subtraction of the source number with input number

    example

    Returns a number that is the subtract of source and input

    const input = [2, 3, 4, 5, 6];
    from(input).pipe(sub(3)).subscribe();
    

    Output: -1, 0, 1, 2, 3

    Parameters

    • num: Subscribable<number> | number

      The number to subtract to the source value

    Returns MonoTypeOperatorFunction < number >

    Observable that emits a number that is the subtraction of source and input

Parse Functions

  • parseFloat(): OperatorFunction<string, number>
  • Returns an Observable that emits a number from a source string using Number.parseFloat.

    example

    Return only parsed number values using base 10

    const input = ['RxJS', '-2.3', '0', '1', '2', '3.14', 'Infinity'];
    from(input).pipe(parseFloat()).subscribe();
    

    Output: -2.3, 0, 1, 2, 3.14

    Returns OperatorFunction < string , number >

    Observable that emits a number from source parsed string

  • parseHex(): OperatorFunction<string, number>
  • Returns an Observable that emits a number from a source hex using Number.parseInt.

    example

    Return only parsed hex values

    const input = ['RxJS', 'ff', '00', '1b', '23', 'c89bb'];
    from(input).pipe(parseHex()).subscribe();
    

    Output: 255, 0, 27, 25, 821691

    Returns OperatorFunction < string , number >

    Observable that emits a number from source hex value

  • parseInt(radix?: Subscribable<number> | number): OperatorFunction<string, number>
  • Returns an Observable that emits a number from a source string using Number.parseInt.

    example

    Return only parsed integer values using base 10

    const input = ['RxJS', '-2.3', '0', '1', '2', '3.14', 'Infinity'];
    from(input).pipe(parseInt()).subscribe();
    

    Output: -2, 0, 1, 2, 3

    example

    Return parsed integer values using base 16

    const input = ['1', 'ff', '40'];
    from(input).pipe(parseInt(16)).subscribe();
    

    Output: 1, 255, 64

    Parameters

    • radix: Subscribable<number> | number = 10

      The number base to convert from. Default is base 10

    Returns OperatorFunction < string , number >

    Observable that emits a number from source parsed string, optionally returns NaN values

Query Functions

  • inRange(min: Subscribable<number> | number, max: Subscribable<number> | number, excludeBounds?: Subscribable<boolean> | boolean): OperatorFunction<number, boolean>
  • Returns an Observable that emits booleans about values from a source that fall within the passed min and max range, including the range numbers.

    remarks

    When querying in range, the range numbers are included in the query - to exclude them set excludeBoundingValues = true

    see

    The filterInRange operator returns the number value

    example

    Returns a boolean value if the number is in the range

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(inRange(0, 10)).subscribe();
    

    Output: false, false, true, true, true, true, true, true, false, false

    example

    Returns a boolean value if the number is in the range excluding the min and max

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(inRange(0, 10, true)).subscribe();
    

    Output: false, false, false, true, true, true, true, false, false, false

    Parameters

    • min: Subscribable<number> | number

      The minimum number for the range

    • max: Subscribable<number> | number

      The maximum number for the range

    • Optional excludeBounds: Subscribable<boolean> | boolean

      Optionally filter the min and max values from the Observable

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean if the source number falls within the passed min and max range

  • isFinite(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number is a finite number using Number.isFinite

    see

    The filterIsFinite operator returns the number value

    example

    Return boolean for finite values

    const input = [-Infinity, -2.3, 0, 1, Infinity, 3.14, 4.2, 10, 11, Number.MAX_VALUE * 2];
    from(input).pipe(isFinite()).subscribe();
    

    Output: false, true, true, true, false, true, true, true, true, false

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean of a source number being finite

  • isFloat(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number is a a valid finite floating point number

    see

    The filterIsFloat operator returns the number value

    example

    Return boolean for floating point numbers

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(isFloat()).subscribe();
    

    Output: false, true, false, false, false, true, true, false, false, false

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean of a source number is a valid finite floating point

  • isInteger(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number is an integer checked with Number.isInteger

    see

    The filterIsInteger operator returns the number value

    example

    Return booleans for values that are integer values

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(isInteger()).subscribe()
    

    Output: true, false, true, true, true, false, false, true, true, true

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean of a source number being an integer

  • isMod(modulus: Subscribable<number> | number): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean is the source number has no remainder from the passed modulus

    example

    Return if the source value has no remainder for modulus 3

    const input = [2, 3, 4, 5, 6];
    from(input).pipe(isMod(3)).subscribe();
    

    Output: false, true, false, false, true

    Parameters

    • modulus: Subscribable<number> | number

      The dividing number for the Modulo operation

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean is the source number has no remainder

  • isNaN(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number is a NaN value from Number.isNaN.

    see

    The filterNaN operator returns numbers excluding NaN values

    example

    Return a boolean if a number is a NaN value

    const input = ['Ninja', 1, 2, NaN, 3.14, undefined];
    from(input).pipe(isNaN()).subscribe();
    

    Output: true, false, false, true, false, true

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean value of a number being valid or NaN

  • isNotNaN(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number is valid and not NaN, checked using Number.isNaN

    remarks

    This is mostly for convenience of getting truthy values that are valid for numbers without flipping the value os isNaN

    see

    The filterNaN operator returns numbers excluding NaN values

    example

    Return a boolean if a number is not NaN value

    const input = ['Ninja', 1, 2, NaN, 3.14, undefined];
    from(input).pipe(isNotNaN()).subscribe();
    

    Output: false, true, true, false, true, false

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean value of a number being valid or NaN

  • isSafeInteger(): OperatorFunction<number, boolean>
  • Returns an Observable that emits a boolean value when a source number has precision safety using Number.isSafeInteger

    see

    The filterIsSafeInteger operator returns the number value

    example

    Return a boolean if a number does not have percision safety

    // `Math.pow(2, 53)` is not within the safe integer range
    const input = [-10, -2.3, 0, 1, 2, 3.14, Math.pow(2, 53) - 1, Math.pow(2, 53), Infinity];
    from(input).pipe(isSafeInteger()).subscribe()
    

    Output: true, false, true, true, true, false, true, false, false

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean value of a number has precision safety

  • outOfRange(min: Subscribable<number> | number, max: Subscribable<number> | number, includeBounds?: Subscribable<boolean> | boolean): OperatorFunction<number, boolean>
  • Returns an Observable that emits booleans about values from a source that fall outside the passed min and max range, excluding the range numbers.

    remarks

    When querying out-of-range, the range numbers are querying from the filter - to include them set includeBounds = true

    see

    To get numbers outside of a range use filterOutOfRange

    example

    Returns a boolean value if the number is out the range including the min and max

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(outOfRange(0, 10)).subscribe();
    

    Output: true, true, true, false, false, false, false, true, true, true

    example

    Returns a boolean value if the number is out the range excluding the min and max

    const input = [-10, -2.3, 0, 1, 2, 3.14, 4.2, 10, 11, 42];
    from(input).pipe(outOfRange(0, 10, true)).subscribe();
    

    Output: true, true, false, false, false, false, false, false, true, true

    Parameters

    • min: Subscribable<number> | number

      The minimum number for the range

    • max: Subscribable<number> | number

      The maximum number for the range

    • Optional includeBounds: Subscribable<boolean> | boolean

      Optionally include the min and max values in the Observable

    Returns OperatorFunction < number , boolean >

    Observable that emits a boolean if the source number falls outside the passed min and max range

Generated using TypeDoc, the 08/02/2021 at 13:47:36