Options
All
  • Public
  • Public/Protected
  • All
Menu

@wanglihua/lulu - v0.0.4

Index

Functions

Functions

  • add(a: number, b: number): number
  • Adds two values.

    example

    add(1,2)          // 3
    

    Parameters

    • a: number
    • b: number

    Returns number

  • adjust<T>(index: number, fn: ((value: T) => T), list: T[]): T[]
  • Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

    example

    adjust(1, (value) => value.toUpperCase(), ['a', 'b', 'c', 'd']);      //=> ['a', 'B', 'c', 'd']
    adjust(-1, (value) => value.toUpperCase(), ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D']

    Type Parameters

    • T

    Parameters

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

          • value: T

          Returns T

    • list: T[]

    Returns T[]

  • and(a: boolean, b: boolean): boolean
  • Returns the first argument if it is falsy, otherwise the second argument. Acts as the boolean and statement if both inputs are Booleans.

    example

    and(true,true)          // true
    and(true,false) // false
    and(false,true) // false
    and(false,false) // false

    Parameters

    • a: boolean
    • b: boolean

    Returns boolean