diff --git a/docs/assets/navigation.js b/docs/assets/navigation.js index 928e3dc6..5ad46a19 100644 --- a/docs/assets/navigation.js +++ b/docs/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE4uOBQApu0wNAgAAAA==" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE42SwUrEMBBA/yXnYlFEpDfBPQiisuJJPAzt7Da0TcJkilvFf5fott22cep13rx3yOT1UzEeWGVqi41lvAWGZwZuvUqUAy5VptC0jU/n/KzkplaJqrQpVHb9lQylG9+ZPCyOibwG79GnA5ra5xen/kZzibSUf+eSeQ8f3dILU8l6dKytgXpp9kSywd+dvNWuNXlwfBrmU+/qcqK9mAJ32mARtwcsRAqyLmaHuaDhgQlyfiLrkLiLFWYrQkwXaFjHKz0T9NruN0SWYnrPBL2BCh+sWZ5wrMxWVmJrpX9kHBDreOGI1uWt3pcsFH64lNF5dTyexuj/nG4IKS7Jvv95o5EuEm/f9LnFTF0EAAA=" \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js index 66d159da..78e45ae7 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAEz2MMQqAMBAE/7J1sNDK/MAP2IiFmBUOkovEoIL4dwmK5ewscyHFY4MdRgNRxxP2ws60SVRY1FVTtTBYhN6VG3QKhMEcQ6BmjJ/rOeeY/tDOlOm6N1imVVZ6URa67wdtjdlXdgAAAA=="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE71d25LbuBH9F86rPBYuvM2bq7JJbcrr3VonmweVa4uRqBmuNaRCUuN1XP73FEiC7Aa7RYqa6GnGUqMPgHPQDfSQ8DevLL5U3sPmm/c5y3feQ6BXXp48p96D95x8Tn8+1lmRJwdv5Z3Kg/fg7U/51nxUvYVf3z/Vz8Zme0iqKq28B8/7vupd+r4Keq+//15/PaZz/N2hT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QIw49s2b96PZgfsRbpCm4QgyAMsp5Og4NG9ggrUL+hlzqhn1EUxK2B0qIi5ijHlUQDdsgm2bVd3ljqAxEIHiCCEkIMEKtqcddgNu2j8XOE9r4MDnZHsoHtP28UCwoYCJjO2y+U8Q8iKncgGYLi70mNZUU8Aut7SdVA23k93+N7D7Yb7vx1FsB52OOI6fk+N44YBwFHEqfk6Oo/zlg2kOODHmRT0KnBKo2R6I2Y20+X8bACaA5BoQrIAhckmoKNPmyjAQiWB+tkf6rrs+x0zrxt1ZgUAhuZlqW9btBdygLQjeklNjUeb22nPQEkyW4IgtyvyEiwgCxEPJabh/cxcENgi35tZr13CkwgigCsHp1zwPegTPtIJVBMnSbLfb+wtGawcIMp5oO14/YNwxRy517pFg/UhO/vYGMbAEwEIPuGkum7uRzTHZXv4KcMFUSU7H9t4ngAuEGHKTNM6RYHbC7rgfcTJuk88o0Gh4CGbbNhckAWAwTSG36NsbusAYwUINOBGOZ1SBDrK1umq4tBtwAQDV2ZYV5hBkDfYA0MSSUXYMQdOYk11d/FEVqNQkYVLkYq+9uw3MKIzYXLMR42BWbMC11dE1Kb1PK++YHdNDlqfew+bT9+//A47+EqekagAA"; \ No newline at end of file diff --git a/docs/classes/AsyncData.html b/docs/classes/AsyncData.html new file mode 100644 index 00000000..0f76e8ae --- /dev/null +++ b/docs/classes/AsyncData.html @@ -0,0 +1,87 @@ +AsyncData | @dancrumb/fpish

Class AsyncData<D, E>

This class represents data from a remote source that takes time to load.

+

It can be single-valued or an array of values. The caller is expected to +know which it is

+

Type Parameters

  • D

    A type representing the shape of data that is being requested

    +
  • E = {}

    A type representing the shape of errors that can be returned

    +

Constructors

Properties

internal: Either<E, readonly D[]>
status: RemoteDataStatus = RemoteDataStatus.NotAsked

Methods

  • This returns true if the predicate returns true for every element of data.

    +

    It is synonymous with every

    +

    Parameters

    • predicate: ((value, index, array) => boolean)
        • (value, index, array): boolean
        • Parameters

          • value: D
          • index: number
          • array: D[]

          Returns boolean

    Returns boolean

    Throws

    an error if no response has been received

    +
  • This returns true if the predicate returns true for any element of data.

    +

    It is synonymous with some

    +

    Parameters

    • predicate: ((value, index, array) => boolean)
        • (value, index, array): boolean
        • Parameters

          • value: D
          • index: number
          • array: D[]

          Returns boolean

    Returns boolean

    Throws

    an error if no response has been received

    +
  • Returns boolean

    true if this object currently contains retrievable data, i.e. not an error and not an inflight request

    +
  • This returns true if the predicate returns true for every element of data.

    +

    It is synonymous with all

    +

    Parameters

    • predicate: ((value, index, array) => boolean)
        • (value, index, array): boolean
        • Parameters

          • value: D
          • index: number
          • array: D[]

          Returns boolean

    Returns boolean

    Throws

    an error if no response has been received

    +
  • Parameters

    • callbackfn: ((value, index?, array?) => boolean)
        • (value, index?, array?): boolean
        • Parameters

          • value: D
          • Optional index: number
          • Optional array: readonly D[]

          Returns boolean

    Returns AsyncData<D, E>

  • Parameters

    • predicate: ((value, index, obj) => boolean)
        • (value, index, obj): boolean
        • Parameters

          • value: D
          • index: number
          • obj: readonly D[]

          Returns boolean

    • Optional thisArg: unknown

    Returns undefined | D

  • Parameters

    • predicate: ((value, index, obj) => boolean)
        • (value, index, obj): boolean
        • Parameters

          • value: D
          • index: number
          • obj: readonly D[]

          Returns boolean

    • Optional thisArg: unknown

    Returns number

  • Get the data as an optional and treat it as an array

    +

    This will return any internal data that exists. As a result, it will +return data after a call to loadMore.

    +

    Returns Optional<readonly D[]>

  • Standard response for mapping this AsyncData to a new one +when no data is loaded

    +

    Type Parameters

    • U

    Returns undefined | AsyncData<U, E>

  • Parameters

    • v: D | readonly D[]

    Returns v is readonly D[]

  • Check whether data has been requested

    +

    Returns boolean

  • Checks whether the data that was loaded is empty.

    +

    This will throw an error if the data is not loaded yet

    +

    Returns boolean

    Throws

  • Check whether the data errored out

    +

    Returns boolean

  • Check whether any data has loaded (or that the request has failed)

    +

    Returns boolean

  • Check whether data is currently loading

    +

    Returns boolean

  • Type Parameters

    • U

    Parameters

    • callbackfn: ((value, index, array?) => U)
        • (value, index, array?): U
        • Parameters

          • value: D
          • index: number
          • Optional array: readonly D[]

          Returns U

    Returns AsyncData<U, E>

  • Type Parameters

    • U

    Parameters

    • callbackfn: ((value, index, array?) => U)
        • (value, index, array?): U
        • Parameters

          • value: D
          • index: number
          • Optional array: readonly D[]

          Returns U

    Returns readonly U[]

  • Treats the data as an Optional and returns the internal +value or the provided value.

    +

    Parameters

    • v: D | readonly D[]

    Returns D | readonly D[]

  • Type Parameters

    • U

    Parameters

    • callbackfn: ((previousValue, currentValue, currentIndex, array) => U)
        • (previousValue, currentValue, currentIndex, array): U
        • Parameters

          • previousValue: U
          • currentValue: D
          • currentIndex: number
          • array: readonly D[]

          Returns U

    • initialValue: U

    Returns AsyncData<U, E>

  • This returns true if the predicate returns true for any element of data.

    +

    It is synonymous with any

    +

    Parameters

    • predicate: ((value, index, array) => boolean)
        • (value, index, array): boolean
        • Parameters

          • value: D
          • index: number
          • array: D[]

          Returns boolean

    Returns boolean

    Throws

    an error if no response has been received

    +
  • Sorts the elements of data, according to compareFn

    +

    Note that this does not sort the elements in place

    +

    Parameters

    • Optional compareFn: ((a, b) => number)

      The comparison function to be applied to the data elements. See Array.sort documentation for more detail

      +
        • (a, b): number
        • Parameters

          Returns number

    Returns D[]

    Throws

    an error if no response has been received

    +
  • Create an instance of this type that indicates that some data has been returned by the request.

    +

    NB: There is nothing here that asserts that the request is complete. This factory method can +be called multiple times to indicate loading data in progress.

    +

    Type Parameters

    • LD
    • LE = {}

    Parameters

    • data: readonly LD[]

    Returns AsyncData<LD, LE>

\ No newline at end of file diff --git a/docs/classes/Either.html b/docs/classes/Either.html new file mode 100644 index 00000000..a5150d31 --- /dev/null +++ b/docs/classes/Either.html @@ -0,0 +1,57 @@ +Either | @dancrumb/fpish

Class Either<L, R>

The Either<R,L> type represents 2 possible values of 2 possible types.

+

A common use case it to use this to represent the outcome of a function that could +be an error or a value: const result: Either<ErrorType, ValueType>. Convention has +ErrorType as the left-value and ValueType as the right-value.

+

The type will only ever be single-valued, but it will always be single-valued

+

Type Parameters

  • L
  • R

Constructors

Properties

left: Optional<L>
right: Optional<R>

Methods

  • Applies a function to the internal value. Since this returns void and takes functions that return +void, this relies entirely on side-effects..

    +

    Parameters

    • lFunc: ((val) => void)
        • (val): void
        • Parameters

          • val: L

          Returns void

    • rFunc: ((val) => void)
        • (val): void
        • Parameters

          • val: R

          Returns void

    Returns void

  • Gets the left-value of the object.

    +

    This will result in an error, if the object is not left-valued

    +

    Returns L

    Throws

  • Gets the right-value of the object.

    +

    This will result in an error, if the object is not right-valued

    +

    Returns R

    Throws

  • Runs the provided function if the left value is populated

    +

    Parameters

    • lFunc: ((val) => void)
        • (val): void
        • Parameters

          • val: L

          Returns void

    Returns void

  • Runs the provided function if the right value is populated

    +

    Parameters

    • rFunc: ((val) => void)
        • (val): void
        • Parameters

          • val: R

          Returns void

    Returns void

  • Returns whether or not the value is left-valued

    +

    Returns boolean

  • Returns whether or not the value is right-valued

    +

    Returns boolean

  • Maps the Either<L,R> object to a simple object of type T.

    +

    Each of the mapping functions must return the same type, so that this Either object can +be mapped.

    +

    Only one of the functions will be called, so no side-effects should be relied upon.

    +

    Type Parameters

    • O

    Parameters

    Returns O

  • Type Parameters

    • T

    Parameters

    • lFunc: ((val) => T)
        • (val): T
        • Parameters

          • val: L

          Returns T

    • rFunc: ((val) => T)
        • (val): T
        • Parameters

          • val: R

          Returns T

    Returns T

  • Map the left-value of one type to a different value of another type.

    +

    If this object is right-valued, then this doesn't change that, but it does +change the overall type of the Either object

    +

    Type Parameters

    • O

    Parameters

    Returns Either<O, R>

  • Type Parameters

    • T

    Parameters

    • lFunc: ((val) => T)
        • (val): T
        • Parameters

          • val: L

          Returns T

    Returns Either<T, R>

  • Map the right-value of one type to a different value of another type.

    +

    If this object is leftt-valued, then this doesn't change that, but it does +change the overall type of the Either object

    +

    Type Parameters

    • O

    Parameters

    Returns Either<L, O>

  • Type Parameters

    • T

    Parameters

    • rFunc: ((val) => T)
        • (val): T
        • Parameters

          • val: R

          Returns T

    Returns Either<L, T>

  • Much like {@link mapLeft}, this converts an Either from one type to another.

    +

    The difference here is that the mapping function returns an Either of its own, rather +than just a left-value. This allows you to chain a series of Eithers together, only operating +if you are getting left-valued Eithers

    +

    Type Parameters

    • T

    Parameters

    Returns Promise<Either<T, R>>

  • Type Parameters

    • T

    Parameters

    Returns Either<T, R>

  • Much like {@link mapRight}, this converts an Either from one type to another.

    +

    The difference here is that the mapping function returns an Either of its own, rather +than just a right-value. This allows you to chain a series of Eithers together, only operating +if you are getting right-valued Eithers

    +

    Type Parameters

    • T

    Parameters

    Returns Promise<Either<L, T>>

  • Type Parameters

    • T

    Parameters

    Returns Either<L, T>

\ No newline at end of file diff --git a/docs/classes/Lazy.html b/docs/classes/Lazy.html new file mode 100644 index 00000000..1205c125 --- /dev/null +++ b/docs/classes/Lazy.html @@ -0,0 +1,18 @@ +Lazy | @dancrumb/fpish

Class Lazy<T>

Represents a value that is initialized in a lazy manner, i.e. not until it is needed

+

Type Parameters

  • T

Constructors

Properties

Methods

Constructors

  • Type Parameters

    • T

    Parameters

    • builder: Builder<T, void>

    Returns Lazy<T>

Properties

builder: Builder<T, void>
value: T | Promise<T>

Methods

  • Creates a new Lazy<S> value. The initializer takes the value of this Lazy<T> and uses it +to create a Lazy<S>

    +

    Multiple values can be chained; they won't initialize until the last one is resolved.

    +

    Type Parameters

    • S

    Parameters

    • builder: Builder<S, T>

      the initializing function. Since this could be doing anything, it can have + side effects

      +

    Returns Lazy<S>

  • Gets the value of the lazy object, initializing it, if necessary

    +

    Returns Promise<T>

  • Create a Lazy by providing the function that will be called when the value +is first needed

    +

    Type Parameters

    • NT

    Parameters

    • builder: Builder<NT, void>

      the initializing function. Since this could be doing anything, it can have + side effects

      +

    Returns Lazy<NT>

\ No newline at end of file diff --git a/docs/classes/Optional.html b/docs/classes/Optional.html new file mode 100644 index 00000000..4c7709d1 --- /dev/null +++ b/docs/classes/Optional.html @@ -0,0 +1,53 @@ +Optional | @dancrumb/fpish

Class Optional<T>

Type Parameters

  • T

Constructors

Properties

value: undefined | T

Methods

  • Converts the internal type to another. guard is called to do the necessary +type checking. This is generally used for up- and down-casting.

    +

    Type Parameters

    • S

    Parameters

    • guard: ((o) => boolean)
        • (o): boolean
        • Parameters

          Returns boolean

    Returns Optional<S>

  • Compares this Optional value to the provided on.

    +

    Empty Optionals are never considered equal to anything, including other +empty Optionals.

    +

    Parameters

    • val: Optional<T>
    • isEqual: ((a, b) => boolean) = strictEquals

      an optional function for comparing equality

      +
        • (a, b): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Checks the value of the optional. If it matches the predicate, then a non-empty +Optional of the same value will be returned.

    +

    Otherwise, an empty Optional is returned.

    +

    Parameters

    • predicate: ((v) => boolean)
        • (v): boolean
        • Parameters

          Returns boolean

    Returns Optional<T>

  • Map the value of an Optional to an Optional value of the same or a different type.

    +

    This differs from map, such that the returned Optional is 'squashed' so that +the returned value is Optional<U> not Optional<Optional<U>>

    +

    Type Parameters

    • U

    Parameters

    • mapper: ((val) => Optional<undefined | null | U>)

    Returns Optional<U>

  • Get the value of the optional or throw a NoSuchElement exception

    +

    Returns T

  • If the Optional is non-empty, pass the value to a consuming function.

    +

    The consumer should not return a value. If it does, this value is ignored.

    +

    Parameters

    • consumer: ((val) => void)
        • (val): void
        • Parameters

          • val: T

          Returns void

    Returns {
        orElse: ((f) => void);
    }

    • orElse: ((f) => void)
        • (f): void
        • Parameters

          • f: (() => void)
              • (): void
              • Returns void

          Returns void

  • Check whether the Optional is empty or not.

    +

    Returns boolean

  • Map the value of an Optional to another value of the same type.

    +

    Type Parameters

    • O

    Parameters

    Returns Optional<O>

  • Map the value of an Optional to another value of a different type.

    +

    Type Parameters

    • U

    Parameters

    • mapper: ((v) => undefined | null | U)
        • (v): undefined | null | U
        • Parameters

          Returns undefined | null | U

    Returns Optional<U>

  • Return the Optional's value if it is not empty, otherwise return the +provided value.

    +

    Parameters

    • other: T

    Returns T

  • Return the Optional's value if it is not empty, otherwise call other and +return that value.

    +

    Parameters

    • other: (() => T)
        • (): T
        • Returns T

    Returns T

  • Return the Optional's value if it is not empty, otherwise call exceptionSupplier +to generate an exception that is then thrown

    +

    Parameters

    • exceptionSupplier: (() => Error)
        • (): Error
        • Returns Error

    Returns T

  • Return the Optional's value if it is not empty, otherwise return undefined.

    +

    Returns undefined | T

  • Return the Optional's value if it is not empty, otherwise return null.

    +

    Returns null | T

  • Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      a property of the enclosed value

      +

    Returns undefined | T[K]

  • Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      a property of the enclosed value

      +
    • orElse: NonNullable<T[K]>

      a default value

      +

    Returns NonNullable<T[K]>

\ No newline at end of file diff --git a/docs/enums/RemoteDataStatus.html b/docs/enums/RemoteDataStatus.html new file mode 100644 index 00000000..dac03988 --- /dev/null +++ b/docs/enums/RemoteDataStatus.html @@ -0,0 +1,14 @@ +RemoteDataStatus | @dancrumb/fpish

Enumeration RemoteDataStatus

The various states that an async request for data can be in

+

Enumeration Members

Enumeration Members

Failed: 2

A response has been received and it indicated an error

+
Failure: 2

Deprecated

synonym for Failed

+
Loading: 1

A request has been sent, but no response has been received

+
NotAsked: 0

No request has been sent yet

+
Succeeded: 3

A response has been received and it was successful

+
Success: 3

Deprecated

synonym for Succeeded

+
\ No newline at end of file diff --git a/docs/functions/asIs.html b/docs/functions/asIs.html new file mode 100644 index 00000000..9c08f828 --- /dev/null +++ b/docs/functions/asIs.html @@ -0,0 +1,2 @@ +asIs | @dancrumb/fpish

Function asIs

\ No newline at end of file diff --git a/docs/functions/asUndefined.html b/docs/functions/asUndefined.html new file mode 100644 index 00000000..6f30abcc --- /dev/null +++ b/docs/functions/asUndefined.html @@ -0,0 +1,2 @@ +asUndefined | @dancrumb/fpish

Function asUndefined

  • This does the same as drop, but is typed to return undefined (rather than void)

    +

    Parameters

    • t: unknown

    Returns undefined

\ No newline at end of file diff --git a/docs/functions/drop.html b/docs/functions/drop.html new file mode 100644 index 00000000..0e653ca4 --- /dev/null +++ b/docs/functions/drop.html @@ -0,0 +1,2 @@ +drop | @dancrumb/fpish

Function drop

  • This function returns undefined, whatever you pass in

    +

    Parameters

    • t: unknown

    Returns void

\ No newline at end of file diff --git a/docs/functions/extractProperty.html b/docs/functions/extractProperty.html new file mode 100644 index 00000000..4d8fd9ac --- /dev/null +++ b/docs/functions/extractProperty.html @@ -0,0 +1,3 @@ +extractProperty | @dancrumb/fpish

Function extractProperty

  • Sometimes, all you're looking to do is extract a single property from and object. +That's what this function does

    +

    Type Parameters

    • O extends object

    Parameters

    • key: keyof O

    Returns ((o) => O[keyof O])

      • (o): O[keyof O]
      • Parameters

        Returns O[keyof O]

\ No newline at end of file diff --git a/docs/functions/identity.html b/docs/functions/identity.html new file mode 100644 index 00000000..e528cf58 --- /dev/null +++ b/docs/functions/identity.html @@ -0,0 +1,2 @@ +identity | @dancrumb/fpish

Function identity

  • This is the identity function - it returns whatever you pass in

    +

    Type Parameters

    • T

    Parameters

    Returns T

\ No newline at end of file diff --git a/docs/functions/logError.html b/docs/functions/logError.html new file mode 100644 index 00000000..611d34f7 --- /dev/null +++ b/docs/functions/logError.html @@ -0,0 +1 @@ +logError | @dancrumb/fpish

Function logError

\ No newline at end of file diff --git a/docs/functions/makeNonOptional.html b/docs/functions/makeNonOptional.html new file mode 100644 index 00000000..4df481ce --- /dev/null +++ b/docs/functions/makeNonOptional.html @@ -0,0 +1,2 @@ +makeNonOptional | @dancrumb/fpish

Function makeNonOptional

  • Take a function that requires a value of Optional<T> and return a version that takes T

    +

    Type Parameters

    • T

    Parameters

    • f: ((o) => unknown)
        • (o): unknown
        • Parameters

          Returns unknown

    Returns ((v) => unknown)

      • (v): unknown
      • Parameters

        Returns unknown

\ No newline at end of file diff --git a/docs/functions/makeOptional.html b/docs/functions/makeOptional.html new file mode 100644 index 00000000..aaa0a782 --- /dev/null +++ b/docs/functions/makeOptional.html @@ -0,0 +1,4 @@ +makeOptional | @dancrumb/fpish

Function makeOptional

  • Take a function that requires a value of T and return a version that takes Optional<T>

    +

    NB: If an empty Optional is passed to the new function, a NoSuchElementException + will be thrown

    +

    Type Parameters

    • T

    Parameters

    • f: ((o) => unknown)
        • (o): unknown
        • Parameters

          Returns unknown

    Returns ((v) => unknown)

      • (v): unknown
      • Parameters

        Returns unknown

\ No newline at end of file diff --git a/docs/functions/partial.html b/docs/functions/partial.html new file mode 100644 index 00000000..9c847765 --- /dev/null +++ b/docs/functions/partial.html @@ -0,0 +1,5 @@ +partial | @dancrumb/fpish

Function partial

  • Takes a function,fn and a list of arguments args, and returns a new function g which, when called, +returns the result of fn called with args followed by whatever arguments are provided to g

    +

    Type Parameters

    • A1
    • R

    Parameters

    • fn: ((a) => R)

      a functions that takes up to 4 arguments

      +
        • (a): R
        • Parameters

          Returns R

    • Rest ...args: [A1]

      a list of up to 4 arguments

      +

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • R

    Parameters

    • fn: ((a) => R)
        • (a): R
        • Parameters

          Returns R

    Returns ((a) => R)

      • (a): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    • Rest ...args: [A1]

    Returns ((a) => R)

      • (a): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    Returns ((a1, a2) => R)

      • (a1, a2): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2, A3]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2]

    Returns ((a) => R)

      • (a): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A1]

    Returns ((a2, a3) => R)

      • (a2, a3): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    Returns ((a1, a2, a3) => R)

      • (a1, a2, a3): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2, A3, A4]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2, A3]

    Returns ((a4) => R)

      • (a4): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2]

    Returns ((a3, a4) => R)

      • (a3, a4): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A1]

    Returns ((a2, a3, a4) => R)

      • (a2, a3, a4): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    Returns ((a1, a2, a3, a4) => R)

      • (a1, a2, a3, a4): R
      • Parameters

        Returns R

\ No newline at end of file diff --git a/docs/functions/partialRight.html b/docs/functions/partialRight.html new file mode 100644 index 00000000..b4147d52 --- /dev/null +++ b/docs/functions/partialRight.html @@ -0,0 +1,6 @@ +partialRight | @dancrumb/fpish

Function partialRight

  • Takes a function,fn and a list of arguments args, and returns a new function g which, when called, +returns the result of fn called with whatever arguments are provided to g +followed by args

    +

    Type Parameters

    • A1
    • R

    Parameters

    • fn: ((a) => R)

      a functions that takes up to 4 arguments

      +
        • (a): R
        • Parameters

          Returns R

    • Rest ...args: [A1]

      a list of up to 4 arguments

      +

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • R

    Parameters

    • fn: ((a) => R)
        • (a): R
        • Parameters

          Returns R

    Returns ((a) => R)

      • (a): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    • Rest ...args: [A2]

    Returns ((a) => R)

      • (a): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • R

    Parameters

    • fn: ((a, a2) => R)
        • (a, a2): R
        • Parameters

          Returns R

    Returns ((a1, a2) => R)

      • (a1, a2): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2, A3]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A2, A3]

    Returns ((a1) => R)

      • (a1): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    • Rest ...args: [A3]

    Returns ((a1, a2) => R)

      • (a1, a2): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • R

    Parameters

    • fn: ((a, a2, a3) => R)
        • (a, a2, a3): R
        • Parameters

          Returns R

    Returns ((a1, a2, a3) => R)

      • (a1, a2, a3): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A1, A2, A3, A4]

    Returns (() => R)

      • (): R
      • Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A2, A3, A4]

    Returns ((a1) => R)

      • (a1): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A3, A4]

    Returns ((a1, a2) => R)

      • (a1, a2): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    • Rest ...args: [A4]

    Returns ((a1, a2, a3) => R)

      • (a1, a2, a3): R
      • Parameters

        Returns R

  • Type Parameters

    • A1
    • A2
    • A3
    • A4
    • R

    Parameters

    • fn: ((a, a2, a3, a4) => R)
        • (a, a2, a3, a4): R
        • Parameters

          Returns R

    Returns ((a1, a2, a3, a4) => R)

      • (a1, a2, a3, a4): R
      • Parameters

        Returns R

\ No newline at end of file diff --git a/docs/functions/pickProperties.html b/docs/functions/pickProperties.html new file mode 100644 index 00000000..a461efcb --- /dev/null +++ b/docs/functions/pickProperties.html @@ -0,0 +1,3 @@ +pickProperties | @dancrumb/fpish

Function pickProperties

  • Sometimes, you want a subset of an object, with just a few properties +That's what this function does

    +

    Type Parameters

    • O extends object

    Parameters

    • keys: (keyof O)[]

    Returns ((o) => Partial<O>)

      • (o): Partial<O>
      • Parameters

        Returns Partial<O>

\ No newline at end of file diff --git a/docs/functions/throwError.html b/docs/functions/throwError.html new file mode 100644 index 00000000..f07ba122 --- /dev/null +++ b/docs/functions/throwError.html @@ -0,0 +1,3 @@ +throwError | @dancrumb/fpish

Function throwError

  • This is a handy utility function that just throws an error +that exists in an Either. Useful for Either.apply

    +

    Parameters

    • e: Error

    Returns never

\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 49110d7e..2c61fe12 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1 +1,18 @@ -@dancrumb/fpish

@dancrumb/fpish

\ No newline at end of file +@dancrumb/fpish

@dancrumb/fpish

Index

Enumerations

Classes

Functions

\ No newline at end of file diff --git a/package.json b/package.json index 18daf7c4..ac1c9338 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "scripts": { "build": "yarn run tsc -p tsconfig.production.json", - "build:docs": "yarn typedoc", + "build:docs": "yarn typedoc src/", "release": "commit-and-tag-version", "lint": "yarn run eslint", "lint:ci": "yarn run eslint --format junit --output-file ./reports/eslint.xml src",