Options
All
  • Public
  • Public/Protected
  • All
Menu

funtil

Index

Functions Function

Functions List

Functions List ```typescript F.includes("pranshu",["pranshu","mit","saumya"]) // true F.includes({id:1,name:"pranshu"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // true F.includes({id:1,name:"saumya"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // false ```

Functions Logic

Functions Math

Functions Object

Functions Other

Function Functions

F

  • F(): false
  • description

    always returns false when you call this function.

    Returns false

T

  • T(x?: any): true
  • description

    always returns true.

    example
    F.T(33) // true
    F.T() // true

    Parameters

    • Optional x: any

    Returns true

always

  • always<T>(x: T): () => T
  • description

    takes an element returns function that always returns element we pass.

    example
    let todo = {id:1,task:"going to school"}
    let todo1 = F.always(todo)();
    todo === todo1 // true

    Type parameters

    • T

    Parameters

    • x: T

    Returns () => T

      • (): T
      • Returns T

binary

  • binary<T1, T2, R>(fn: (arg1: T1, arg: T2, ...args: any[]) => R): (arg1: T1, arg: T2) => R
  • description

    takes a function and returns the function that takes only first two argument of that function and calls that function

    example
    function triplets(a:number,b:number,c?:number)(){
    return [a,b,c];
    }
    let twins = F.binary(triplets);
    twins(3,4) // [3,4,undefined]

    Type parameters

    • T1

    • T2

    • R

    Parameters

    • fn: (arg1: T1, arg: T2, ...args: any[]) => R
        • (arg1: T1, arg: T2, ...args: any[]): R
        • Parameters

          • arg1: T1
          • arg: T2
          • Rest ...args: any[]

          Returns R

    Returns (arg1: T1, arg: T2) => R

      • (arg1: T1, arg: T2): R
      • Parameters

        • arg1: T1
        • arg: T2

        Returns R

clone

  • clone<T>(x: T): T
  • description

    takes and element and copies that element and returns it. for reference types it deepcopies the element.

    example
    let item = {id:1,person:{name:"pranshu"}}
    let cloned = F.clone(item);
    cloned === item // false;
    item.person === item.person // false;

    Type parameters

    • T

    Parameters

    • x: T

    Returns T

compose

  • compose<V, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T6
  • compose<V, T1>(fn0: (...args: V) => T1): (...args: V) => T1
  • compose<V, T1, T2>(fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T2
  • compose<V, T1, T2, T3>(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T3
  • compose<V, T1, T2, T3, T4>(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T4
  • compose<V, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T5
  • description

    takes upto 6 functions as argument and returns the function that will take arguments of right-most function and it will call functions right-left.every functions except right most function should have only one parameter.

    example
    function upper(x: string) {
    return x.toUpperCase();
    }
    const greeting = (first: string, last: string) => first + last;
    F.compose(upper,greeting)("pranshu","shah") //PRANSHUSHAH

    Type parameters

    • V: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • fn5: (x: T5) => T6
        • (x: T5): T6
        • Parameters

          • x: T5

          Returns T6

    • fn4: (x: T4) => T5
        • (x: T4): T5
        • Parameters

          • x: T4

          Returns T5

    • fn3: (x: T3) => T4
        • (x: T3): T4
        • Parameters

          • x: T3

          Returns T4

    • fn2: (x: T2) => T3
        • (x: T2): T3
        • Parameters

          • x: T2

          Returns T3

    • fn1: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T6

      • (...args: V): T6
      • Parameters

        • Rest ...args: V

        Returns T6

  • Type parameters

    • V: any[]

    • T1

    Parameters

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T1

      • (...args: V): T1
      • Parameters

        • Rest ...args: V

        Returns T1

  • Type parameters

    • V: any[]

    • T1

    • T2

    Parameters

    • fn1: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T2

      • (...args: V): T2
      • Parameters

        • Rest ...args: V

        Returns T2

  • Type parameters

    • V: any[]

    • T1

    • T2

    • T3

    Parameters

    • fn2: (x: T2) => T3
        • (x: T2): T3
        • Parameters

          • x: T2

          Returns T3

    • fn1: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T3

      • (...args: V): T3
      • Parameters

        • Rest ...args: V

        Returns T3

  • Type parameters

    • V: any[]

    • T1

    • T2

    • T3

    • T4

    Parameters

    • fn3: (x: T3) => T4
        • (x: T3): T4
        • Parameters

          • x: T3

          Returns T4

    • fn2: (x: T2) => T3
        • (x: T2): T3
        • Parameters

          • x: T2

          Returns T3

    • fn1: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T4

      • (...args: V): T4
      • Parameters

        • Rest ...args: V

        Returns T4

  • Type parameters

    • V: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • fn4: (x: T4) => T5
        • (x: T4): T5
        • Parameters

          • x: T4

          Returns T5

    • fn3: (x: T3) => T4
        • (x: T3): T4
        • Parameters

          • x: T3

          Returns T4

    • fn2: (x: T2) => T3
        • (x: T2): T3
        • Parameters

          • x: T2

          Returns T3

    • fn1: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • fn0: (...args: V) => T1
        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    Returns (...args: V) => T5

      • (...args: V): T5
      • Parameters

        • Rest ...args: V

        Returns T5

constant

  • constant<T>(v: T): () => T
  • alias

    always

    description

    takes an element returns function that always returns element we pass.

    example
    let todo = {id:1,task:"todo1"};
    constantTodo = constant(todo);
    constantTodo(todo) === todo // true;

    Type parameters

    • T

    Parameters

    • v: T

    Returns () => T

      • (): T
      • Returns T

curry

  • curry<Fn>(fn: Fn, arity?: number): F.Curry<Fn>
  • description

    flexible curry function that can take multiple arguments at time.

    example
    function multiplyThreeNumbers(a:number,b:number,c:number){
    return a * b * c;
    }
    let curriedMultiply = F.curry(multiplyThreeNumbers);
    let a = curriedMultiply(3,4);
    a(2) // 24

    Type parameters

    • Fn: Function<any, any, Fn>

    Parameters

    • fn: Fn

      function you want to curried.

    • arity: number = ...

      number of arguments it will take

    Returns F.Curry<Fn>

curry_strict

  • curry_strict<P, R>(fn: (...args: P) => R, arity?: number): StrictCurry<P, R>
  • description

    haskell style curried function that will take one argument at time

    example
    function multiplyThreeNumbers(a:number,b:number,c:number){
    return a * b * c;
    }
    let curriedMultiply = F.strict_curry(multiplyThreeNumbers);
    let a = curriedMultiply(3);
    let b = a(2)
    b(4) // 24

    Type parameters

    • P: any[]

    • R

    Parameters

    • fn: (...args: P) => R

      function you want to curried.

        • (...args: P): R
        • Parameters

          • Rest ...args: P

          Returns R

    • arity: number = ...

      number of arguments it will take

    Returns StrictCurry<P, R>

debounce

  • debounce<F>(fn: F, wait: number, immediate?: boolean): (...args: Parameters<F>) => void
  • description

    Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.

    example
    input.addEventListener("keyup",F.debounce(){
    fetch("getSuggestions");
    })

    Type parameters

    • F: (...args: any[]) => any

    Parameters

    • fn: F

      function you want to debounce

    • wait: number

      elapsed time

    • immediate: boolean = false

      if immediate is true it invokes at leading end otherwise it invokes at trailing end.for more info please check out this link.

    Returns (...args: Parameters<F>) => void

      • (...args: Parameters<F>): void
      • Parameters

        • Rest ...args: Parameters<F>

        Returns void

default_to

  • default_to<T1, T2>(default_val: T1, check_val: T2): T1 | T2
  • default_to<T1, T2>(default_val: T1): (check_val: T2) => T1 | T2
  • description

    it takes default_val and value you want to check and returns value you wanted to check if that value if not undefined , null or NaN otherwise it returns default_val

    example
    F.default_to("pranshu","mit") // mit
    let defaultToPrasnshu = F.default_to("pranshu");
    defaultToPranshu(null) // "pranshu"
    defaultToPranshu("zoom") // "zoom"

    Type parameters

    • T1

    • T2

    Parameters

    • default_val: T1
    • check_val: T2

    Returns T1 | T2

    default value if check value is null,undefined or NaN

  • Type parameters

    • T1

    • T2

    Parameters

    • default_val: T1

    Returns (check_val: T2) => T1 | T2

      • (check_val: T2): T1 | T2
      • Parameters

        • check_val: T2

        Returns T1 | T2

delay

  • delay<T>(fn: T, time: number): (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>
  • delay<T>(fn: T): (time: number) => (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>
  • description

    invokes the given function after given time,also works with parital form.

    example
    function greet(name){
    alert(`Welcome ${name}!`)
    }
    delayedGreet = F.delay(greet,200)
    delayedGreet("pranshu")

    Type parameters

    • T: (...args: any[]) => any

    Parameters

    • fn: T
    • time: number

    Returns (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>

    function that exectues passed function after given time.

      • (...args: OvarloadedParameters<T>): OverloadedReturnType<T>
      • Parameters

        • Rest ...args: OvarloadedParameters<T>

        Returns OverloadedReturnType<T>

        function that exectues passed function after given time.

  • Type parameters

    • T: (...args: any[]) => any

    Parameters

    • fn: T

    Returns (time: number) => (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>

      • (time: number): (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>
      • Parameters

        • time: number

        Returns (...args: OvarloadedParameters<T>) => OverloadedReturnType<T>

          • (...args: OvarloadedParameters<T>): OverloadedReturnType<T>
          • Parameters

            • Rest ...args: OvarloadedParameters<T>

            Returns OverloadedReturnType<T>

either

  • either<T>(fn1: Pred<T>, fn2: Pred<T>): (...args: T) => boolean
  • either<T>(fn1: Pred<T>): (fn2: Pred<T>) => (...args: T) => boolean
  • description

    takes two functions and returns a function that will take arguments for both of the function and returns true if any one function returns true otherwise returns false

    example
    let gt10 = F.gt(10);
    let lt5 = F.lt(5);
    F.either(gt10,lt5)(7) // false
    F.either(gt10,lt5)(17) // true

    Type parameters

    • T: any[]

    Parameters

    • fn1: Pred<T>
    • fn2: Pred<T>

    Returns (...args: T) => boolean

    a function that takes arguments for both of the function.

      • (...args: T): boolean
      • Parameters

        • Rest ...args: T

        Returns boolean

        a function that takes arguments for both of the function.

  • Type parameters

    • T: any[]

    Parameters

    • fn1: Pred<T>

    Returns (fn2: Pred<T>) => (...args: T) => boolean

      • (fn2: Pred<T>): (...args: T) => boolean
      • Parameters

        • fn2: Pred<T>

        Returns (...args: T) => boolean

          • (...args: T): boolean
          • Parameters

            • Rest ...args: T

            Returns boolean

empty

  • empty(x: string | object | any[]): {}
  • description

    takes object or array or string and returns empty version of given type

    example
    F.empty([1,2,3]) // []
    F.empty('pranshu') // ''
    F.empty(33) // {}

    Parameters

    • x: string | object | any[]

    Returns {}

    flip

    • flip<T1, T2, T3, R>(fn: (args2: T2, args1: T1, ...args: T3) => R): (args1: T1, args2: T2, ...args: T3) => R
    • description

      returns a function that invokes the function with first two arguments fipped

      example
      let flippedConcat = F.flip(F.concat);
      flippedConcat("pranshu","shah") //shahpranshu

      Type parameters

      • T1

      • T2

      • T3: any[]

      • R

      Parameters

      • fn: (args2: T2, args1: T1, ...args: T3) => R
          • (args2: T2, args1: T1, ...args: T3): R
          • Parameters

            • args2: T2
            • args1: T1
            • Rest ...args: T3

            Returns R

      Returns (args1: T1, args2: T2, ...args: T3) => R

        • (args1: T1, args2: T2, ...args: T3): R
        • Parameters

          • args1: T1
          • args2: T2
          • Rest ...args: T3

          Returns R

    identity

    • identity<T>(v: T): T
    • description

      always returns the value that passed in argument.

      example
      let numbers = [1,2,3,4];
      identity(numbers) // [1,2,3,4]

      Type parameters

      • T

      Parameters

      • v: T

      Returns T

    is_array

    • is_array(x: any): boolean
    • description

      wrpper around Array.isArray

      example
      F.is_array([1,2]) // true
      F.is_array("pranshu") // false
      F.is_array({}) // false
      F.is_array(undefined) // false

      Parameters

      • x: any

      Returns boolean

    is_array_like

    • is_array_like(x: any): boolean
    • description

      returns true for object that has a length property.returns false for function.

      example
      F.is_array_like("pranshu") // true
      function x(){
      F.is_array_like(arguments) // true
      }
      F.is_array_like({id:1}) // false

      Parameters

      • x: any

      Returns boolean

    is_date

    • is_date(x: any): number | false
    • description

      checks weather given element is date or not.

      example
      F.is_date(new Date()) // true
      F.is_date({}) // false

      Parameters

      • x: any

      Returns number | false

    is_empty

    • is_empty(x: any): boolean
    • description

      checks for string,array and object whether they are empty or not. returns false of every other data types.

      example
      F.is_empty(null) //true
      F.is_empty(undefined) //true
      F.is_empty([1,2]) // false
      F.is_empty([]) // true
      F.is_empty({}) //true
      F.is_empty("") // true
      F.is_empty("pra") // false

      Parameters

      • x: any

      Returns boolean

    is_finite

    • is_finite(x: any): boolean

    is_function

    • is_function(x: any): any
    • description

      check for given element is function or not returns false for object,array and date

      example
      F.is_function(Array.isArray) // true
      F.is_function(Array.prototype) // false

      Parameters

      • x: any

      Returns any

    is_map

    • is_map(x: any): boolean
    • description

      checks whether given element is Map object.

      example
      F.is_map(new Map()) // true
      F.is_map({}) // false
      F.is_map(new Date()) // false
      F.is_map(new Set()) // false

      Parameters

      • x: any

      Returns boolean

    is_match

    • is_match<T>(matcher: Partial<T>, obj: T): boolean
    • is_match<T>(matcher: Partial<T>): (obj: T) => boolean
    • description

      Tells you if the keys and values in matcher are present in obj.

      Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: Partial<T>
      • obj: T

      Returns boolean

    • Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: Partial<T>

      Returns (obj: T) => boolean

        • (obj: T): boolean
        • Parameters

          • obj: T

          Returns boolean

    is_null

    • is_null(x: any): boolean
    • description

      wrapper around x === null

      example
      F.is_null(null) // true
      F.is_null(undefined) // false
      F.is_null({}) // false

      Parameters

      • x: any

      Returns boolean

    is_object

    • is_object(x: any): boolean
    • description

      checks wether given value is object or not.

      example
      F.is_object({id:1}) // true
      F.is_object([]) // true
      F.is_object(new Map()) // true
      F.is_object(null) // true

      Parameters

      • x: any

      Returns boolean

    is_object_like

    • is_object_like(x: any): boolean
    • description

      checks wether given value is object or not.returns false for function,array,map,set null and primitive types.

      example
      F.is_object_like({id:1}); // true
      F.is_object_like(new Map()); // false
      F.is_object_like([]); // false
      F.is_object_like(new Set()); // false
      F.is_object_like(null); // false

      Parameters

      • x: any

      Returns boolean

    is_primitive

    • is_primitive(x: any): boolean
    • description

      cehcks it whether given type is javascript primitive or not.generally type of null is object which very wellknown bug in javascript but here it returns true for null.

      example
      F.is_primitive(null) // true
      F.is_primitive("pranshu") // true
      F.is_primitive(33) // true
      F.is_primitive(undefined) // true
      F.is_primitive({}) // false
      F.is_primitive([]) // false
      F.is_primitive(()=>{}) // false

      Parameters

      • x: any

      Returns boolean

    is_set

    • is_set(x: any): boolean
    • description

      checks whether given element is javascript Set or not.

      example
      F.is_set(new Set()) // true
      F.is_set({}) // false
      F.is_set(new Date()) // false
      F.is_set(new Map()) // false

      Parameters

      • x: any

      Returns boolean

    is_undefined

    • is_undefined(x: any): boolean
    • description

      wrapper around x === undefined

      example
      F.is_undefined(undefined) // true
      F.is_undefined(null) // false
      F.is_undefined({}) // false
      F.is_undefined([]) // false
      F.is_undefined(22) // false
      F.is_undefined("pranshu") // false

      Parameters

      • x: any

      Returns boolean

    once

    • once<F>(fn: F): (...args: Parameters<F>) => ReturnType<F>
    • description

      takes and function as an argument and returns a function that takes arguments for function we passed and invokes that function only once.

      example
       let count = 0;
      function inc() {
      count++;
      return count;
      }
      let resultOnce = F.once(inc);
      resultOnce(); // count = 1;
      resultOnce(); // count = 1;

      Type parameters

      • F: (...a: readonly any[]) => any

      Parameters

      • fn: F

      Returns (...args: Parameters<F>) => ReturnType<F>

        • (...args: Parameters<F>): ReturnType<F>
        • Parameters

          • Rest ...args: Parameters<F>

          Returns ReturnType<F>

    partial

    • partial<T1, T2, R>(fn: (...args: [...T1[], ...T2[]]) => R, ...intialArgs: T1): (...afterargs: T2) => R
    • description

      takes a function as argument and few arguments of that function and returns a function that takes rest of the argument. when you call returned function it invokes argument function with given arguments.

      example
      async function postFetch(url:string,body={}:object){
      let res = await fetch(url,{
      method:"POST",
      mode: 'cors',
      headers: {
      'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
      });
      return await res.json();
      }
      let addTodo = F.partial(postFetch,"addTodos");
      await addTodo({id:1,text:"todo1",done:false,userId:123})

      Type parameters

      • T1: readonly any[]

      • T2: readonly any[]

      • R

      Parameters

      • fn: (...args: [...T1[], ...T2[]]) => R
          • (...args: [...T1[], ...T2[]]): R
          • Parameters

            • Rest ...args: [...T1[], ...T2[]]

            Returns R

      • Rest ...intialArgs: T1

      Returns (...afterargs: T2) => R

        • (...afterargs: T2): R
        • Parameters

          • Rest ...afterargs: T2

          Returns R

    partial_right

    • partial_right<P1, P2, F>(fn: F, ...intialArgs: P1): (...afterargs: P2) => ReturnType<F>
    • description

      This method is like F.partial except that partially applied arguments are appended to the arguments it receives.type inference is not working as expected so you have to explicitly type genereic i hope we resolve this issue in up coming version.

      example
      async function postFetch(url:string,body={}:object){
      let res = await fetch(url,{
      method:"POST",
      mode: 'cors',
      headers: {
      'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
      });
      return await res.json();
      }
      let postRequestFromUser = F.partial_right<[object],[string],typeof postFetch>(postFetch,{
      user:localStorage.getItem("id"),
      authId:localStorage.getItem("authId")
      })
      postRequestFromUser("addTodos")

      Type parameters

      • P1: unknown[]

      • P2: unknown[]

      • F: (...args: [...P2[], ...P1[]]) => any

      Parameters

      • fn: F
      • Rest ...intialArgs: P1

      Returns (...afterargs: P2) => ReturnType<F>

        • (...afterargs: P2): ReturnType<F>
        • Parameters

          • Rest ...afterargs: P2

          Returns ReturnType<F>

    pipe

    • pipe<V, T1, T2, T3, T4, T5, T6>(fn0: (...args: V) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (...args: V) => T5): (...args: V) => T6
    • pipe<V, T1>(fn0: (...args: V) => T1): (...args: V) => T1
    • pipe<V, T1, T2>(fn0: (...args: V) => T1, fn1: (x: T1) => T2): (...args: V) => T2
    • pipe<V, T1, T2, T3>(fn0: (...args: V) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (...args: V) => T3
    • pipe<V, T1, T2, T3, T4>(fn0: (...args: V) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (...args: V) => T4
    • pipe<V, T1, T2, T3, T4, T5>(fn0: (...args: V) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (...args: V) => T5
    • description

      it is same as F.compose but order of exection of function is left-right

      example

      function upper(x: string) {
      return x.toUpperCase();
      }
      const greeting = (first: string, last: string) => first + last;
      F.compose(greeting,upper)("pranshu","shah") //PRANSHUSHAH

      Type parameters

      • V: any[]

      • T1

      • T2

      • T3

      • T4

      • T5

      • T6

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      • fn1: (x: T1) => T2
          • (x: T1): T2
          • Parameters

            • x: T1

            Returns T2

      • fn2: (x: T2) => T3
          • (x: T2): T3
          • Parameters

            • x: T2

            Returns T3

      • fn3: (x: T3) => T4
          • (x: T3): T4
          • Parameters

            • x: T3

            Returns T4

      • fn4: (x: T4) => T5
          • (x: T4): T5
          • Parameters

            • x: T4

            Returns T5

      • fn5: (...args: V) => T5
          • (...args: V): T5
          • Parameters

            • Rest ...args: V

            Returns T5

      Returns (...args: V) => T6

        • (...args: V): T6
        • Parameters

          • Rest ...args: V

          Returns T6

    • Type parameters

      • V: any[]

      • T1

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      Returns (...args: V) => T1

        • (...args: V): T1
        • Parameters

          • Rest ...args: V

          Returns T1

    • Type parameters

      • V: any[]

      • T1

      • T2

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      • fn1: (x: T1) => T2
          • (x: T1): T2
          • Parameters

            • x: T1

            Returns T2

      Returns (...args: V) => T2

        • (...args: V): T2
        • Parameters

          • Rest ...args: V

          Returns T2

    • Type parameters

      • V: any[]

      • T1

      • T2

      • T3

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      • fn1: (x: T1) => T2
          • (x: T1): T2
          • Parameters

            • x: T1

            Returns T2

      • fn2: (x: T2) => T3
          • (x: T2): T3
          • Parameters

            • x: T2

            Returns T3

      Returns (...args: V) => T3

        • (...args: V): T3
        • Parameters

          • Rest ...args: V

          Returns T3

    • Type parameters

      • V: any[]

      • T1

      • T2

      • T3

      • T4

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      • fn1: (x: T1) => T2
          • (x: T1): T2
          • Parameters

            • x: T1

            Returns T2

      • fn2: (x: T2) => T3
          • (x: T2): T3
          • Parameters

            • x: T2

            Returns T3

      • fn3: (x: T3) => T4
          • (x: T3): T4
          • Parameters

            • x: T3

            Returns T4

      Returns (...args: V) => T4

        • (...args: V): T4
        • Parameters

          • Rest ...args: V

          Returns T4

    • Type parameters

      • V: any[]

      • T1

      • T2

      • T3

      • T4

      • T5

      Parameters

      • fn0: (...args: V) => T1
          • (...args: V): T1
          • Parameters

            • Rest ...args: V

            Returns T1

      • fn1: (x: T1) => T2
          • (x: T1): T2
          • Parameters

            • x: T1

            Returns T2

      • fn2: (x: T2) => T3
          • (x: T2): T3
          • Parameters

            • x: T2

            Returns T3

      • fn3: (x: T3) => T4
          • (x: T3): T4
          • Parameters

            • x: T3

            Returns T4

      • fn4: (x: T4) => T5
          • (x: T4): T5
          • Parameters

            • x: T4

            Returns T5

      Returns (...args: V) => T5

        • (...args: V): T5
        • Parameters

          • Rest ...args: V

          Returns T5

    reverse_arguments

    • reverse_arguments<T, R>(fn: (...arg: T) => R): (...args: List.Reverse<T>) => R
    • description

      takes a function an returns function that takes argument for function we passed in reverse and calls that function when we call returned function; also works in partial form.

      example
      function logName(name: string, age: number) {
      return `name is ${name} and age is ${age}`;
      }
      F.reverse_arguments(logName)(24,"pranshu") // name is pranshu and age is 24

      Type parameters

      • T: any[]

      • R

      Parameters

      • fn: (...arg: T) => R
          • (...arg: T): R
          • Parameters

            • Rest ...arg: T

            Returns R

      Returns (...args: List.Reverse<T>) => R

        • (...args: List.Reverse<T>): R
        • Parameters

          • Rest ...args: List.Reverse<T>

          Returns R

    throttle

    • throttle<F>(fn: F, wait: number, immediate?: boolean): (...args: Parameters<F>) => void
    • example

      window.addEventListener('scroll',F.throttle(function(e:Event){
      console.log(e)
      },200))

      Type parameters

      • F: (...args: any[]) => any

      Parameters

      • fn: F

        function you want to throttle.

      • wait: number

        throttling time

      • immediate: boolean = true

        if immediate is true it invokes at leading end otherwise it invokes at trailing end.for more info please check out this link.

      Returns (...args: Parameters<F>) => void

        • (...args: Parameters<F>): void
        • Parameters

          • Rest ...args: Parameters<F>

          Returns void

    times

    • times<T>(fn: (arg: number) => T, n: number): T[]
    • times<T>(fn: (arg: number) => T): (n: number) => T[]
    • description

      Calls an input function n times, returning an array containing the results of those function calls.

      example
      F.times(gt(3),5) // [false,false,false,false,true]

      Type parameters

      • T

      Parameters

      • fn: (arg: number) => T
          • (arg: number): T
          • Parameters

            • arg: number

            Returns T

      • n: number

      Returns T[]

    • Type parameters

      • T

      Parameters

      • fn: (arg: number) => T
          • (arg: number): T
          • Parameters

            • arg: number

            Returns T

      Returns (n: number) => T[]

        • (n: number): T[]
        • Parameters

          • n: number

          Returns T[]

    try_catch

    • try_catch<F, F1>(tryer: F, catcher: F1): (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>
    • try_catch<F>(tryer: F): <F1>(catcher: F1) => (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>
    • description

      tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does not throw error, it simply returns the result. If the tryer does throw error, the returned function evaluates the catcher function and returns its result.

      example
      function catcher(x: Error) {
      return x.message;
      }
      let gtWithCatch= F.try_catch(gt,catcher)
      gtWithCatch([1,2],[]) // true
      let errorChecker = F.try_catch(function() {
      throw Error('error');
      },catcher)
      errorChecker() // 'error'

      Type parameters

      • F: (...args: any[]) => any

      • F1: (x: Error, ...args: any[]) => any

      Parameters

      • tryer: F
      • catcher: F1

      Returns (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>

      function that takes tuple of array arguments for tryer and catcher.

        • (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]): ReturnType<F1> | ReturnType<F>
        • Parameters

          • args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]

          Returns ReturnType<F1> | ReturnType<F>

          function that takes tuple of array arguments for tryer and catcher.

    • Type parameters

      • F: (...args: any[]) => any

      Parameters

      • tryer: F

      Returns <F1>(catcher: F1) => (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>

        • <F1>(catcher: F1): (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>
        • Type parameters

          • F1: (x: Error, ...args: any[]) => any

          Parameters

          • catcher: F1

          Returns (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]) => ReturnType<F1> | ReturnType<F>

            • (args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]): ReturnType<F1> | ReturnType<F>
            • Parameters

              • args: [OvarloadedParameters<F>, Tail<OvarloadedParameters<F1>>]

              Returns ReturnType<F1> | ReturnType<F>

    unary

    • unary<T>(fn: T): (arg: Head<OvarloadedParameters<T>>) => OverloadedReturnType<T>
    • description

      returns the function that will call the supplied function with only first argument we passed.

      example
      function takesTwoArgs(x: number, y: number = 22): [number, number] {
      return [x, y];
      }
      let takesOneArgs = F.unary(takesTwoArgs);
      takesOneArgs(42) // [42,22]

      Type parameters

      • T: (...args: any[]) => any

      Parameters

      • fn: T

      Returns (arg: Head<OvarloadedParameters<T>>) => OverloadedReturnType<T>

        • (arg: Head<OvarloadedParameters<T>>): OverloadedReturnType<T>
        • Parameters

          • arg: Head<OvarloadedParameters<T>>

          Returns OverloadedReturnType<T>

    uncurry

    • uncurry<F1>(fn: Curry<F1>): F.UnCurry<F1>
    • description

      uncurries F.curry.

      example
      const addFour = a => b => c => d => a + b + c + d;
      const uncurriedAddFour = F.uncurry(addFour);
      uncurriedAddFour(1, 2, 3, 4); //=> 10

      Type parameters

      • F1: Function<any, any, F1>

      Parameters

      • fn: Curry<F1>

      Returns F.UnCurry<F1>

    List Functions

    adjust

    • adjust<T>(index: number, fn: (arg: T) => T, arr: readonly T[]): T[]
    • adjust<T>(index: number, fn: (arg: T) => T): (arr: readonly T[]) => T[]
    • adjust(index: number): { <T>(fn: (arg: T) => T, arr: readonly T[]): T[]; <T>(fn: (arg: T) => T): (arr: readonly T[]) => T[] }
    • description

      this function takes index,function and array as an argument.then passes the element at given index to the function and return value is set as new value at given index in array.

      example
      F.adjust(3,F.negate,[1,2,3,4]) // => [1,2,3,-4]

      const arrayGetter = F.adjust(3,F.negate);
      arrayGetter([1,2]) // => [1,-2]

      const functionAndArrayGetter = F.adjust(-1);
      functionAndArrayGetter(F.negate,[1,2,3]); // => [1,2,-3]

      Type parameters

      • T

      Parameters

      • index: number
      • fn: (arg: T) => T
          • (arg: T): T
          • Parameters

            • arg: T

            Returns T

      • arr: readonly T[]

      Returns T[]

      new copy of array with function applied at given index

    • Type parameters

      • T

      Parameters

      • index: number
      • fn: (arg: T) => T
          • (arg: T): T
          • Parameters

            • arg: T

            Returns T

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    • Parameters

      • index: number

      Returns { <T>(fn: (arg: T) => T, arr: readonly T[]): T[]; <T>(fn: (arg: T) => T): (arr: readonly T[]) => T[] }

        • <T>(fn: (arg: T) => T, arr: readonly T[]): T[]
        • <T>(fn: (arg: T) => T): (arr: readonly T[]) => T[]
        • Type parameters

          • T

          Parameters

          • fn: (arg: T) => T
              • (arg: T): T
              • Parameters

                • arg: T

                Returns T

          • arr: readonly T[]

          Returns T[]

        • Type parameters

          • T

          Parameters

          • fn: (arg: T) => T
              • (arg: T): T
              • Parameters

                • arg: T

                Returns T

          Returns (arr: readonly T[]) => T[]

            • (arr: readonly T[]): T[]
            • Parameters

              • arr: readonly T[]

              Returns T[]

    all

    • all<T>(predicate: (arg: T) => boolean, arr: readonly T[]): boolean
    • all<T>(predicate: (arg: T) => boolean): (arr: readonly T[]) => boolean
    • description

      takes predication function and array and passes all element one by one to predication function if it returns true for all elements function returns true otherwise it returns false. also works in partial form

      example
       F.all(F.lt(100), [1, 2, 3, 3, 56, -112, -32])  // =>  true
      let arrayGetter = F.all(F.lt(100));
      arrayGetter([1, 2, 3, 3, 56, 112, -32]) // false

      Type parameters

      • T

      Parameters

      • predicate: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      • arr: readonly T[]

      Returns boolean

      true if predication function returns true for all elements in array otherwise false

    • Type parameters

      • T

      Parameters

      • predicate: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      Returns (arr: readonly T[]) => boolean

        • (arr: readonly T[]): boolean
        • Parameters

          • arr: readonly T[]

          Returns boolean

    any

    • any<T>(predicate: (arg: T) => boolean, arr: readonly T[]): boolean
    • any<T>(predicate: (arg: T) => boolean): (arr: readonly T[]) => boolean
    • description

      takes predication function and array and passes all element one by one to predication function if it returns true for any,element function returns true it otherwise returns false. also works in partial form

      example
      function isItLongString(str:string){
      return str.length > 10;
      }
      F.any(isItLongString,["pranshu","mit","pranshu shah"]) // true;
      F.any(isItLongString,["pranshu","mit","sanket"]) // false;

      Type parameters

      • T

      Parameters

      • predicate: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      • arr: readonly T[]

      Returns boolean

      true if predication function returns true for any element in array or false

    • Type parameters

      • T

      Parameters

      • predicate: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      Returns (arr: readonly T[]) => boolean

        • (arr: readonly T[]): boolean
        • Parameters

          • arr: readonly T[]

          Returns boolean

    append

    • append<T>(arr: T[], val: T): T[]
    • append<T>(arr: T[]): (val: T) => T[]
    • description

      takes array and value and appends that value into the array also works in partial form

      example
      let arr = [1,2,3];
      arr = append(arr,4); // [1,2,3,4]

      Type parameters

      • T

      Parameters

      • arr: T[]
      • val: T

      Returns T[]

      new copy of array with given value at end

    • Type parameters

      • T

      Parameters

      • arr: T[]

      Returns (val: T) => T[]

        • (val: T): T[]
        • Parameters

          • val: T

          Returns T[]

    apply

    • apply<Function>(fn: Function, arr: OvarloadedParameters<Function>): OverloadedReturnType<Function>
    • apply<Function>(fn: Function): (arr: OvarloadedParameters<Function>) => OverloadedReturnType<Function>
    • description

      takes a function and array of arguments and spread that arguments into function we passed, also works in parital form

      example
      let array_min = F.apply(Math.min);
      array_min([1,2,3,-1]) // -1

      Type parameters

      • Function: (...args: any[]) => any

      Parameters

      • fn: Function
      • arr: OvarloadedParameters<Function>

      Returns OverloadedReturnType<Function>

      return value of the function.

    • Type parameters

      • Function: (...args: any[]) => any

      Parameters

      • fn: Function

      Returns (arr: OvarloadedParameters<Function>) => OverloadedReturnType<Function>

        • (arr: OvarloadedParameters<Function>): OverloadedReturnType<Function>
        • Parameters

          • arr: OvarloadedParameters<Function>

          Returns OverloadedReturnType<Function>

    compact

    • compact<T>(arr: readonly T[]): T[]
    • description

      takes an array and removes the falsy values like ("",null,undefined) returns the array.

      example
      F.compact([1,"","pranshu",null,3,undefined]) //[1,"pranshu",3]

      Type parameters

      • T

      Parameters

      • arr: readonly T[]

      Returns T[]

      it returns new copy of array without mutating original array

    concat

    • concat<T>(arg1: T, arg2: T): T
    • concat<T>(arg1: T): (arg2: T) => T
    • concat(arg1: string): (arg2: string) => string
    • concat(arg1: string, arg2: string): string
    • description

      take two element. that can be either string or array and returns the concated version.it will throw error if we pass one string and one array.it also take partial arguments

      example
      F.concat([1,2],[3,4]) // [1,2,3,4]
      F.concat("pranshu ","shah") // "pranshu shah"

      Type parameters

      • T: readonly any[]

      Parameters

      • arg1: T
      • arg2: T

      Returns T

      new string or array.

    • Type parameters

      • T: readonly any[]

      Parameters

      • arg1: T

      Returns (arg2: T) => T

        • (arg2: T): T
        • Parameters

          • arg2: T

          Returns T

    • Parameters

      • arg1: string

      Returns (arg2: string) => string

        • (arg2: string): string
        • Parameters

          • arg2: string

          Returns string

    • Parameters

      • arg1: string
      • arg2: string

      Returns string

    difference

    • difference<T>(arr1: T[], arr2: T[]): T[]
    • difference<T>(arr1: T[]): (arr2: T[]) => T[]
    • description

      takes 2 array and returns array that does not contain any value of second array.it uses F.equals for eqality.

      example
      F.difference([1,2,3,4,5],[2,4,6]); // [1,3,5]
      F.difference([{id:1,task:"task1"},{id:2,task:"task2"},{id:3,task:"task3"}],[{id:1,task:"task1"},{id:4,task:"task4"}]) // [{id:2,task:"task2"},{id:3,task:"task3"}]

      Type parameters

      • T

      Parameters

      • arr1: T[]
      • arr2: T[]

      Returns T[]

      an array that contains values of the first array but does not exist in second array.

    • Type parameters

      • T

      Parameters

      • arr1: T[]

      Returns (arr2: T[]) => T[]

        • (arr2: T[]): T[]
        • Parameters

          • arr2: T[]

          Returns T[]

    drop

    • drop<T>(n: number, xs: T): T
    • drop<T>(n: number): (xs: T) => T
    • drop(n: number, xs: string): string
    • drop(n: number): (xs: string) => string
    • description

      drops any number of elements you want from front of the array or string and returns new copy of or array or string.if you provide number > number of elements in array it drops all elements and if you provide negative number it will not drop any element.

      example
      F.drop([1,2,3,4,5,6],3) //[4,5,6]
      F.drop("pranshu",3) // 'nshu'

      Type parameters

      • T: any[]

      Parameters

      • n: number
      • xs: T

      Returns T

      shallow copy with removed elements.

    • Type parameters

      • T: any[]

      Parameters

      • n: number

      Returns (xs: T) => T

        • (xs: T): T
        • Parameters

          • xs: T

          Returns T

    • Parameters

      • n: number
      • xs: string

      Returns string

    • Parameters

      • n: number

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    drop_last

    • drop_last<T>(number_element_to_drop_from_back: number, xs: T): T
    • drop_last<T>(number_element_to_drop_from_back: number): (xs: T) => T
    • drop_last(number_element_to_drop_from_back: number, xs: string): string
    • drop_last(number_element_to_drop_from_back: number): (xs: string) => string
    • description

      drops any number of elements you want from back array or string and returns new copy of or array or string.if you provide number > number of elements in array it does not drop any element and if you provide negative number it will not drop any element.

      example
      F.drop_last([1,2,3,4,5,6],3) //[1,2,3]
      F.drop_last("pranshu",3) // 'pran'

      Type parameters

      • T: any[]

      Parameters

      • number_element_to_drop_from_back: number
      • xs: T

      Returns T

    • Type parameters

      • T: any[]

      Parameters

      • number_element_to_drop_from_back: number

      Returns (xs: T) => T

        • (xs: T): T
        • Parameters

          • xs: T

          Returns T

    • Parameters

      • number_element_to_drop_from_back: number
      • xs: string

      Returns string

    • Parameters

      • number_element_to_drop_from_back: number

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    drop_last_while

    • drop_last_while<T>(predicate_fn: (arg: UnionOf<T>) => boolean, xs: T): T
    • drop_last_while<T>(predicate_fn: (arg: UnionOf<T>) => boolean): T
    • drop_last_while(predicate_fn: (arg: string) => boolean, xs: string): string
    • drop_last_while(predicate_fn: (arg: string) => boolean): (xs: string) => string
    • description

      drops elements from last until predication function returns false and it returns new copy of dropped .works also with partial arguments.

      example
      function isOdd(x:number){
      return F.mod(2,x) === 1;
      }
      F.drop_last_while(isOdd,[1,2,3,5,7]); //[1,2]
      F.drop_last_while((s: string) => s !== 'n', 'pranshu'); // 'pran'

      Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      • xs: T

      Returns T

    • Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      Returns T

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      • xs: string

      Returns string

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    drop_repeats

    • drop_repeats<T>(arr: T): any[]
    • description

      drops repeating elements in array it uses F.equals internally and returns new copy of array

      example
      F.drop_repeats([1,2,3,1,2,3,1,2]) // [1,2,3]
      F.drop_repeats([{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"},{id:2,name:"mit"}]) // [{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]

      Type parameters

      • T: any[]

      Parameters

      • arr: T

      Returns any[]

      new array that does not contain the copy.

    drop_while

    • drop_while<T>(predicate_fn: (arg: UnionOf<T>) => boolean, xs: T): T
    • drop_while<T>(predicate_fn: (arg: UnionOf<T>) => boolean): (xs: T) => T
    • drop_while(predicate_fn: (arg: string) => boolean, xs: string): string
    • drop_while(predicate_fn: (arg: string) => boolean): (xs: string) => string
    • description

      drops elements from front until predcation function returns false and returns copy of that array or string.also wokrs in partial form

      example
      function isOdd(x:number){
      return F.mod(2,x) === 1;
      }
      F.drop_while(isOdd,[1,3,4,5]); //[4,5]
      F.drop_while((s: string) => s !== 'n', 'pranshu'); // 'nshu'

      Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      • xs: T

      Returns T

      shallow copy of the array with removed elements.

    • Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      Returns (xs: T) => T

        • (xs: T): T
        • Parameters

          • xs: T

          Returns T

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      • xs: string

      Returns string

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    ends_with

    • ends_with<T>(suffix: T, xs: T): boolean
    • ends_with<T>(suffix: T): (xs: T) => boolean
    • ends_with(suffix: string, xs: string): boolean
    • ends_with(suffix: string): (xs: string) => boolean
    • description

      checks if given list ends with provided sublist. it uses F.equals

      example
      F.ends_with([{id:1,name:"pranshu"}],[{id:3,name:"sanket"},{id:2,name:"mit"},{id:1,name:"pranshu"}]) // true
      F.ends_with("pra","pranshu") // false

      Type parameters

      • T: any[]

      Parameters

      • suffix: T
      • xs: T

      Returns boolean

    • Type parameters

      • T: any[]

      Parameters

      • suffix: T

      Returns (xs: T) => boolean

        • (xs: T): boolean
        • Parameters

          • xs: T

          Returns boolean

    • Parameters

      • suffix: string
      • xs: string

      Returns boolean

    • Parameters

      • suffix: string

      Returns (xs: string) => boolean

        • (xs: string): boolean
        • Parameters

          • xs: string

          Returns boolean

    filter

    • filter<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): T[]
    • filter<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => T[]
    • description

      returns an array of all elements for which predicate function returns true,also works with partial argument.

      alias

      filter_in

      example
      function isOdd(x:number){
      return x % 2 === 1;
      }
      F.filter(isOdd,[1,2,3,4,5,6,7]) // [1,3,5,7]

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    filter_in

    • filter_in<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): T[]
    • filter_in<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => T[]
    • description

      returns an array of all elements for which predicate function returns true,also works with partial argument.

      alias

      filter

      example
      function isOdd(x:number){
      return x % 2 === 1;
      }
      F.filter_in(isOdd,[1,2,3,4,5,6,7]) // [1,3,5,7]

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    filter_out

    • filter_out<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): T[]
    • filter_out<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => T[]
    • description

      returns an array of all elements for which predicate function returns false,also works with partial argument.

      example
      function isOdd(x:number){
      return x % 2 === 1;
      }
      F.filter_out(isOdd,[1,2,3,4,5,6,7]) // [2,4,6]

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    find

    • find<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): T | undefined
    • find<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => T | undefined
    • description

      returns the last element for which predication function returns true. returns undefined if predication function does not return true for any value in array, also works with partial argument.

      example

      function isLongString(x:string){ return x.length > 10; } F.find(isLongString,["mit","sanket","pranshu shah","nisarg","mit nilesh desai"]) // "pranshu shah" F.find(isLongString,["mit","sanket","pranshu","nisarg"]) // undefined

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns T | undefined

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => T | undefined

        • (arr: readonly T[]): T | undefined
        • Parameters

          • arr: readonly T[]

          Returns T | undefined

    find_index

    • find_index<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): number
    • find_index<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => number
    • description

      returns the first index for which predication function returns true. returns -1 if predication function does not return true for any value in array,also works with partial argument.

      example
      function isLongString(x:string){
      return x.length > 10;
      }
      F.find_index(isLongString,["mit","sanket","pranshu shah","nisarg","mit nilesh desai"]) // 2
      F.find_index(isLongString,["mit","sanket","pranshu","nisarg"]) // -1

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns number

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => number

        • (arr: readonly T[]): number
        • Parameters

          • arr: readonly T[]

          Returns number

    find_last

    • find_last<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): T | undefined
    • find_last<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => T | undefined
    • description

      returns the last element for which predication function returns true. returns undefined if predication function does not return true for any value in array.also works with partial argument.

      example
      function isLongString(x:string){
      return x.length > 10;
      }
      F.find_last(isLongString,["mit","sanket","pranshu shah","nisarg","mit nilesh desai"]) // "mit nilesh desai"
      F.find_index(isLongString,["mit","sanket","pranshu","nisarg"]) // undefined

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns T | undefined

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => T | undefined

        • (arr: readonly T[]): T | undefined
        • Parameters

          • arr: readonly T[]

          Returns T | undefined

    find_last_index

    • find_last_index<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean, arr: readonly T[]): number
    • find_last_index<T>(predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean): (arr: readonly T[]) => number
    • description

      returns the last index for which predication function returns true. returns -1 if predication function does not return true for any value in array,also works with partial argument.

      example
      function isLongString(x:string){
      return x.length > 10;
      }
      F.find_last_index(isLongString,["mit","sanket","pranshu shah","nisarg","mit nilesh desai"]) // 4
      F.find_last_index(isLongString,["mit","sanket","pranshu","nisarg"]) // -1

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      • arr: readonly T[]

      Returns number

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T, index: number, arr: readonly T[]) => boolean
          • (arg: T, index: number, arr: readonly T[]): boolean
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns boolean

      Returns (arr: readonly T[]) => number

        • (arr: readonly T[]): number
        • Parameters

          • arr: readonly T[]

          Returns number

    find_where

    • find_where<T>(matcher: Partial<T>): (list: T[]) => T
    • find_where<T>(matcher: Partial<T>, list: T[]): T
    • Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: Partial<T>

      Returns (list: T[]) => T

        • (list: T[]): T
        • Parameters

          • list: T[]

          Returns T

    • Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: Partial<T>
      • list: T[]

      Returns T

    flat_map

    • flat_map<T, R>(mapper: R, arr: T[]): any[]
    • flat_map<T, R>(mapper: R): (arr: T[]) => any[]
    • description

      Wrapper around [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap](array.prototype.flatMap).also supports partial form.

      example
      let arr = ["it's always sunny in","philadelphia"];
      F.flat_map(function mapper(x:string){
      return x.split(" ")
      },arr) // ["it's", "always", "sunny", "in", "philadelphia"]

      Type parameters

      • T: unknown

      • R: (val: T, index: number, arr: T[]) => any

      Parameters

      • mapper: R
      • arr: T[]

      Returns any[]

    • Type parameters

      • T: unknown

      • R: (val: T, index: number, arr: T[]) => any

      Parameters

      • mapper: R

      Returns (arr: T[]) => any[]

        • (arr: T[]): any[]
        • Parameters

          • arr: T[]

          Returns any[]

    flatten

    • flatten<T>(arr: T[]): FlatArray<T, 0 | 1 | 2 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20>[]
    • description

      it is equivalent to es6 arr.flat(Infinity)

      example
      F.flatten([1,2,3,[[4,5]]]) // [1,2,3,4,5]
      F.flatten(1,2,3,[[[4]]]) // [1,2,3,4]

      Type parameters

      • T

      Parameters

      • arr: T[]

      Returns FlatArray<T, 0 | 1 | 2 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20>[]

    for_each

    • for_each<T>(fn: (arg: T, index: number, arr: readonly T[]) => void, arr: readonly T[]): T[]
    • for_each<T>(fn: (arg: T, index: number, arr: readonly T[]) => void): (arr: readonly T[]) => T[]
    • description

      takes a function and an array, and calls that function on every element of array.

      example
      for_each(function todoPrinter(todo){
      console.log(todo.task)
      },[{id:1,task:"task1"},{id:2,task:"task2"},{id:3,task:"task3"}]) // task1 task2 task3

      Type parameters

      • T

      Parameters

      • fn: (arg: T, index: number, arr: readonly T[]) => void
          • (arg: T, index: number, arr: readonly T[]): void
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns void

      • arr: readonly T[]

      Returns T[]

      original array.

    • Type parameters

      • T

      Parameters

      • fn: (arg: T, index: number, arr: readonly T[]) => void
          • (arg: T, index: number, arr: readonly T[]): void
          • Parameters

            • arg: T
            • index: number
            • arr: readonly T[]

            Returns void

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    from_pair

    • from_pair<T>(arr: [string | number, any][]): Obj<any>
    • description

      takes array of tuple of [key,value] and maps that tuples into object.

      example
      let namePair = [["name","pranshu"],["age",24],["city","surat"]]
      F.from_pair(namePair) {name:"pranshu",age:24,city:"surat"}

      Type parameters

      • T

      Parameters

      • arr: [string | number, any][]

      Returns Obj<any>

      an object which was created from key-value pair of array.

    head

    • head(str: string): string
    • head<T>(list: readonly T[]): T | undefined
    • description

      takes an array or string and returns first element of it.

      example
      F.head("pranshu") // "p"
      F.head([1,2,3]) // 1

      Parameters

      • str: string

      Returns string

    • Type parameters

      • T

      Parameters

      • list: readonly T[]

      Returns T | undefined

    index_of

    • index_of<T>(item: T, arr: readonly T[]): number
    • index_of<T>(item: T): (arr: readonly T[]) => number
    • description

      takes and element and array and finds index of that element in array.it uses F.equals so you can find idnex of non primitive easily,also works with partial form

      example
      F.index_of("pranshu",["mit","pranshu","saumya"]) // 1
      F.index_of({id:1,name:"pranshu"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // 0
      F.index_of({id:1,name:"saumya"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // -1

      Type parameters

      • T

      Parameters

      • item: T
      • arr: readonly T[]

      Returns number

    • Type parameters

      • T

      Parameters

      • item: T

      Returns (arr: readonly T[]) => number

        • (arr: readonly T[]): number
        • Parameters

          • arr: readonly T[]

          Returns number

    init

    • init<T>(xs: T[]): T[]
    • init(xs: string): string

    insert

    • insert<T>(insert_index: number, element: T, arr: readonly T[]): T[]
    • insert<T>(insert_index: number, element: T): (arr: readonly T[]) => T[]
    • insert(insert_index: number): { <T>(element: T, arr: readonly T[]): T[]; <T>(element: T): (arr: readonly T[]) => T[] }
    • insert element at given index of array and returns new copy of array,also works with partial form.

      example
      F.insert(2,"pranshu",["mit","sanket","zoom","nisarg"]) //  ["mit", "sanket", "pranshu", "zoom", "nisarg"]
      

      Type parameters

      • T

      Parameters

      • insert_index: number
      • element: T
      • arr: readonly T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • insert_index: number
      • element: T

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    • Parameters

      • insert_index: number

      Returns { <T>(element: T, arr: readonly T[]): T[]; <T>(element: T): (arr: readonly T[]) => T[] }

        • <T>(element: T, arr: readonly T[]): T[]
        • <T>(element: T): (arr: readonly T[]) => T[]
        • Type parameters

          • T

          Parameters

          • element: T
          • arr: readonly T[]

          Returns T[]

        • Type parameters

          • T

          Parameters

          • element: T

          Returns (arr: readonly T[]) => T[]

            • (arr: readonly T[]): T[]
            • Parameters

              • arr: readonly T[]

              Returns T[]

    insert_all

    • insert_all<T>(insert_index: number, elements: readonly T[], arr: readonly T[]): T[]
    • insert_all<T>(insert_index: number, elements: readonly T[]): (arr: readonly T[]) => T[]
    • insert_all(insert_index: number): { <T>(elements: readonly T[], arr: readonly T[]): T[]; <T>(elements: readonly T[]): (arr: readonly T[]) => T[] }
    • description

      insert array of elements at given index of array and returns new copy of array., also works on partial form.

      example
      F.insert_all(2,[6,7],[1,2,3,4,5]) // [1,2,6,7,3,4,5]
      F.insert_all(111,[6,7],[1,2,3,4,5]) // [1,2,3,4,5,6,7]
      F.insert_all(-1,[6,7],[1,2,3,4,5]) // [6,7,1,2,3,4,5]
      F.insert_all(-111,[6,7],[1,2,3,4,5]) // [6,7,1,2,3,4,5]

      Type parameters

      • T

      Parameters

      • insert_index: number
      • elements: readonly T[]
      • arr: readonly T[]

      Returns T[]

      new copy of array with new elements

    • Type parameters

      • T

      Parameters

      • insert_index: number
      • elements: readonly T[]

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    • Parameters

      • insert_index: number

      Returns { <T>(elements: readonly T[], arr: readonly T[]): T[]; <T>(elements: readonly T[]): (arr: readonly T[]) => T[] }

        • <T>(elements: readonly T[], arr: readonly T[]): T[]
        • <T>(elements: readonly T[]): (arr: readonly T[]) => T[]
        • Type parameters

          • T

          Parameters

          • elements: readonly T[]
          • arr: readonly T[]

          Returns T[]

        • Type parameters

          • T

          Parameters

          • elements: readonly T[]

          Returns (arr: readonly T[]) => T[]

            • (arr: readonly T[]): T[]
            • Parameters

              • arr: readonly T[]

              Returns T[]

    intersperse

    • intersperse<T>(x: T, xs: readonly T[]): T[]
    • intersperse<T>(x: T): (xs: readonly T[]) => T[]
    • description

      creates a new array that adds separator between the elements , also works in partial form.

      example
      F.intersperse(" ",["pranshu","tikendrakumar","shah"]) // ["pranshu"," ","tikendrakumar"," ","shah"]
      

      Type parameters

      • T

      Parameters

      • x: T
      • xs: readonly T[]

      Returns T[]

      new array that has separator between every element.

    • Type parameters

      • T

      Parameters

      • x: T

      Returns (xs: readonly T[]) => T[]

        • (xs: readonly T[]): T[]
        • Parameters

          • xs: readonly T[]

          Returns T[]

    join

    • join(s: string, arr: any[]): string
    • join(s: string): (arr: any[]) => string
    • description

      wrapper around Array.prototype.join()

      example
      let addSpace = F.join(" ");
      addSpace(["pranshu","shah"]) // "pranshu shah"
      F.join('-',["left","right","center"]) // "left-right-center"

      Parameters

      • s: string
      • arr: any[]

      Returns string

    • Parameters

      • s: string

      Returns (arr: any[]) => string

        • (arr: any[]): string
        • Parameters

          • arr: any[]

          Returns string

    last

    • last<T>(xs: T[]): T | undefined
    • last(xs: string): string

    last_index_of

    • last_index_of<T>(item: T, arr: readonly T[]): number
    • last_index_of<T>(item: T): (arr: readonly T[]) => number
    • description

      returns last index of given element in array.returns -1 if no element is found.uses F.equals , also works with partial form.

      example
      F.last_index_of({id:1,name:pranshu},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:1,name:"pranshu"}]) // 2
      F.last_index_of(2,[1,3,4,5]) // -1
      F.last_index_of("a",["a","b","c","a"]) // 3

      Type parameters

      • T

      Parameters

      • item: T
      • arr: readonly T[]

      Returns number

    • Type parameters

      • T

      Parameters

      • item: T

      Returns (arr: readonly T[]) => number

        • (arr: readonly T[]): number
        • Parameters

          • arr: readonly T[]

          Returns number

    length

    • length<T>(xs: string | T[]): number
    • description

      returns length of given string or array.

      example
      F.length("pranshu") // 7
      F.length([1,2,3,4]) // 4
      F.length([]) // 0

      Type parameters

      • T

      Parameters

      • xs: string | T[]

      Returns number

    map

    • map<T, R>(mapper: (val: T, index: number, arr: readonly T[]) => R, arr: readonly T[]): R[]
    • map<T, R>(mapper: (val: T, index: number, arr: readonly T[]) => R): (arr: readonly T[]) => R[]
    • description

      same as es6 Array.prototype.map(). also works with partial form.

      example
      function mapper(todo:Todo){
      return todo.task
      }
      F.map(mapper,[{id:1,task:"task1"},{id:2,task:"task2"},{id:3,task:"task3"}]) // ["task1","task2","task3"]

      Type parameters

      • T

      • R

      Parameters

      • mapper: (val: T, index: number, arr: readonly T[]) => R
          • (val: T, index: number, arr: readonly T[]): R
          • Parameters

            • val: T
            • index: number
            • arr: readonly T[]

            Returns R

      • arr: readonly T[]

      Returns R[]

    • Type parameters

      • T

      • R

      Parameters

      • mapper: (val: T, index: number, arr: readonly T[]) => R
          • (val: T, index: number, arr: readonly T[]): R
          • Parameters

            • val: T
            • index: number
            • arr: readonly T[]

            Returns R

      Returns (arr: readonly T[]) => R[]

        • (arr: readonly T[]): R[]
        • Parameters

          • arr: readonly T[]

          Returns R[]

    map_accum

    • map_accum<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R], acc: T1, list: readonly T2[]): [T1, R[]]
    • map_accum<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R], acc: T1): (list: readonly T2[]) => [T1, R[]]
    • map_accum<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R]): { (acc: T1, list: readonly T2[]): [T1, R[]]; (acc: T1): (list: readonly T2[]) => [T1, R[]] }
    • description

      The mapAccum function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.also works with partial form.

      example
      function adder(acc: string, x: string): [string, number] {
      return [acc + x, parseInt(acc) + parseInt(x)];
      }
      F.map_accum(adder, '0', ['1', '2', '3', '4']); // ['01234',[1,3,15,127]]

      Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      • acc: T1
      • list: readonly T2[]

      Returns [T1, R[]]

      tuple containing accumulator, and new mapped array.

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      • acc: T1

      Returns (list: readonly T2[]) => [T1, R[]]

        • (list: readonly T2[]): [T1, R[]]
        • Parameters

          • list: readonly T2[]

          Returns [T1, R[]]

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      Returns { (acc: T1, list: readonly T2[]): [T1, R[]]; (acc: T1): (list: readonly T2[]) => [T1, R[]] }

        • (acc: T1, list: readonly T2[]): [T1, R[]]
        • (acc: T1): (list: readonly T2[]) => [T1, R[]]
        • Parameters

          • acc: T1
          • list: readonly T2[]

          Returns [T1, R[]]

        • Parameters

          • acc: T1

          Returns (list: readonly T2[]) => [T1, R[]]

            • (list: readonly T2[]): [T1, R[]]
            • Parameters

              • list: readonly T2[]

              Returns [T1, R[]]

    map_accum_right

    • map_accum_right<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R], acc: T1, list: readonly T2[]): [T1, R[]]
    • map_accum_right<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R], acc: T1): (list: readonly T2[]) => [T1, R[]]
    • map_accum_right<T1, T2, R>(fn: (acc: T1, val: T2) => [T1, R]): { (acc: T1, list: readonly T2[]): [T1, R[]]; (acc: T1): (list: readonly T2[]) => [T1, R[]] }
    • description

      he mapAccumRight function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from right to left, and returns a tuple containing a final value of this accumulator together with the new list.also works with partial form

      example
      function adder(acc: string, x: string): [string, number] {
      return [acc + x, parseInt(acc) + parseInt(x)];
      }
      F.map_accum_right(adder, '0', ['1', '2', '3', '4']); // ['04321',[433,45,7,4]]

      Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      • acc: T1
      • list: readonly T2[]

      Returns [T1, R[]]

      tuple containing accumulator, and new mapped array.

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      • acc: T1

      Returns (list: readonly T2[]) => [T1, R[]]

        • (list: readonly T2[]): [T1, R[]]
        • Parameters

          • list: readonly T2[]

          Returns [T1, R[]]

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (acc: T1, val: T2) => [T1, R]
          • (acc: T1, val: T2): [T1, R]
          • Parameters

            • acc: T1
            • val: T2

            Returns [T1, R]

      Returns { (acc: T1, list: readonly T2[]): [T1, R[]]; (acc: T1): (list: readonly T2[]) => [T1, R[]] }

        • (acc: T1, list: readonly T2[]): [T1, R[]]
        • (acc: T1): (list: readonly T2[]) => [T1, R[]]
        • Parameters

          • acc: T1
          • list: readonly T2[]

          Returns [T1, R[]]

        • Parameters

          • acc: T1

          Returns (list: readonly T2[]) => [T1, R[]]

            • (list: readonly T2[]): [T1, R[]]
            • Parameters

              • list: readonly T2[]

              Returns [T1, R[]]

    move

    • move<T>(from: number, to: number, list: T[]): T[]
    • move(from: number, to: number): <T>(list: T[]) => T[]
    • move(from: number): { <T>(to: number, list: T[]): T[]; (to: number): <T>(list: T[]) => T[] }
    • description

      Move an item, at index from, to index to, in a list of elements. A new list will be created containing the new elements order.

      example
      F.move(0,2,[0,1,2,3]) // [1,2,0,3]
      F.move(-1,0,[0,1,2,3]) // [3,0,1,2]
      F.move(0,-1,[0,1,2,3]) // [1,2,3,0]
      F.move(0,-5,[0,1,2,3]) // [0,1,2,3]
      F.move(-5,3,[0,1,2,3]) // [0,1,2,3]

      Type parameters

      • T

      Parameters

      • from: number
      • to: number
      • list: T[]

      Returns T[]

    • Parameters

      • from: number
      • to: number

      Returns <T>(list: T[]) => T[]

        • <T>(list: T[]): T[]
        • Type parameters

          • T

          Parameters

          • list: T[]

          Returns T[]

    • Parameters

      • from: number

      Returns { <T>(to: number, list: T[]): T[]; (to: number): <T>(list: T[]) => T[] }

        • <T>(to: number, list: T[]): T[]
        • (to: number): <T>(list: T[]) => T[]
        • Type parameters

          • T

          Parameters

          • to: number
          • list: T[]

          Returns T[]

        • Parameters

          • to: number

          Returns <T>(list: T[]) => T[]

            • <T>(list: T[]): T[]
            • Type parameters

              • T

              Parameters

              • list: T[]

              Returns T[]

    none

    • none<T>(fn: (arg: T) => boolean, arr: T[]): boolean
    • none<T>(fn: (arg: T) => boolean): (arr: T[]) => boolean
    • description

      returns true if predication function returns false for all the value of array, otherwise it returns false; also works with partial form.

      example
      function doneChecker(todo: Todo) {
      return todo.done === true;
      }
      F.none(doneChecker,[
      { id: 11, done: false },
      { id: 12, done: false },
      { id: 13, done: true },
      { id: 14, done: false },
      ]) // false

      F.none(doneChecker,[
      { id: 11, done: false },
      { id: 12, done: false },
      { id: 13, done: false },
      { id: 14, done: false },
      ]) // true

      Type parameters

      • T

      Parameters

      • fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      • arr: T[]

      Returns boolean

    • Type parameters

      • T

      Parameters

      • fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      Returns (arr: T[]) => boolean

        • (arr: T[]): boolean
        • Parameters

          • arr: T[]

          Returns boolean

    nth

    • nth<T>(n: number, xs: T): L.UnionOf<T> | undefined
    • nth<T>(n: number): (xs: T) => L.UnionOf<T> | undefined
    • nth(n: number, xs: string): string
    • nth(n: number): (xs: string) => string
    • description

      returns value of nth index of array or string.if you pass negative index it will convert to it's absolute value.

      example
      F.nth(1,[1,2,3,4]) // 2
      F.nth(-1,[1,2,3,4]) // 2
      F.nth(9,[1,2,3,4]) // undefined
      F.nth(2,"pranshu") // 'a'

      Type parameters

      • T: any[]

      Parameters

      • n: number
      • xs: T

      Returns L.UnionOf<T> | undefined

    • Type parameters

      • T: any[]

      Parameters

      • n: number

      Returns (xs: T) => L.UnionOf<T> | undefined

        • (xs: T): L.UnionOf<T> | undefined
        • Parameters

          • xs: T

          Returns L.UnionOf<T> | undefined

    • Parameters

      • n: number
      • xs: string

      Returns string

    • Parameters

      • n: number

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    of

    • of<T>(x: T): [T]
    • description

      returns an array containing value that was passed in function.

      example
      F.of(33) // [33]
      F.of("pranshu") // ["pranshu"]
      F.of({id:11,name:"pranshu"}) // [{id:11,name:"pranshu"}]

      Type parameters

      • T

      Parameters

      • x: T

      Returns [T]

    pair

    • pair<T1, T2>(fst: T1, snd: T2): [T1, T2]
    • pair<T1>(fst: T1): <T2>(snd: T2) => [T1, T2]
    • description

      takes couple argument and returns tuple of that arguments; also works with partial form.

      example
      F.pair("pranshu","shah") ["pranshu","shah"];
      F.pai({auth:true},{premium:false}) [{auth:true},{premium:false}]

      Type parameters

      • T1

      • T2

      Parameters

      • fst: T1
      • snd: T2

      Returns [T1, T2]

    • Type parameters

      • T1

      Parameters

      • fst: T1

      Returns <T2>(snd: T2) => [T1, T2]

        • <T2>(snd: T2): [T1, T2]
        • Type parameters

          • T2

          Parameters

          • snd: T2

          Returns [T1, T2]

    pluck

    • pluck<T>(key: keyof T, arr: readonly T[]): T[keyof T][]
    • pluck(key: string | number | symbol): <T>(arr: readonly T[]) => T[keyof T][]
    • description

      Returns a neuw list by plucking the same named property off all objects in the list supplied;also works with partial form.

      example
      F.pluck('name', [
      { id: 1, name: 'pranshu' },
      { id: 2, name: 'nisarg' },
      ]); // ["pranshu","nisarg"]

      Type parameters

      • T: Any_Obj

      Parameters

      • key: keyof T
      • arr: readonly T[]

      Returns T[keyof T][]

    • Parameters

      • key: string | number | symbol

      Returns <T>(arr: readonly T[]) => T[keyof T][]

        • <T>(arr: readonly T[]): T[keyof T][]
        • Type parameters

          • T

          Parameters

          • arr: readonly T[]

          Returns T[keyof T][]

    prepend

    • prepend<T>(el: T, arr: T[]): T[]
    • prepend<T>(el: T): (arr: T[]) => T[]
    • description

      takes an element and array.adds that element at the start of the array.it returns new copy of array;also works with partial form.

      example
      F.prepend(1,[2,3,4]) // [1,2,3,4]
      

      Type parameters

      • T

      Parameters

      • el: T
      • arr: T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • el: T

      Returns (arr: T[]) => T[]

        • (arr: T[]): T[]
        • Parameters

          • arr: T[]

          Returns T[]

    range

    • range(from: number, to: number): number[]
    • range(from: number): (to: number) => number[]
    • description

      returns an array of given range;if given number isNan or Infinity it throws array; also works in partial form.

      example
      F.range(3,6) // [3,4,5]
      F.range(1,Infinity) // throws error
      F.range(NaN,11) // throws error
      F.range(5,1) // []

      Parameters

      • from: number
      • to: number

      Returns number[]

    • Parameters

      • from: number

      Returns (to: number) => number[]

        • (to: number): number[]
        • Parameters

          • to: number

          Returns number[]

    reduce

    • reduce<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R, arr: readonly T[]): R
    • reduce<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R): (arr: readonly T[]) => R
    • reduce<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R): { (initialValue: R): (arr: readonly T[]) => R; (initialValue: R, arr: readonly T[]): R }
    • description

      same as https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce but does not skip deleted or unassigned indices (sparse arrays); also works in partial form.

      example
      F.reduce(F.add,0,[1,2,3]) // 6
      

      Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R
      • arr: readonly T[]

      Returns R

      accumulator

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R

      Returns (arr: readonly T[]) => R

        • (arr: readonly T[]): R
        • Parameters

          • arr: readonly T[]

          Returns R

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      Returns { (initialValue: R): (arr: readonly T[]) => R; (initialValue: R, arr: readonly T[]): R }

        • (initialValue: R): (arr: readonly T[]) => R
        • (initialValue: R, arr: readonly T[]): R
        • Parameters

          • initialValue: R

          Returns (arr: readonly T[]) => R

            • (arr: readonly T[]): R
            • Parameters

              • arr: readonly T[]

              Returns R

        • Parameters

          • initialValue: R
          • arr: readonly T[]

          Returns R

    reduce_right

    • reduce_right<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R, arr: readonly T[]): R
    • reduce_right<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R): (arr: readonly T[]) => R
    • reduce_right<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R): { (initialValue: R, arr: readonly T[]): R; (initialValue: R): (arr: readonly T[]) => R }
    • description

      same as F.reduce function but reduces the array right-left; also works in partial form.

      Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R
      • arr: readonly T[]

      Returns R

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R

      Returns (arr: readonly T[]) => R

        • (arr: readonly T[]): R
        • Parameters

          • arr: readonly T[]

          Returns R

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      Returns { (initialValue: R, arr: readonly T[]): R; (initialValue: R): (arr: readonly T[]) => R }

        • (initialValue: R, arr: readonly T[]): R
        • (initialValue: R): (arr: readonly T[]) => R
        • Parameters

          • initialValue: R
          • arr: readonly T[]

          Returns R

        • Parameters

          • initialValue: R

          Returns (arr: readonly T[]) => R

            • (arr: readonly T[]): R
            • Parameters

              • arr: readonly T[]

              Returns R

    remove

    • remove<T>(start: number, delete_count: number, arr: T[]): T[]
    • remove<T>(start: number, delete_count: number): (arr: T[]) => T[]
    • remove<T>(start: number): { (delete_count: number, arr: T[]): T[]; (delete_count: number): (arr: T[]) => T[] }
    • description

      same as Array.prototype.splice but does not mutate original array and returns new copy.also works in partial form.

      example
      F.remove(3,2,[1, 2, 3, 4, 5, 6]) // [1,2,3,6]
      

      Type parameters

      • T

      Parameters

      • start: number
      • delete_count: number
      • arr: T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • start: number
      • delete_count: number

      Returns (arr: T[]) => T[]

        • (arr: T[]): T[]
        • Parameters

          • arr: T[]

          Returns T[]

    • Type parameters

      • T

      Parameters

      • start: number

      Returns { (delete_count: number, arr: T[]): T[]; (delete_count: number): (arr: T[]) => T[] }

        • (delete_count: number, arr: T[]): T[]
        • (delete_count: number): (arr: T[]) => T[]
        • Parameters

          • delete_count: number
          • arr: T[]

          Returns T[]

        • Parameters

          • delete_count: number

          Returns (arr: T[]) => T[]

            • (arr: T[]): T[]
            • Parameters

              • arr: T[]

              Returns T[]

    repeat

    • repeat<T>(value: T, n: number): T[]
    • repeat<T>(value: T): (n: number) => T[]
    • description

      takes and value you want to repeat and how many times you want to repeat and returns an array that contains given repeating given number.also works in partial form.

      example
      F.repeat({ id: 1, name: 'pranshu' },3) [{ id: 1, name: 'pranshu' },{ id: 1, name: 'pranshu' },{ id: 1, name: 'pranshu' }]
      

      Type parameters

      • T

      Parameters

      • value: T
      • n: number

      Returns T[]

    • Type parameters

      • T

      Parameters

      • value: T

      Returns (n: number) => T[]

        • (n: number): T[]
        • Parameters

          • n: number

          Returns T[]

    reverse

    • reverse<T>(xs: T[]): T[]
    • reverse(xs: string): string
    • description

      Reverses given string or array.

      example
      F.reverse([1,2,3,4]) // [4,3,2,1]
      F.reverse("mit") // "tim"

      Type parameters

      • T

      Parameters

      • xs: T[]

      Returns T[]

    • Parameters

      • xs: string

      Returns string

    scan

    • scan<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R, arr: readonly T[]): R[]
    • scan<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R): { (initialValue: R, arr: readonly T[]): R[]; (initialValue: R): (arr: readonly T[]) => R[] }
    • scan<T, R>(reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R, initialValue: R): (arr: readonly T[]) => R[]
    • description

      same as F.reducer but returns acc at every point; also works with partial form.

      example
      function stringCombiner(acc: string, element: string) {
      return acc + element;
      }
      F.scan(stringCombiner, '', ['0', '1', '2', '3']); // ['','0','01','012','0123']

      Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R
      • arr: readonly T[]

      Returns R[]

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      Returns { (initialValue: R, arr: readonly T[]): R[]; (initialValue: R): (arr: readonly T[]) => R[] }

        • (initialValue: R, arr: readonly T[]): R[]
        • (initialValue: R): (arr: readonly T[]) => R[]
        • Parameters

          • initialValue: R
          • arr: readonly T[]

          Returns R[]

        • Parameters

          • initialValue: R

          Returns (arr: readonly T[]) => R[]

            • (arr: readonly T[]): R[]
            • Parameters

              • arr: readonly T[]

              Returns R[]

    • Type parameters

      • T

      • R

      Parameters

      • reducer_fn: (acc: R, element: T, index?: number, arr?: readonly T[]) => R
          • (acc: R, element: T, index?: number, arr?: readonly T[]): R
          • Parameters

            • acc: R
            • element: T
            • Optional index: number
            • Optional arr: readonly T[]

            Returns R

      • initialValue: R

      Returns (arr: readonly T[]) => R[]

        • (arr: readonly T[]): R[]
        • Parameters

          • arr: readonly T[]

          Returns R[]

    slice

    • slice<T>(from_index: number, to_index: number, xs: T): T
    • slice(from_index: number, to_index: number, xs: string): string
    • slice(from_index: number, to_index: number): { <T>(xs: T): T; (xs: string): string }
    • slice(from_index: number): { <T>(to_index: number, xs: T): T; (to_index: number): <T>(xs: T) => T; (to_index: number, xs: string): string; (to_index: number): (xs: string) => string }
    • description

      wrapper around Array.prototype.slice() . also works with partial form.

      example
      F.slice(1,4,[1,2,3,4,5,6]) // [2,3,4]
      

      Type parameters

      • T: readonly any[]

      Parameters

      • from_index: number
      • to_index: number
      • xs: T

      Returns T

    • Parameters

      • from_index: number
      • to_index: number
      • xs: string

      Returns string

    • Parameters

      • from_index: number
      • to_index: number

      Returns { <T>(xs: T): T; (xs: string): string }

        • <T>(xs: T): T
        • (xs: string): string
        • Type parameters

          • T: readonly any[]

          Parameters

          • xs: T

          Returns T

        • Parameters

          • xs: string

          Returns string

    • Parameters

      • from_index: number

      Returns { <T>(to_index: number, xs: T): T; (to_index: number): <T>(xs: T) => T; (to_index: number, xs: string): string; (to_index: number): (xs: string) => string }

        • <T>(to_index: number, xs: T): T
        • (to_index: number): <T>(xs: T) => T
        • (to_index: number, xs: string): string
        • (to_index: number): (xs: string) => string
        • Type parameters

          • T: readonly any[]

          Parameters

          • to_index: number
          • xs: T

          Returns T

        • Parameters

          • to_index: number

          Returns <T>(xs: T) => T

            • <T>(xs: T): T
            • Type parameters

              • T: readonly any[]

              Parameters

              • xs: T

              Returns T

        • Parameters

          • to_index: number
          • xs: string

          Returns string

        • Parameters

          • to_index: number

          Returns (xs: string) => string

            • (xs: string): string
            • Parameters

              • xs: string

              Returns string

    split_at

    • split_at<T>(index: number, xs: T): T[]
    • split_at(index: number): { <T>(xs: T): T[]; (xs: string): string[] }
    • split_at(index: number, xs: string): string[]
    • description

      Splits a given list or string at a given index; also works with partial form.

      example
      F.split_at(3,[1,2,3,4,5,6,7,8,9]) // [[1,2,3],[4,5,6,7,8,9]]
      F.split_at(3, 'pranshu'); // ["pra","nshu"]

      Type parameters

      • T: readonly any[]

      Parameters

      • index: number
      • xs: T

      Returns T[]

    • Parameters

      • index: number

      Returns { <T>(xs: T): T[]; (xs: string): string[] }

        • <T>(xs: T): T[]
        • (xs: string): string[]
        • Type parameters

          • T: readonly any[]

          Parameters

          • xs: T

          Returns T[]

        • Parameters

          • xs: string

          Returns string[]

    • Parameters

      • index: number
      • xs: string

      Returns string[]

    split_every

    • split_every<T>(n: number, list: readonly T[]): T[][]
    • split_every<T>(n: number): { (list: readonly T[]): T[][]; (list: string): string[] }
    • split_every(n: number, list: string): string[]
    • description

      Splits a collection into slices of the specified length; also works with partial form.

      example
      F.split_every(3,[1,2,3,4,5,6,7,8]) // [[1,2,3],[4,5,6],[7,8]]
      F.split_every(3,"pranshu") // ["pra","nsh","u"]

      Type parameters

      • T

      Parameters

      • n: number
      • list: readonly T[]

      Returns T[][]

    • Type parameters

      • T

      Parameters

      • n: number

      Returns { (list: readonly T[]): T[][]; (list: string): string[] }

        • (list: readonly T[]): T[][]
        • (list: string): string[]
        • Parameters

          • list: readonly T[]

          Returns T[][]

        • Parameters

          • list: string

          Returns string[]

    • Parameters

      • n: number
      • list: string

      Returns string[]

    split_when

    • split_when<T>(pred_fn: (arg: T) => boolean, list: readonly T[]): T[][]
    • split_when<T>(pred_fn: (arg: T) => boolean): (list: readonly T[]) => T[][]
    • Takes an array and a predication function and splits the array when predication function reuturns true; also works with partial form.

      example
      F.split_when(F.gt(5),[11, 2, 3, 6, 1, 4, 8, 3]) // [[11],[2,3,6],[1,4,8],[3]]
      

      Type parameters

      • T

      Parameters

      • pred_fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      • list: readonly T[]

      Returns T[][]

    • Type parameters

      • T

      Parameters

      • pred_fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      Returns (list: readonly T[]) => T[][]

        • (list: readonly T[]): T[][]
        • Parameters

          • list: readonly T[]

          Returns T[][]

    starts_with

    • starts_with<T>(prefix: T, xs: T): boolean
    • starts_with<T>(prefix: T): (xs: T) => boolean
    • starts_with(prefix: string, xs: string): boolean
    • starts_with(prefix: string): (xs: string) => boolean
    • description

      checks if given array has prefix we passed, also works with partial form.

      example
      F.starts_with([1,2],[1,2,3,5]) // true
      F.starts_with([1,2,4],[1,2,3,5]) // false
      F.starts_with("pra","pranshu") // true
      F.starts_with("pa","pranshu") // false

      Type parameters

      • T: readonly any[]

      Parameters

      • prefix: T
      • xs: T

      Returns boolean

    • Type parameters

      • T: readonly any[]

      Parameters

      • prefix: T

      Returns (xs: T) => boolean

        • (xs: T): boolean
        • Parameters

          • xs: T

          Returns boolean

    • Parameters

      • prefix: string
      • xs: string

      Returns boolean

    • Parameters

      • prefix: string

      Returns (xs: string) => boolean

        • (xs: string): boolean
        • Parameters

          • xs: string

          Returns boolean

    take

    • take<T>(number_of_elements_you_want: number, xs: T): T
    • take(number_of_elements_you_want: number, xs: string): string
    • take(number_of_elements_you_want: number): { <T>(xs: T): T; (xs: string): string }
    • example
      F.take(3,[1,2,3,4,5,6]) // [1,2,3]
      F.take(3,"pranshu") // "pra"

      Type parameters

      • T: readonly any[]

      Parameters

      • number_of_elements_you_want: number
      • xs: T

      Returns T

      first n elements an array of from front.

    • Parameters

      • number_of_elements_you_want: number
      • xs: string

      Returns string

    • Parameters

      • number_of_elements_you_want: number

      Returns { <T>(xs: T): T; (xs: string): string }

        • <T>(xs: T): T
        • (xs: string): string
        • Type parameters

          • T: readonly any[]

          Parameters

          • xs: T

          Returns T

        • Parameters

          • xs: string

          Returns string

    take_last

    • take_last<T>(number_elements_you_want_from_behind: number, xs: T): T
    • take_last<T>(number_elements_you_want_from_behind: number, xs: string): string
    • take_last(number_elements_you_want_from_behind: number): { <T>(xs: T): T; (xs: string): string }
    • description

      returns a new list with n numbers from behind.

      example
      F.take_last(3,[1,2,3,4,5]) // [3,4,5]
      F.take_last(3,"pranshu") // "shu"

      Type parameters

      • T: any[]

      Parameters

      • number_elements_you_want_from_behind: number
      • xs: T

      Returns T

    • Type parameters

      • T

      Parameters

      • number_elements_you_want_from_behind: number
      • xs: string

      Returns string

    • Parameters

      • number_elements_you_want_from_behind: number

      Returns { <T>(xs: T): T; (xs: string): string }

        • <T>(xs: T): T
        • (xs: string): string
        • Type parameters

          • T: any[]

          Parameters

          • xs: T

          Returns T

        • Parameters

          • xs: string

          Returns string

    take_while

    • take_while<T>(predicate_fn: (arg: T) => boolean, xs: T[]): T[]
    • take_while(predicate_fn: (arg: string) => boolean, xs: string): string
    • take_while(predicate_fn: (arg: string) => boolean): (xs: string) => string
    • take_while<T>(predicate_fn: (arg: T) => boolean): (xs: T[]) => T[]
    • description

      takes a function and an array returns new array containing values from given array from start till predication function returns false.

      Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      • xs: T[]

      Returns T[]

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      • xs: string

      Returns string

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    • Type parameters

      • T

      Parameters

      • predicate_fn: (arg: T) => boolean
          • (arg: T): boolean
          • Parameters

            • arg: T

            Returns boolean

      Returns (xs: T[]) => T[]

        • (xs: T[]): T[]
        • Parameters

          • xs: T[]

          Returns T[]

    take_while_last

    • take_while_last<T>(predicate_fn: (arg: UnionOf<T>) => boolean, xs: T): T
    • take_while_last<T>(predicate_fn: (arg: UnionOf<T>) => boolean): (xs: T) => T
    • take_while_last(predicate_fn: (arg: string) => boolean, xs: string): string
    • take_while_last(predicate_fn: (arg: string) => boolean): (xs: string) => string
    • description

      takes predication funtion and array and returns new array containg values from behind from given array while predication function returns true.

      Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      • xs: T

      Returns T

    • Type parameters

      • T: any[]

      Parameters

      • predicate_fn: (arg: UnionOf<T>) => boolean
          • (arg: UnionOf<T>): boolean
          • Parameters

            • arg: UnionOf<T>

            Returns boolean

      Returns (xs: T) => T

        • (xs: T): T
        • Parameters

          • xs: T

          Returns T

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      • xs: string

      Returns string

    • Parameters

      • predicate_fn: (arg: string) => boolean
          • (arg: string): boolean
          • Parameters

            • arg: string

            Returns boolean

      Returns (xs: string) => string

        • (xs: string): string
        • Parameters

          • xs: string

          Returns string

    tap

    • tap<T>(fn: (arg: T) => any, x: T): T
    • tap<T>(fn: (arg: T) => any): (x: T) => T
    • description

      takes a function and its argument. it calls given function and returns the argument.

      example
      let number = 1;

      function logger(x: number) {
      number = number + x;
      }
      F.tap(logger,3) // returns 3 , number === 4

      Type parameters

      • T

      Parameters

      • fn: (arg: T) => any
          • (arg: T): any
          • Parameters

            • arg: T

            Returns any

      • x: T

      Returns T

    • Type parameters

      • T

      Parameters

      • fn: (arg: T) => any
          • (arg: T): any
          • Parameters

            • arg: T

            Returns any

      Returns (x: T) => T

        • (x: T): T
        • Parameters

          • x: T

          Returns T

    union

    • union<T>(x1: T, x2: T): T
    • union<T>(x1: T): (x2: T) => T
    • description

      it returns unioun of given two arrays.

      example
      F.union([{ id: 1, name: 'pranshu' },{ id: 2, name: 'mit' },{ id: 3, name: 'sanket' }],
      [{ id: 1, name: 'pranshu' },{ id: 5, name: 'harsh' }]);
      // [{ id: 1, name: 'pranshu' },{ id: 2, name: 'mit' },{ id: 3, name: 'sanket' },{ id: 5, name: 'harsh' }]

      Type parameters

      • T: any[]

      Parameters

      • x1: T
      • x2: T

      Returns T

    • Type parameters

      • T: any[]

      Parameters

      • x1: T

      Returns (x2: T) => T

        • (x2: T): T
        • Parameters

          • x2: T

          Returns T

    uniq_by

    • uniq_by<T, U>(fn: (arg: T) => U, arr: readonly T[]): T[]
    • uniq_by<T, U>(fn: (arg: T) => U): (arr: readonly T[]) => T[]
    • description

      takes a function and an array. returns an array that contains the return value of the function that takes element of an array as an argument.

      example
      type Name = {
      id: string;
      name: string;
      };
      function nameGetter(x: Name) {
      return x.name;
      }
      F.uniq_by(nameGetter, [
      { id: '1', name: 'pranshu' },
      { id: '1', name: 'mit' },
      { id: '1', name: 'pranshu' },
      { id: '1', name: 'smit' },
      ]); // ["pranshu","mit","smit"]

      Type parameters

      • T

      • U

      Parameters

      • fn: (arg: T) => U
          • (arg: T): U
          • Parameters

            • arg: T

            Returns U

      • arr: readonly T[]

      Returns T[]

    • Type parameters

      • T

      • U

      Parameters

      • fn: (arg: T) => U
          • (arg: T): U
          • Parameters

            • arg: T

            Returns U

      Returns (arr: readonly T[]) => T[]

        • (arr: readonly T[]): T[]
        • Parameters

          • arr: readonly T[]

          Returns T[]

    unique

    • unique<T>(arr: T[]): T[]
    • description

      returns unique value of array.it uses F.equals for equality.

      example
      F.unique([{ id: 1, name: 'pranshu' },{ id: 2, name: 'mit' },{ id: 1, name: 'pranshu' }]);
      // [{ id: 1, name: 'pranshu' },{ id: 2, name: 'mit' }]

      Type parameters

      • T

      Parameters

      • arr: T[]

      Returns T[]

    unnest

    • unnest<T>(arr: T[]): (T extends readonly InnerArr[] ? InnerArr : T)[]
    • description

      flattens given array once.

      example
      F.unnest([
      [1, 2],
      [3, 4],
      [5, 6],
      ]); // [1,2,3,4,5,6]

      Type parameters

      • T

      Parameters

      • arr: T[]

      Returns (T extends readonly InnerArr[] ? InnerArr : T)[]

    update

    • update<T>(n: number, el: T, elements: readonly T[]): T[]
    • update<T>(n: number, el: T): (elements: readonly T[]) => T[]
    • update(n: number): { <T>(el: T, elements: readonly T[]): T[]; <T>(el: T): (elements: readonly T[]) => T[] }
    • description

      updates given array at given index with given element and returns new copy of array.

      example
      F.update(2,23,[1,2,3,4,5]) // [1,2,23,4,5]
      F.update(-1,23,[1,2,3,4,5]) // [1,2,3,4,23]
      F.update(NaN,23,[1,2,3,4,5]) // [1,2,3,4,23]
      F.update(9,23,[1,2,3,4,5]) // [1,2,3,4,23]

      Type parameters

      • T

      Parameters

      • n: number
      • el: T
      • elements: readonly T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • n: number
      • el: T

      Returns (elements: readonly T[]) => T[]

        • (elements: readonly T[]): T[]
        • Parameters

          • elements: readonly T[]

          Returns T[]

    • Parameters

      • n: number

      Returns { <T>(el: T, elements: readonly T[]): T[]; <T>(el: T): (elements: readonly T[]) => T[] }

        • <T>(el: T, elements: readonly T[]): T[]
        • <T>(el: T): (elements: readonly T[]) => T[]
        • Type parameters

          • T

          Parameters

          • el: T
          • elements: readonly T[]

          Returns T[]

        • Type parameters

          • T

          Parameters

          • el: T

          Returns (elements: readonly T[]) => T[]

            • (elements: readonly T[]): T[]
            • Parameters

              • elements: readonly T[]

              Returns T[]

    where

    • where<T>(matcher: Partial<T>, list: T[]): T[]
    • where<T>(matcher: T): (list: Partial<T>[] | Record<string | number, any>) => T[]
    • description

      Looks through each value in the array, returning an array of all the values that matches the key-value pairs listed in matcher.

      example
      F. where({ name: "mit" }, [
      { id: 11, name: 'pranshu' },
      { id: 12, name: 'mit' },
      { id: 13, name: 'sanket patel' },
      { id: 14, name: "mit" },
      ]); // [{ id: 12, name: 'mit' },{ id: 14, name: "mit" },]

      Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: Partial<T>
      • list: T[]

      Returns T[]

    • Type parameters

      • T: Record<string | number, any>

      Parameters

      • matcher: T

      Returns (list: Partial<T>[] | Record<string | number, any>) => T[]

        • (list: Partial<T>[] | Record<string | number, any>): T[]
        • Parameters

          • list: Partial<T>[] | Record<string | number, any>

          Returns T[]

    without

    • without<T>(removal_list: T[], list: T[]): T[]
    • without<T>(removal_list: T[]): (list: T[]) => T[]
    • description

      takes removal_list and list and removes every elements that is in removal_list.

      example
      F.without([1,2,3],[1,2,3,4,5,6]) // [4,5,6]
      

      Type parameters

      • T

      Parameters

      • removal_list: T[]
      • list: T[]

      Returns T[]

    • Type parameters

      • T

      Parameters

      • removal_list: T[]

      Returns (list: T[]) => T[]

        • (list: T[]): T[]
        • Parameters

          • list: T[]

          Returns T[]

    zip

    • zip<T, G>(arr1: T[], arr2: G[]): [T, G][]
    • zip<T>(arr1: T[]): <G>(arr2: G[]) => [T, G][]
    • description

      Creates a new list out of the two supplied by pairing up equally-positioned items from both lists. The returned list is truncated to the length of the shorter of the two input lists.

      example
      F.zip(['1', '2', '3'], [1, 2, 3]) // [['1',1],['2',2],['3',3]]
      

      Type parameters

      • T

      • G

      Parameters

      • arr1: T[]
      • arr2: G[]

      Returns [T, G][]

    • Type parameters

      • T

      Parameters

      • arr1: T[]

      Returns <G>(arr2: G[]) => [T, G][]

        • <G>(arr2: G[]): [T, G][]
        • Type parameters

          • G

          Parameters

          • arr2: G[]

          Returns [T, G][]

    zip_obj

    • zip_obj<T>(keys: (string | number)[], values: T[]): Record<string | number, T>
    • zip_obj(keys: (string | number)[]): <T>(values: T[]) => Record<string | number, T>
    • description

      takes an array of keys and values and makes object out of it.

      example
      zip_obj(['id', 'name'], [11, 'pranshu shah']) // {"id":11,"name":"pranshu shah"}
      

      Type parameters

      • T

      Parameters

      • keys: (string | number)[]
      • values: T[]

      Returns Record<string | number, T>

    • Parameters

      • keys: (string | number)[]

      Returns <T>(values: T[]) => Record<string | number, T>

        • <T>(values: T[]): Record<string | number, T>
        • Type parameters

          • T

          Parameters

          • values: T[]

          Returns Record<string | number, T>

    zip_with

    • zip_with<T1, T2, R>(fn: (arg1: T1, arg2: T2) => R, list1: T1[], list2: T2[]): R[]
    • zip_with<T1, T2, R>(fn: (arg1: T1, arg2: T2) => R, list1: T1[]): (list2: T2[]) => R[]
    • zip_with<T1, T2, R>(fn: (arg1: T1, arg2: T2) => R): { (list1: T1[], list2: T2[]): R[]; (list1: T1[]): (list2: T2[]) => R[] }
    • description

      Creates a new list out of the two supplied by applying the function to each equally-positioned pair in the lists. The returned list is truncated to the length of the shorter of the two input lists.

      example
      function concate(x: number, y: string) {
      return x + y;
      }
      F.zip_with(concate, [1, 2, 3, 4], ['1', '2']); // ['11','22']

      Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (arg1: T1, arg2: T2) => R
          • (arg1: T1, arg2: T2): R
          • Parameters

            • arg1: T1
            • arg2: T2

            Returns R

      • list1: T1[]
      • list2: T2[]

      Returns R[]

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (arg1: T1, arg2: T2) => R
          • (arg1: T1, arg2: T2): R
          • Parameters

            • arg1: T1
            • arg2: T2

            Returns R

      • list1: T1[]

      Returns (list2: T2[]) => R[]

        • (list2: T2[]): R[]
        • Parameters

          • list2: T2[]

          Returns R[]

    • Type parameters

      • T1

      • T2

      • R

      Parameters

      • fn: (arg1: T1, arg2: T2) => R
          • (arg1: T1, arg2: T2): R
          • Parameters

            • arg1: T1
            • arg2: T2

            Returns R

      Returns { (list1: T1[], list2: T2[]): R[]; (list1: T1[]): (list2: T2[]) => R[] }

        • (list1: T1[], list2: T2[]): R[]
        • (list1: T1[]): (list2: T2[]) => R[]
        • Parameters

          • list1: T1[]
          • list2: T2[]

          Returns R[]

        • Parameters

          • list1: T1[]

          Returns (list2: T2[]) => R[]

            • (list2: T2[]): R[]
            • Parameters

              • list2: T2[]

              Returns R[]

    List ```typescript F.includes("pranshu",["pranshu","mit","saumya"]) // true F.includes({id:1,name:"pranshu"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // true F.includes({id:1,name:"saumya"},[{id:1,name:"pranshu"},{id:2,name:"mit"},{id:3,name:"sanket"}]) // false ``` Functions

    includes

    • includes<T>(target: T, source: T[]): boolean
    • includes<T>(target: T): (source: T[]) => boolean
    • description

      it checks whether given element is in array or not. it uses F.equals,also works with partial form.

      Type parameters

      • T = any

      Parameters

      • target: T
      • source: T[]

      Returns boolean

    • Type parameters

      • T = any

      Parameters

      • target: T

      Returns (source: T[]) => boolean

        • (source: T[]): boolean
        • Parameters

          • source: T[]

          Returns boolean

    Logic Functions

    all_pass

    • all_pass<T>(preds: Pred<T>[]): (...args: T) => boolean
    • description

      it takes list of predication function and returns the functions that takes arguments for predication function.if you call the return function it returns true if all predication function returns true otherwise it returns false

      example
        all_pass([F.gt(0), F.lt(100)])(33); // true
      all_pass([F.lt(11)])(12) //false

      Type parameters

      • T: any[]

      Parameters

      • preds: Pred<T>[]

      Returns (...args: T) => boolean

      returns a function that takes arguments for list of predication functions.

        • (...args: T): boolean
        • Parameters

          • Rest ...args: T

          Returns boolean

    any_pass

    • any_pass<Args>(preds: Pred<Args>[]): (...args: Args) => boolean
    • description

      it takes list of predication function and returns the functions that takes arguments for predication function.if you call the return function it returns true if any predication function returns true otherwise it returns false

      example
      F.any_pass([F.lt(33),F.gt(20)])(30) // true;
      F.any_pass([F.lt(33),F.gt(20)])(35) // true;
      F.any_pass([F.lt(33),F.gt(35)])(34) // false;

      Type parameters

      • Args: any[]

      Parameters

      • preds: Pred<Args>[]

      Returns (...args: Args) => boolean

      returns a function that takes arguments for list of predication functions.

        • (...args: Args): boolean
        • Parameters

          • Rest ...args: Args

          Returns boolean

    both

    • both<T>(fn1: Pred<T>, fn2: Pred<T>): (...args: T) => boolean
    • both<T>(fn1: Pred<T>): (fn2: Pred<T>) => (...args: T) => boolean
    • description

      takes couple of function and returns function that takes arguments for that function and if call returned function it returns true if both function returns true otherwise returns false. also works in partial style

      example
      F.both(F.lt(30),F.gt(20))(25) // true
      F.both(F.lt(30),F.gt(20))(15) // false

      Type parameters

      • T: any[]

      Parameters

      • fn1: Pred<T>
      • fn2: Pred<T>

      Returns (...args: T) => boolean

        • (...args: T): boolean
        • Parameters

          • Rest ...args: T

          Returns boolean

    • Type parameters

      • T: any[]

      Parameters

      • fn1: Pred<T>

      Returns (fn2: Pred<T>) => (...args: T) => boolean

        • (fn2: Pred<T>): (...args: T) => boolean
        • Parameters

          • fn2: Pred<T>

          Returns (...args: T) => boolean

            • (...args: T): boolean
            • Parameters

              • Rest ...args: T

              Returns boolean

    complement

    • complement<T>(fn: T): (...args: OvarloadedParameters<T>) => boolean
    • description

      takes an function that returns boolean and returns function that will take the arguments for function we pass as argument and when we call that function it will return complement of function we passed in argument

      example
      let invertedLessThan30 =  F.complement(F.lt(30));
      invertedLessThan30(25) // false

      Type parameters

      • T: (...args: any[]) => boolean

      Parameters

      • fn: T

      Returns (...args: OvarloadedParameters<T>) => boolean

        • (...args: OvarloadedParameters<T>): boolean
        • Parameters

          • Rest ...args: OvarloadedParameters<T>

          Returns boolean

    eq_by

    • eq_by<T>(fn: (x: T) => any, x1: T, x2: T): boolean
    • eq_by<T>(fn: (x: T) => any, x1: T): (x2: T) => boolean
    • eq_by<T>(fn: (x: T) => boolean): { (x1: T, x2: T): boolean; (x1: T): (x2: T) => boolean }
    • description

      takes predicate function fn and 2 elements.returns true if fn(x1) === fn(x2) otherwise false. it uses F.equals to compare. it also works with partial arguments.

      example
      let gt10 = gt(10);
      F.eq_by(gt10,31,22); // true
      F.eq_by(gt10,31,5) // false

      Type parameters

      • T

      Parameters

      • fn: (x: T) => any
          • (x: T): any
          • Parameters

            • x: T

            Returns any

      • x1: T
      • x2: T

      Returns boolean

    • Type parameters

      • T

      Parameters

      • fn: (x: T) => any
          • (x: T): any
          • Parameters

            • x: T

            Returns any

      • x1: T

      Returns (x2: T) => boolean

        • (x2: T): boolean
        • Parameters

          • x2: T

          Returns boolean

    • Type parameters

      • T

      Parameters

      • fn: (x: T) => boolean
          • (x: T): boolean
          • Parameters

            • x: T

            Returns boolean

      Returns { (x1: T, x2: T): boolean; (x1: T): (x2: T) => boolean }

        • (x1: T, x2: T): boolean
        • (x1: T): (x2: T) => boolean
        • Parameters

          • x1: T
          • x2: T

          Returns boolean

        • Parameters

          • x1: T

          Returns (x2: T) => boolean

            • (x2: T): boolean
            • Parameters

              • x2: T

              Returns boolean

    gt

    • gt(x1: number, x2: number): boolean
    • gt(x2: number): (x1: number) => boolean
    • description

      takes two number returns whether second number is greater than first number, also work with partial form

      example
      F.gt(20,23) // true
      let isGreaterThan20= F.gt(20)
      isGreaterThan20(15) // false
      isGreaterThan20(25) // true

      Parameters

      • x1: number
      • x2: number

      Returns boolean

    • Parameters

      • x2: number

      Returns (x1: number) => boolean

        • (x1: number): boolean
        • Parameters

          • x1: number

          Returns boolean

    gte

    • gte(x2: number, x1: number): boolean
    • gte(x2: number): (x1: number) => boolean
    • description

      takes two number returns whether second number is greater or equal to first number,also work with partial form

      example
      F.gte(20,23) // true
      let isGreaterThanOrEqualTo20= F.gte(20)
      isGreaterThanOrEqualTo20(15) // false
      isGreaterThanOrEqualTo20(20) // true
      isGreaterThanOrEqualTo20(33) // true

      Parameters

      • x2: number
      • x1: number

      Returns boolean

    • Parameters

      • x2: number

      Returns (x1: number) => boolean

        • (x1: number): boolean
        • Parameters

          • x1: number

          Returns boolean

    identical

    • identical(x1: any, x2: any): boolean
    • identical(x1: any): (x2: any) => boolean
    • description

      takes two elements and checks whether both of them are equal or not. it uses Object.is to check equality,also works with partial form

      example
      F.identical(33,33) //true
      let obj = {id:1,name:"pranshu"};
      F.identical(obj,obj) //true
      F.identical({id:1,name:"pranshu"},{id:1,name:"pranshu"}) // false

      Parameters

      • x1: any
      • x2: any

      Returns boolean

    • Parameters

      • x1: any

      Returns (x2: any) => boolean

        • (x2: any): boolean
        • Parameters

          • x2: any

          Returns boolean

    lt

    • lt(x2: number, x1: number): boolean
    • lt(x2: number): (x1: number) => boolean
    • description

      takes two number and checks whether second number is less than first number, also works with partial form.

      example
      F.lt(33,23) // true
      let lessThan20 = F.lt(20);
      lessThan20(33) // false
      lessThan20(12) // true

      Parameters

      • x2: number
      • x1: number

      Returns boolean

    • Parameters

      • x2: number

      Returns (x1: number) => boolean

        • (x1: number): boolean
        • Parameters

          • x1: number

          Returns boolean

    lte

    • lte(x2: number, x1: number): boolean
    • lte(x2: number): (x1: number) => boolean
    • description

      takes two number and checks whether second number is less than first number, also works with partial form.

      example
      F.lte(33,23) // true
      let lessThanOrEqual20 = F.lte(20);
      lessThanOrEqual20(33) // false
      lessThanOrEqual20(12) // true
      lessThanOrEqual20(20) // true

      Parameters

      • x2: number
      • x1: number

      Returns boolean

    • Parameters

      • x2: number

      Returns (x1: number) => boolean

        • (x1: number): boolean
        • Parameters

          • x1: number

          Returns boolean

    Math Functions

    add

    • add(x: number): (y: number) => number
    • add(x: number, y: number): number
    • description

      takes two number and adds them.also works in partial form.

      example
      F.add(2,3) // 5;
      let addToFive = F.add(5);
      addToFive(6) // 11;

      Parameters

      • x: number

      Returns (y: number) => number

        • (y: number): number
        • Parameters

          • y: number

          Returns number

    • Parameters

      • x: number
      • y: number

      Returns number

    dec

    • dec(x: number): number
    • description

      decrements given number.

      example
      F.dec(3) // 2;
      

      Parameters

      • x: number

      Returns number

    divide

    • divide(y: number, x: number): number
    • divide(y: number): (x: number) => number
    • description

      takes two number and divides second number by first number.also works in partial form.

      example
      F.divide(2,6) // 3;
      let divideBy3 = F.divide(3);
      divideBy3(27) // 9

      Parameters

      • y: number
      • x: number

      Returns number

    • Parameters

      • y: number

      Returns (x: number) => number

        • (x: number): number
        • Parameters

          • x: number

          Returns number

    equals

    • equals(y: any, x: any): boolean
    • equals(y: any): (x: any) => boolean
    • description

      compares two element. it uses deep equality to check two elements.also works in partial form.

      example

      F.equals("pranshu","pranshu") // true; F.equals({id:1,name:"pranshu"},{id:1,name:"pranshu"}) // true

      Parameters

      • y: any
      • x: any

      Returns boolean

    • Parameters

      • y: any

      Returns (x: any) => boolean

        • (x: any): boolean
        • Parameters

          • x: any

          Returns boolean

    inc

    • inc(x: number): number
    • description

      increments given number by one.

      example

      F.inc(5) // 6;

      Parameters

      • x: number

      Returns number

    mean

    • mean(x: number[]): number
    • description

      takes array of numbers returns mean of that array.

      example
      F.mean([10, 2, 38, 23, 38, 23, 21]) // 22.14
      

      Parameters

      • x: number[]

      Returns number

    median

    • median(list: number[]): number
    • description

      takes an array of number and returns median of it.

      example
      F.median([10, 2, 38, 23, 38, 23, 21]) // 23
      

      Parameters

      • list: number[]

      Returns number

    mod

    • mod(y: number, x: number): number
    • mod(y: number): (x: number) => number
    • description

      takes two number y and x returns x%y.also works in partial form.

      example
      F.mod(2,6) // 0
      let modOf2 = F.mod(2);
      modOf2(12) // 0

      Parameters

      • y: number
      • x: number

      Returns number

    • Parameters

      • y: number

      Returns (x: number) => number

        • (x: number): number
        • Parameters

          • x: number

          Returns number

    multiply

    • multiply(x: number, y: number): number
    • multiply(x: number): (y: number) => number
    • description

      mulitplies two number.also works in partial form.

      example
      F.multiply(2,3) // 6
      

      Parameters

      • x: number
      • y: number

      Returns number

    • Parameters

      • x: number

      Returns (y: number) => number

        • (y: number): number
        • Parameters

          • y: number

          Returns number

    negate

    • negate(x: number): number
    • description

      returns negation of given number.

      example
      F.negate(33) // -33
      F.negate(-21) // 21

      Parameters

      • x: number

      Returns number

    subtract

    • subtract(y: number): (x: number) => number
    • subtract(y: number, x: number): number
    • description

      takes two numbers, y and x. returns x - y.also works in partial form.

      example

      F.subtract(1,4) // 3;

      Parameters

      • y: number

      Returns (x: number) => number

        • (x: number): number
        • Parameters

          • x: number

          Returns number

    • Parameters

      • y: number
      • x: number

      Returns number

    sum

    • sum(x: number[]): number
    • description

      takes number of array returns sum of the array.

      example
      F.sum([1,2,3]) // 6
      

      Parameters

      • x: number[]

      Returns number

    Object Functions

    assoc

    • assoc<T, U, K>(prop: K, val: T, obj: U): Record<K, T> & U
    • assoc<T, U, K>(prop: K, val: T): (obj: U) => Record<K, T> & U
    • assoc<K>(prop: K): { <T, U>(val: T): (obj: U) => Record<K, T> & U; <T, U>(val: T, obj: U): Record<K, T> & U }
    • description

      takes key,value and object and returns object that includes given key and pair

      example
      F.assoc('z',"hello",{x:1,y:2}) // {x:1,y:2,z:"hello"}
      

      Type parameters

      • T

      • U: object

      • K: string | number | symbol

      Parameters

      • prop: K
      • val: T
      • obj: U

      Returns Record<K, T> & U

      new object with all properties of old object and new key,value pair we pass

    • Type parameters

      • T

      • U: object

      • K: string | number | symbol

      Parameters

      • prop: K
      • val: T

      Returns (obj: U) => Record<K, T> & U

        • (obj: U): Record<K, T> & U
        • Parameters

          • obj: U

          Returns Record<K, T> & U

    • Type parameters

      • K: string | number | symbol

      Parameters

      • prop: K

      Returns { <T, U>(val: T): (obj: U) => Record<K, T> & U; <T, U>(val: T, obj: U): Record<K, T> & U }

        • <T, U>(val: T): (obj: U) => Record<K, T> & U
        • <T, U>(val: T, obj: U): Record<K, T> & U
        • Type parameters

          • T

          • U: object

          Parameters

          • val: T

          Returns (obj: U) => Record<K, T> & U

            • (obj: U): Record<K, T> & U
            • Parameters

              • obj: U

              Returns Record<K, T> & U

        • Type parameters

          • T

          • U: object

          Parameters

          • val: T
          • obj: U

          Returns Record<K, T> & U

    dissoc

    • dissoc<T, K>(prop: K, obj: T): Omit<T, K>
    • dissoc<K>(prop: K): <T>(obj: T) => Omit<T, K>
    • description

      returns the object that omits prop property.also works in partial form

      example
      F.dissoc("room",{id:1,name:"pranshu",room:401}); // {id:1,name:"pranshu"}
      let deleteRoom = F.dissoc("room");
      deleteRoom({id:2,name:"mit",room:1001}) // {id:2,name:"mit"}

      Type parameters

      • T: object

      • K: string | number | symbol

      Parameters

      • prop: K
      • obj: T

      Returns Omit<T, K>

      shallow copy of the object with omitted key.

    • Type parameters

      • K: string | number | symbol

      Parameters

      • prop: K

      Returns <T>(obj: T) => Omit<T, K>

        • <T>(obj: T): Omit<T, K>
        • Type parameters

          • T: object

          Parameters

          • obj: T

          Returns Omit<T, K>

    eq_props

    • eq_props(key: string | number, o1: Any_Obj, o2: Any_Obj): boolean
    • eq_props(key: string | number, o1: Any_Obj): (o2: Any_Obj) => boolean
    • eq_props(key: string | number): { (o1: Any_Obj, o2: Any_Obj): boolean; (o1: Any_Obj): (o2: Any_Obj) => boolean }
    • description

      takes key and 2 objects and checks whether given key has same value in object.it uses F.equals to check equality.

      example
      F.eq_props("profile",{id:1,profile:{name:"pranshu shah",age:25}},{id:2,profile:{name:"pranshu shah",age:25},teacher:false}) //true
      

      Parameters

      • key: string | number
      • o1: Any_Obj
      • o2: Any_Obj

      Returns boolean

    • Parameters

      • key: string | number
      • o1: Any_Obj

      Returns (o2: Any_Obj) => boolean

        • (o2: Any_Obj): boolean
        • Parameters

          • o2: Any_Obj

          Returns boolean

    • Parameters

      • key: string | number

      Returns { (o1: Any_Obj, o2: Any_Obj): boolean; (o1: Any_Obj): (o2: Any_Obj) => boolean }

        • (o1: Any_Obj, o2: Any_Obj): boolean
        • (o1: Any_Obj): (o2: Any_Obj) => boolean
        • Parameters

          • o1: Any_Obj
          • o2: Any_Obj

          Returns boolean

        • Parameters

          • o1: Any_Obj

          Returns (o2: Any_Obj) => boolean

            • (o2: Any_Obj): boolean
            • Parameters

              • o2: Any_Obj

              Returns boolean

    keys

    • keys<T>(obj: T): string[]
    • description

      wrapper around Object.keys()

      example
      F.keys({id:1,name:"pranshu",age:24}) // ["id","name","age"]
      F.keys([10,20,30]) // ['0','1','2']

      Type parameters

      • T: object

      Parameters

      • obj: T

      Returns string[]

    merge_all

    • merge_all<OL>(arr: OL): MergeAll<OL>
    • description

      takes an array of objects and returns an object containing all objects in array,also work in partial form

      example
      F.merge_all([
      { id: '11', name: 'pranshu shah' },
      { id: '12', task: 'woww' },
      { id: '13', name: 'zoom' },
      ]); // {id:'13',name:"zoom",task:"woww"}

      Type parameters

      • OL: object[]

      Parameters

      • arr: OL

      Returns MergeAll<OL>

    merge_left

    • merge_left<T1, T2>(o1: T1, o2: T2): Merge<T1, T2>
    • merge_left<T1>(o1: T1): <T2>(o2: T2) => Merge<T1, T2>
    • description

      merges two object if key exists in both object it takes key-val of first pair.also works in partial form

      example
      F.merge_left(
      { id: '11', name: 'pranshu shah' },
      { id: '12', task: 'woww' }
      ); // {id:"11",name:"pranshu shah",task:'woww'}

      Type parameters

      • T1: object

      • T2: object

      Parameters

      • o1: T1
      • o2: T2

      Returns Merge<T1, T2>

    • Type parameters

      • T1: object

      Parameters

      • o1: T1

      Returns <T2>(o2: T2) => Merge<T1, T2>

        • <T2>(o2: T2): Merge<T1, T2>
        • Type parameters

          • T2: object

          Parameters

          • o2: T2

          Returns Merge<T1, T2>

    merge_right

    • merge_right<T1, T2>(o1: T1, o2: T2): Merge<T2, T1>
    • merge_right<T1>(o1: T1): <T2>(o2: T2) => Merge<T2, T1>
    • description

      merges two object if key exist in both object it take key-val from 2nd object. also works in partial form.

      example
      F.merge_right(
      { id: '11', name: 'pranshu shah' },
      { id: '12', task: 'woww' }
      ); // {id:'12',task:"woww",name:"pranshu shah"}

      Type parameters

      • T1: object

      • T2: object

      Parameters

      • o1: T1
      • o2: T2

      Returns Merge<T2, T1>

    • Type parameters

      • T1: object

      Parameters

      • o1: T1

      Returns <T2>(o2: T2) => Merge<T2, T1>

        • <T2>(o2: T2): Merge<T2, T1>
        • Type parameters

          • T2: object

          Parameters

          • o2: T2

          Returns Merge<T2, T1>

    object_of

    • object_of<T, K>(key: K, value: T): Record<K, T>
    • object_of<T, K>(key: K): (value: T) => Record<K, T>
    • description

      creates an object of given key val pair; also works with partial form.

      example
      F.object_of('id', 222); {id:222}
      F.object_of("getName",function(){
      return this.name
      }) // {getName:function(){return this.name}}

      Type parameters

      • T

      • K: string | number

      Parameters

      • key: K
      • value: T

      Returns Record<K, T>

    • Type parameters

      • T

      • K: string | number

      Parameters

      • key: K

      Returns (value: T) => Record<K, T>

        • (value: T): Record<K, T>
        • Parameters

          • value: T

          Returns Record<K, T>

    omit

    • omit<O, K>(obj: O, delete_keys?: K[]): Omit<O, K>
    • omit<O, K>(obj: O): (delete_keys: K[]) => Omit<O, K>
    • description

      deletes given array of keys from object and returns new copy of object; also works with partial form.

      example
      F.omit({id: 'hello',name: 'pranshu',age: 24},['id', 'name']); // {age:24}
      

      Type parameters

      • O: object

      • K: string | number | symbol

      Parameters

      • obj: O
      • Optional delete_keys: K[]

      Returns Omit<O, K>

    • Type parameters

      • O: object

      • K: string | number | symbol

      Parameters

      • obj: O

      Returns (delete_keys: K[]) => Omit<O, K>

        • (delete_keys: K[]): Omit<O, K>
        • Parameters

          • delete_keys: K[]

          Returns Omit<O, K>

    partial_props

    • partial_props<T, T1, R>(fn: (x: T) => R, intial_object_args: T1): (later_object_args: O.Exclude<T, T1>) => R
    • partial_props<T, R>(fn: (x: T) => R): <T1>(intial_object_args: T1) => (later_object_args: O.Exclude<T, T1>) => R
    • description

      takes a function and an object that is partial of the object that we passes as function argument.

      example
      type Args = {
      id:string;
      name:string;
      }
      function deleteName(x:Args){
      delete obj[x.id][x.name]
      }
      getNameAndDelete = F.partial_props(deleteName,{id:"111"})
      getNameAndDelete({name:"pranshu"})

      Type parameters

      • T: object

      • T1: Partial<T>

      • R

      Parameters

      • fn: (x: T) => R
          • (x: T): R
          • Parameters

            • x: T

            Returns R

      • intial_object_args: T1

      Returns (later_object_args: O.Exclude<T, T1>) => R

      a function that takes remaining part of object will invoke the function when you call returned function.

        • (later_object_args: O.Exclude<T, T1>): R
        • Parameters

          • later_object_args: O.Exclude<T, T1>

          Returns R

          a function that takes remaining part of object will invoke the function when you call returned function.

    • Type parameters

      • T: object

      • R

      Parameters

      • fn: (x: T) => R
          • (x: T): R
          • Parameters

            • x: T

            Returns R

      Returns <T1>(intial_object_args: T1) => (later_object_args: O.Exclude<T, T1>) => R

        • <T1>(intial_object_args: T1): (later_object_args: O.Exclude<T, T1>) => R
        • Type parameters

          • T1: Partial<T>

          Parameters

          • intial_object_args: T1

          Returns (later_object_args: O.Exclude<T, T1>) => R

            • (later_object_args: O.Exclude<T, T1>): R
            • Parameters

              • later_object_args: O.Exclude<T, T1>

              Returns R

    path

    • path<T, ReturnValueType>(path_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[], obj: T): ReturnValueType | undefined
    • path<T>(path_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]): <ReturnValueType>(obj: T) => ReturnValueType | undefined
    • description

      takes a path as an array and the object and returns the value at given in object otherwise it returns undefined;also works with partial form.

      example
      let obj = { id: '1', profile: { name: 'pranshu' } };
      path<typeof obj, string>(['profile', 'name'], obj); //"pranshu"

      Type parameters

      • T: Any_Obj

      • ReturnValueType

      Parameters

      • path_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]
      • obj: T

      Returns ReturnValueType | undefined

    • Type parameters

      • T: Any_Obj

      Parameters

      • path_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]

      Returns <ReturnValueType>(obj: T) => ReturnValueType | undefined

        • <ReturnValueType>(obj: T): ReturnValueType | undefined
        • Type parameters

          • ReturnValueType

          Parameters

          • obj: T

          Returns ReturnValueType | undefined

    path_or

    • path_or<T, D>(defaut_val: D, paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[], obj: T): D
    • path_or<T, D>(defaut_val: D, paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]): (obj: T) => D
    • path_or<T, D>(defaut_val: D): { (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[], obj: T): D; (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]): (obj: T) => D }
    • description

      takes a default value,path as an array and object and checks whether given path exist in object, if it does it returns the value at that path otherwise returns default value;also works with partial form.

      example
      let obj = { id: '1', profile: { name: 'pranshu' } };
      F.path_or('mit', ['profile', 'name'], obj); // "pranshu"
      F.path_or('mit', ['profile', 'age'], obj); // "mit"

      Type parameters

      • T: Any_Obj

      • D

      Parameters

      • defaut_val: D
      • paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]
      • obj: T

      Returns D

    • Type parameters

      • T: Any_Obj

      • D

      Parameters

      • defaut_val: D
      • paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]

      Returns (obj: T) => D

        • (obj: T): D
        • Parameters

          • obj: T

          Returns D

    • Type parameters

      • T: Any_Obj

      • D

      Parameters

      • defaut_val: D

      Returns { (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[], obj: T): D; (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]): (obj: T) => D }

        • (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[], obj: T): D
        • (paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]): (obj: T) => D
        • Parameters

          • paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]
          • obj: T

          Returns D

        • Parameters

          • paths_list: (T extends Any_Obj ? { [ K in string | number | symbol]-?: K extends string | number ? `${K}` | (T[K] extends Any_Obj ? { [K in keyof T[K]]-?: K extends string | number ? `${K}` | (T[K][K] extends Any_Obj ? { [K in keyof T[K][K]]-?: K extends string | number ? `${K}` | (T[K][K][K] extends Any_Obj ? { [K in keyof T[K][K][K]]-?: K extends string | number ? `${K}` : never; }[keyof T[K][K][K]] : never) : never; }[keyof T[K][K]] : never) ...[keyof any[any]] : never) : never }[keyof T] : never)[]

          Returns (obj: T) => D

            • (obj: T): D
            • Parameters

              • obj: T

              Returns D

    pick

    • pick<O, K>(keys: K[], obj: O): Pick<O, K>
    • pick<O, K>(keys: K[]): (obj: O) => Pick<O, K>
    • description

      Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored;also works with partial form.

      example
      F.pick(["name","age"],{id:1,name:"pranshu",age:24}) {name:"pranshu",age:24}
      

      Type parameters

      • O: Any_Obj

      • K: string | number | symbol

      Parameters

      • keys: K[]
      • obj: O

      Returns Pick<O, K>

    • Type parameters

      • O: Any_Obj

      • K: string | number | symbol

      Parameters

      • keys: K[]

      Returns (obj: O) => Pick<O, K>

        • (obj: O): Pick<O, K>
        • Parameters

          • obj: O

          Returns Pick<O, K>

    pick_by

    • pick_by<U, T, K>(pred: (key: K, value: T[K]) => boolean, obj: T): Pick_by<U, T>
    • pick_by<U, T, K>(pred: (key: K, value: T[K]) => boolean): (obj: T) => Pick_by<U, T>
    • description

      Returns a partial copy of an object containing only the keys that satisfy the supplied predication function;also works with partial form.

      Type parameters

      • U

      • T: Any_Obj = {}

      • K: string | number | symbol = string

      Parameters

      • pred: (key: K, value: T[K]) => boolean
          • (key: K, value: T[K]): boolean
          • Parameters

            • key: K
            • value: T[K]

            Returns boolean

      • obj: T

      Returns Pick_by<U, T>

    • Type parameters

      • U

      • T: Any_Obj = {}

      • K: string | number | symbol = string

      Parameters

      • pred: (key: K, value: T[K]) => boolean
          • (key: K, value: T[K]): boolean
          • Parameters

            • key: K
            • value: T[K]

            Returns boolean

      Returns (obj: T) => Pick_by<U, T>

        • (obj: T): Pick_by<U, T>
        • Parameters

          • obj: T

          Returns Pick_by<U, T>

    prop

    • prop<T>(obj: T, key: keyof T): T[keyof T]
    • prop<T>(obj: T): (key: keyof T) => T[keyof T]
    • description

      returns value of given key in the object we passed. also works with partial form.

      example
      F.prop({id:1,name:"pranshu"},"name") // "pranshu"
      

      Type parameters

      • T: object

      Parameters

      • obj: T
      • key: keyof T

      Returns T[keyof T]

    • Type parameters

      • T: object

      Parameters

      • obj: T

      Returns (key: keyof T) => T[keyof T]

        • (key: keyof T): T[keyof T]
        • Parameters

          • key: keyof T

          Returns T[keyof T]

    prop_or

    • prop_or<O, ReturnType>(default_val: ReturnType, obj: O, prop: keyof O): ReturnType | O[keyof O]
    • prop_or<O, ReturnType>(default_val: ReturnType, obj: O): (prop: keyof O) => ReturnType | O[keyof O]
    • prop_or<ReturnType>(default_val: ReturnType): { <O>(obj: O, prop: keyof O): ReturnType | O[keyof O]; <O>(obj: O): (prop: keyof O) => ReturnType | O[keyof O] }
    • description

      If the given, non-null object has an own property with the specified name, returns the value of that property if it does not satisfy F.is_empty. Otherwise returns the provided default value, also works with partial form.

      example
      F.prop_or('mit', { id: '11', author: 'pranshu' }, 'author'); // "pranshu"
      F.prop_or('mit', { id: '11', author: null }, 'author'); // "mit"

      Type parameters

      • O: Any_Obj

      • ReturnType

      Parameters

      • default_val: ReturnType
      • obj: O
      • prop: keyof O

      Returns ReturnType | O[keyof O]

    • Type parameters

      • O: Any_Obj

      • ReturnType

      Parameters

      • default_val: ReturnType
      • obj: O

      Returns (prop: keyof O) => ReturnType | O[keyof O]

        • (prop: keyof O): ReturnType | O[keyof O]
        • Parameters

          • prop: keyof O

          Returns ReturnType | O[keyof O]

    • Type parameters

      • ReturnType

      Parameters

      • default_val: ReturnType

      Returns { <O>(obj: O, prop: keyof O): ReturnType | O[keyof O]; <O>(obj: O): (prop: keyof O) => ReturnType | O[keyof O] }

        • <O>(obj: O, prop: keyof O): ReturnType | O[keyof O]
        • <O>(obj: O): (prop: keyof O) => ReturnType | O[keyof O]
        • Type parameters

          • O: Any_Obj

          Parameters

          • obj: O
          • prop: keyof O

          Returns ReturnType | O[keyof O]

        • Type parameters

          • O: Any_Obj

          Parameters

          • obj: O

          Returns (prop: keyof O) => ReturnType | O[keyof O]

            • (prop: keyof O): ReturnType | O[keyof O]
            • Parameters

              • prop: keyof O

              Returns ReturnType | O[keyof O]

    prop_satisfies

    • prop_satisfies<T>(pre: (arg: any) => boolean, key: keyof T, obj: T): boolean
    • prop_satisfies<T>(pre: (arg: any) => boolean, key: string | number | symbol): (obj: T) => boolean
    • prop_satisfies(pre: (arg: any) => boolean): { <T>(key: keyof T, obj: T): boolean; (key: string | number | symbol): <T>(obj: T) => boolean }
    • description

      Returns true if the specified object property satisfies the given predicate; false otherwise; also works with partial form.

      example
      function longNameChecker(name: string) {
      return name.length > 10;
      }
      F.prop_satisfies(longNameChecker, 'name', {
      id: '12',
      name: 'mit',
      }); // false

      Type parameters

      • T: Any_Obj

      Parameters

      • pre: (arg: any) => boolean
          • (arg: any): boolean
          • Parameters

            • arg: any

            Returns boolean

      • key: keyof T
      • obj: T

      Returns boolean

    • Type parameters

      • T: Any_Obj

      Parameters

      • pre: (arg: any) => boolean
          • (arg: any): boolean
          • Parameters

            • arg: any

            Returns boolean

      • key: string | number | symbol

      Returns (obj: T) => boolean

        • (obj: T): boolean
        • Parameters

          • obj: T

          Returns boolean

    • Parameters

      • pre: (arg: any) => boolean
          • (arg: any): boolean
          • Parameters

            • arg: any

            Returns boolean

      Returns { <T>(key: keyof T, obj: T): boolean; (key: string | number | symbol): <T>(obj: T) => boolean }

        • <T>(key: keyof T, obj: T): boolean
        • (key: string | number | symbol): <T>(obj: T) => boolean
        • Type parameters

          • T: Any_Obj

          Parameters

          • key: keyof T
          • obj: T

          Returns boolean

        • Parameters

          • key: string | number | symbol

          Returns <T>(obj: T) => boolean

            • <T>(obj: T): boolean
            • Type parameters

              • T: Any_Obj

              Parameters

              • obj: T

              Returns boolean

    prop_set

    • prop_set<T, K, Val>(obj: T, key: keyof K, val: Val): T & Record<keyof K, Val>
    • prop_set<T>(obj: T): { <K, Val>(key: keyof K, val: Val): T & Record<keyof K, Val>; <K>(key: keyof K): <Val>(val: Val) => T & Record<keyof K, Val> }
    • prop_set<T, K>(obj: T, key: keyof K): <Val>(val: Val) => T & Record<keyof K, Val>
    • description

      add new key-val pair in object and returns new copy of object(Note: it creates shallow copy).also works with partial form.

      example
      F.prop_set({id:1,todo:"doing stuff"},"author","pranshu") // {id:1,todo:"doing stuff",author:"pranshu"};
      

      Type parameters

      • T: Any_Obj

      • K: Any_Obj

      • Val

      Parameters

      • obj: T
      • key: keyof K
      • val: Val

      Returns T & Record<keyof K, Val>

    • Type parameters

      • T: Any_Obj

      Parameters

      • obj: T

      Returns { <K, Val>(key: keyof K, val: Val): T & Record<keyof K, Val>; <K>(key: keyof K): <Val>(val: Val) => T & Record<keyof K, Val> }

        • <K, Val>(key: keyof K, val: Val): T & Record<keyof K, Val>
        • <K>(key: keyof K): <Val>(val: Val) => T & Record<keyof K, Val>
        • Type parameters

          • K: Any_Obj

          • Val

          Parameters

          • key: keyof K
          • val: Val

          Returns T & Record<keyof K, Val>

        • Type parameters

          • K: Any_Obj

          Parameters

          • key: keyof K

          Returns <Val>(val: Val) => T & Record<keyof K, Val>

            • <Val>(val: Val): T & Record<keyof K, Val>
            • Type parameters

              • Val

              Parameters

              • val: Val

              Returns T & Record<keyof K, Val>

    • Type parameters

      • T: Any_Obj

      • K: Any_Obj

      Parameters

      • obj: T
      • key: keyof K

      Returns <Val>(val: Val) => T & Record<keyof K, Val>

        • <Val>(val: Val): T & Record<keyof K, Val>
        • Type parameters

          • Val

          Parameters

          • val: Val

          Returns T & Record<keyof K, Val>

    props

    • props<O>(obj: O, ps: keyof O[]): O[keyof O][]
    • props<O>(obj: O): (ps: keyof O[]) => O[keyof O][]
    • description

      same as F.prop but here it takes array of keys and returns array of values in same order; also works with partial form.

      example
      F.props({id:1,todo:"doing stuff",author:"pranshu"},["todo","author"]) // ["doing suff","pranshu"]
      

      Type parameters

      • O: Record<any, any>

      Parameters

      • obj: O
      • ps: keyof O[]

      Returns O[keyof O][]

    • Type parameters

      • O: Record<any, any>

      Parameters

      • obj: O

      Returns (ps: keyof O[]) => O[keyof O][]

        • (ps: keyof O[]): O[keyof O][]
        • Parameters

          • ps: keyof O[]

          Returns O[keyof O][]

    to_pairs

    • to_pairs<T>(obj: Obj<T>): [string | number, T][]
    • description

      wrapper aroundObject.entries().

      example
      F.to_pair({id:1,name:"pranshu"}) // [["id",1],["name","pranshu"]]
      

      Type parameters

      • T

      Parameters

      • obj: Obj<T>

      Returns [string | number, T][]

    values

    • values<T, K>(obj: T): T[K][]
    • description

      returns array of values from object.

      example
      F.values({id:"1",name:"pranshu",age:24}) // [1,"pranshu",24]
      

      Type parameters

      • T: Any_Obj

      • K: string | number | symbol

      Parameters

      • obj: T

      Returns T[K][]

    Other Functions

    async_delay

    • async_delay<T>(delay: number, x?: T): Promise<T | undefined>
    • description

      async function that resolves after given milisecond with value we provide.

      example
      await F.delay(300,23) // returns 23 after 300 miliseconds.
      

      Type parameters

      • T

      Parameters

      • delay: number

        time you want wait for your promise to resolve.(in milisecond.)

      • Optional x: T

        value you want return with resolve function.

      Returns Promise<T | undefined>

      Promise that resolves in given time.

    async_filter

    • async_filter<T>(arr: readonly T[], predicate_fn: (value: T, index: number, arr: readonly T[]) => Promise<boolean>): Promise<T[]>
    • description

      takes an array and predication function(which returns promise) and returns an array for which predication function returns true.all the predication functions are being evaluate in parallel but the final result will be same as original array.

      example
      async function isPremiumUser(userName:string):Promise<boolean>{
      let res = await fetch(`someUrlTocheckPremiumUser?name=${userName}`);
      let data = await res.json();
      return data.isPremiumUser
      }
      let premiumUsers = await F.async_filter(["pranshu_44","mit_123","sanket_69","kartik_99"],isPremiumUser) // ["pranshu_44","sanket_69"]

      Type parameters

      • T

      Parameters

      • arr: readonly T[]

        array you want to filter

      • predicate_fn: (value: T, index: number, arr: readonly T[]) => Promise<boolean>

        filter function

          • (value: T, index: number, arr: readonly T[]): Promise<boolean>
          • Parameters

            • value: T
            • index: number
            • arr: readonly T[]

            Returns Promise<boolean>

      Returns Promise<T[]>

    async_for_each

    • async_for_each<T>(xs: readonly T[], Fn: (item: T, index: number, original_list: readonly T[]) => Promise<any>): Promise<readonly T[]>
    • description

      same as F.for_each() but callback functions will be called asynchronously.

      example
      async function deleteFile(file:string) {
      await fs.unlink(file);
      };
      await F.async_for_each(["pranshu.txt","mit.txt","kartik.txt"],deleteFile);

      Type parameters

      • T

      Parameters

      • xs: readonly T[]

        array you want to loop over.

      • Fn: (item: T, index: number, original_list: readonly T[]) => Promise<any>

        async function want call on every element.

          • (item: T, index: number, original_list: readonly T[]): Promise<any>
          • Parameters

            • item: T
            • index: number
            • original_list: readonly T[]

            Returns Promise<any>

      Returns Promise<readonly T[]>

    async_map

    • async_map<T, V>(arr: readonly T[], fn: (value: T, index: number, arr: readonly T[]) => Promise<V>): Promise<V[]>
    • description

      takes an array and mapper function that returns a promise and returns an array with mapped values.all the element in array are passed to the mapper functions in parallel but the final result will be same as original array.

      example
       async function getTotalPosts(userName:string):Promise<number>{
      let res = await fetch(`someUrlTogetPosts?name=${userName}`);
      let data = await res.json();
      return data.totalPosts;
      }
      let posts = await F.async_map(["pranshu_44","mit_123","sanket_69","kartik_99"],getTotalPosts) // [12,2,3,1];

      Type parameters

      • T

      • V

      Parameters

      • arr: readonly T[]

        array you want to map.

      • fn: (value: T, index: number, arr: readonly T[]) => Promise<V>

        function that will map the given element to the new element.

          • (value: T, index: number, arr: readonly T[]): Promise<V>
          • Parameters

            • value: T
            • index: number
            • arr: readonly T[]

            Returns Promise<V>

      Returns Promise<V[]>

    async_retry

    • async_retry<Fn>(fn: Fn, options?: retryOptions): (...args: OvarloadedParameters<Fn>) => OverloadedReturnType<Fn> | Error
    • description

      takes a function and optinal options object and returns a function, which will try to call our async function maximum attempts times(default 10).if task is successful it will return that result and of task is not successful after all attempts it will throw error.

      example
      async function isPaymentCompleted(id:string){
      let res = await fetch(`paymentCompletedchecker.com?id=${id}`);
      let data = await res.json();
      if(data.isPaymentCompleted){
      return true;
      }else{
      throw new Error("payment is pending");
      }
      }
      let paymentCheckerWatcher = async async_retry(isPaymentCompleted,{delayInMs:100});
      let result = await paymentCheckerWatcher("123"); // isPaymentCompleted function is called maximum 10 times until it does not throw error and it returns the value. and it wait for 100ms between each call.

      Type parameters

      • Fn: (...args: any[]) => Promise<any>

      Parameters

      • fn: Fn

        function you want call.

      • Optional options: retryOptions

        optional options object.

      Returns (...args: OvarloadedParameters<Fn>) => OverloadedReturnType<Fn> | Error

        • (...args: OvarloadedParameters<Fn>): OverloadedReturnType<Fn> | Error
        • Parameters

          • Rest ...args: OvarloadedParameters<Fn>

          Returns OverloadedReturnType<Fn> | Error

    async_timeout

    • async_timeout<T>(x: Promise<T>, timeout: number): Promise<T>
    • description

      if given promises does not resolves in given time it throws error.

      example
      try{

      let res = await F.async_timeout(
      fetch("https://jsonplaceholder.typicode.com/todos/1"),
      10000
      );
      console.log(res) // if reques does resolve in 10000 ms it log the response.
      }catch(e){
      conosle.error(e) // if request does not resolve in 10000 ms it will thorw error.
      }

      Type parameters

      • T

      Parameters

      • x: Promise<T>

        Promise you want timeout.

      • timeout: number

        value of timeout in milisecond.

      Returns Promise<T>

    index_by

    • index_by<T, K>(fn: (a: T) => K, list: readonly T[]): { [ key in K]: T }
    • index_by<T, K>(fn: (a: T) => K): (list: readonly T[]) => { [ key in K]: T }
    • Type parameters

      • T

      • K: string | number = string

      Parameters

      • fn: (a: T) => K
          • (a: T): K
          • Parameters

            • a: T

            Returns K

      • list: readonly T[]

      Returns { [ key in K]: T }

    • Type parameters

      • T

      • K: string | number = string

      Parameters

      • fn: (a: T) => K
          • (a: T): K
          • Parameters

            • a: T

            Returns K

      Returns (list: readonly T[]) => { [ key in K]: T }

        • (list: readonly T[]): { [ key in K]: T }
        • Parameters

          • list: readonly T[]

          Returns { [ key in K]: T }

    Generated using TypeDoc