New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

sleep-ref

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sleep-ref

Reference implementation of the SLEEP protocol.

Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
5
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

SLEEP

npm install sleep-ref

SLEEP is a protocol envisioned by @maxogden for open data publication and synchronization.

This project is meant to iterate on the spec through implementation and also to produce a module that is easily usable by other databases to expose their data with SLEEP.

Server

var sleep = require('sleep-ref')
  , http = require('http')
  ;

function getSequences (opts, cb) {
  var c = mydatabase.changes() // [{id:'uuid', seq:1}, {id:'uuid2', seq:3}]
  if (opts.include_data) c.forEach(function (c) {c.data = mydatabase.get(c.id)})
  cb(null, c)
}

var sl = sleep(getSequences)

http.createServer(function (req, resp) {
  sl.httpHandler(req, resp)
})

net.createServer(function (socket) {
  sl.netHandler(socket)
})

Client

var sleep = require('sleep-ref')
  , changes = sleep.client('http://localhost:8888/', {include_data})
  ;
changes.on('entry', function (entry) { console.log(entry) })
changes.on('end', function () { console.log('up to date') })

sleep.client(url[, opts]) takes all valid SLEEP options. The url responds to the following protocols: http:, https:, tcp:, and tls:. You can pass tls options to opts via the tls property.

Keywords

SLEEP

FAQs

Package last updated on 03 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts