https://github.com/poga/rats
javascript encoder/decoder for RATS
https://github.com/poga/rats
binaryformat compression protocol-buffers timeseries
Last synced: 11 months ago
JSON representation
javascript encoder/decoder for RATS
- Host: GitHub
- URL: https://github.com/poga/rats
- Owner: poga
- License: mit
- Created: 2017-02-03T11:37:51.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-24T21:14:41.000Z (almost 9 years ago)
- Last Synced: 2025-02-08T16:44:26.092Z (about 1 year ago)
- Topics: binaryformat, compression, protocol-buffers, timeseries
- Language: JavaScript
- Size: 37.1 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rats.js
JavaScript implementation for [RATS](https://github.com/random-access-timeseries/spec).
`npm i rats-js`
## Usage
```js
var RATS = require('rats')
var rats = new RATS('./rats')
rats.append({foo: 'bar'}, function (err) {})
rats.currentOffset // === 1
rats.get(0, function (err, data) {})
rats.range(0, 100, function (err, list) {})
```
## API
#### `var rats = new RATS(path, opts)`
Create a new RATS at `path`. Options `opts` include:
* maxSegmentSize: maximum size of a segment. default:5MB
#### `rats.currentOffset`
Returns the current offset.
#### `rats.append(object, [time], [cb(err)])`
Append an `object` to the RATS. you can specify the timestamp of this append with `time` (unix time in seconds).
#### `rats.currentIndex()`
The index file currently in use.
#### `rats.currentLog()`
The log file currently in use.
#### `rats.get(offset, cb(err, data))`
Get the data at `offset`.
#### `rats.range(startTime, [endTime], cb(err,list))`
Get the data(s) in the range.
`endTime` by default will be the timestamp of the last object in the RATS.
## License
The MIT License