开发者社区> 镜像站> NPM> ssb-audio-schema
ssb-audio-schema
JSON schemas + validators for audio messages
Last updated a year ago by mixmix .
AGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ssb-audio-schema 
SYNC missed versions from official npm registry.

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

Field type description
type String must be "audio"
blob String has to be a valid ssb-blob ref
format String (optional) min-length of 2, see IANA audio formats
duration Number (optional) length of the audio in seconds
size Integer (optional) size of the audio in bytes

See also

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

Current Tags

  • 1.0.3                                ...           latest (a year ago)

4 Versions

  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (3)
Dependents (0)
None