https://github.com/nowsecure/interval-to-ltgt
Convert an interval string to a levelup style ltgt object
https://github.com/nowsecure/interval-to-ltgt
Last synced: 11 months ago
JSON representation
Convert an interval string to a levelup style ltgt object
- Host: GitHub
- URL: https://github.com/nowsecure/interval-to-ltgt
- Owner: nowsecure
- Created: 2015-03-25T10:17:08.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-27T18:19:06.000Z (over 10 years ago)
- Last Synced: 2025-07-12T14:03:26.402Z (12 months ago)
- Language: JavaScript
- Size: 103 KB
- Stars: 4
- Watchers: 9
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# interval-to-ltgt
Convert an interval string to a levelup style ltgt object.
This is the counterpart to [ltgt-to-interval](https://npmjs.org/package/ltgt-to-interval).
[](http://travis-ci.org/nowsecure/interval-to-ltgt)
## Example
```js
var toLtgt = require('interval-to-ltgt');
toLtgt('a,b'); // => { gte: 'a', lte: 'b' }
toLtgt('a,'); // => { gte: 'a' },
toLtgt(',b'); // => { lte: 'b' }
toLtgt('[a,b'); // => { gte: 'a', lte: 'b' }
toLtgt('(a,b'); // => { gt: 'a', lte: 'b' }
toLtgt('[a,b)'); // => { gte: 'a', lt: 'b' }
toLtgt(']a,b['); // => { gt: 'a', lt: 'b' }
```
## Installation
```bash
$ npm install interval-to-ltgt
```
## API
### toLtgt(str)
Parse `str` into an [levelup](https://npmjs.org/package/levelup) style ltgt object.
Intervals sides are inclusive by default, unless when using parens or
outward open square brackets.
## License
MIT