Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkrhere/shotgun
An opinionated micro DSL for object query and function call
https://github.com/mkrhere/shotgun
dsl object query
Last synced: 9 days ago
JSON representation
An opinionated micro DSL for object query and function call
- Host: GitHub
- URL: https://github.com/mkrhere/shotgun
- Owner: MKRhere
- Created: 2018-09-05T10:31:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-05T10:53:51.000Z (over 6 years ago)
- Last Synced: 2024-11-24T19:25:08.505Z (2 months ago)
- Topics: dsl, object, query
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shotgun
Shotgun is a DSL to query an object and call a function.
## Installation
```shell
npm install shotgun-query
```## Usage:
```JavaScript
const expect = thing =>
({ equals: otherThing => thing === otherThing });new Shotgun(" res.status equals 200 ")
.eval({ res: { status: 200 } })
.call(expect);
```## Convention
The function passed to `.call` must be of this signature:
```TypeScript
f = (arg : any) : object => ({
g : (...rest : any[]) : any => { ... },
...
});
```It will be called as such:
```JavaScript
f(a)[g](...rest)
```And the evaluation is returned.
## Tests
```shell
npm test
```