Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Token

Index

Type Aliases

Blockstore: Blockstore

Type Parameters

    Type Parameters

      EncodedBlobBlob<G>: lib/interface

      Type Parameters

      • G

      EncodedBlobUrl<T>: lib/interface

      Type Parameters

      • T

      TokenInput: lib/interface

      Type Parameters

        TokenType<T>: lib/interface

        Type Parameters

        • T

        Functions

        • Takes token input and encodes it into FormData object where form field values are discovered Blob (or File) objects in the given token and field keys are . joined paths where they were discoverd in the token. Additionally encoded FormData will also have a field named meta containing JSON serialized token with blobs and file values null set to null (this allows backend to injest all of the files from multipart/form-data request and update provided "meta" data with corresponding file ipfs:// URLs)

          example
          const cat = new File([], 'cat.png')
          const kitty = new File([], 'kitty.png')
          const form = encode({
          name: 'hello'
          image: cat
          properties: {
          extra: {
          image: kitty
          }
          }
          })
          [...form.entries()] //>
          // [
          // ['image', cat],
          // ['properties.extra.image', kitty],
          // ['meta', '{"name":"hello",image:null,"properties":{"extra":{"kitty": null}}}']
          // ]

          Type Parameters

          Parameters

          Returns FormData

        • mapWith<T, I, X, O, State>(input: MatchRecord<T, ((input: I) => X)>, p: ((input: any, state: State, path: PropertyKey[]) => input is X), f: ((state: State, input: X, path: PropertyKey[]) => [State, O]), state: State): MatchRecord<T, ((input: I) => O)>
        • Substitues values in the given input that match p(value) == true with f(value, context, path) where context is whatever you pass (usually a mutable state) and path is a array of keys / indexes where the value was encountered.

          Type Parameters

          • T

          • I

          • X

          • O

          • State

          Parameters

          • input: MatchRecord<T, ((input: I) => X)>

            Arbitrary input.

          • p: ((input: any, state: State, path: PropertyKey[]) => input is X)

            Predicate function to determine which values to swap.

              • (input: any, state: State, path: PropertyKey[]): input is X
              • Parameters

                • input: any
                • state: State
                • path: PropertyKey[]

                Returns input is X

          • f: ((state: State, input: X, path: PropertyKey[]) => [State, O])

            Function that swaps matching values.

              • (state: State, input: X, path: PropertyKey[]): [State, O]
              • Parameters

                • state: State
                • input: X
                • path: PropertyKey[]

                Returns [State, O]

          • state: State

            Some additional context you need in the process. likey you'll start with [].

          Returns MatchRecord<T, ((input: I) => O)>

        Generated using TypeDoc