Skip to content

Helpers

applesauce-core and other packages export a bunch of helper methods for working with events bunch of methods to get data from events

WARNING

Some helper methods my throw errors. so make sure to have error handling and use the isValid* helpers to filter out invalid events

Core helpers

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

The helpers are broken into multiple categories based on what they can be used for, mailboxes, zaps, profiles, and a lot more

Events

Profiles

Mailboxes

Comments

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

Zaps

Lightning

Pointers

Delete events

Emojis

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

Factory Helpers

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

Some of the most useful ones are