Skip to content

Helpers

applesauce-core and other packages export helper methods for working with events.

WARNING

Some helper methods may throw errors. make sure your app can handle errors correctly.

Core helpers

The applesauce-core package contains the majority of the helper methods

Events

Profiles

Mailboxes

Event relays

  • addSeenRelay Adds a relay to the list of relay the event was seen on
  • getSeenRelays Get the list of relays this event was seen on

Pointers

Delete events

URLs

  • getURLFilename returns the filename part fo the path in a URL
  • isAudioURL Checks if the URL ends with a audio file extension
  • isVideoURL Checks if the URL ends with a video file extension
  • isImageURL Checks if the URL ends with a image file extension
  • isStreamURL Checks if the URL ends with a stream file extension

Tags

  • isETag Checks if tag is an "e" tag and has at least one value
  • isATag Checks if tag is an "a" tag and has at least one value
  • isPTag Checks if tag is an "p" tag and has at least one value
  • isDTag Checks if tag is an "d" tag and has at least one value
  • isRTag Checks if tag is an "r" tag and has at least one value
  • isTTag Checks if tag is an "t" tag and has at least one value

Hidden Tags

Hidden tags are used in NIP-51 lists and NIP-60 wallets

Filters

Time

  • unixNow Returns the current unix timestamp

Common helpers

The applesauce-common package exports helpers for NIP-specific event kinds (comments, zaps, lightning, emoji packs, etc).

Comments (NIP-22)

Zaps (NIP-57)

Lightning

Emoji packs (NIP-30)

  • getEmojiTag Gets an "emoji" tag that matches an emoji code

Factory Helpers

The applesauce-core package exports some helpers for building events and tags

Some of the most useful ones are