1.0.3 • Published 5 years ago

ssb-audio-schema v1.0.3

Weekly downloads
3
License
AGPL-3.0
Repository
github
Last release
5 years ago

ssb-audio-schema

a module which provides you schemas and validators for audio messages

Example Usage

var { isAudio } = require('ssb-audio-schema')

const testMsg = {
  type: 'audio',
  blob: '&dEBa9Ujhrydu3A07QiuSosPmU9JwKkXpq4AKgi8PYPc=.sha256',
  format 'aac',
  duration: 10,
  size: 44
}
// can be the content of a message or the whole thing

isAudio(testMsg)
// => true

isAudio.errors
// => helpful errors from last failure (none in this case!)

API

isAudio(Object) -> Boolean

Object can be a full message from the log, or just the content from the message, the validator will take care of it.

If the test Object fails the validation, errors are attached to the function (i.e. isAudio.errors, see Example Usage)

isAudio(Object, { attachErrors: true })

Notes of fields

Fieldtypedescription
typeStringmust be "audio"
blobStringhas to be a valid ssb-blob ref
formatString(optional) min-length of 2, see IANA audio formats
durationNumber(optional) length of the audio in seconds
sizeInteger(optional) size of the audio in bytes

See also

  • the README in each folder with a little more about each message type