Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ben-ng/umpire
A logical framework for Javascript
https://github.com/ben-ng/umpire
Last synced: 21 days ago
JSON representation
A logical framework for Javascript
- Host: GitHub
- URL: https://github.com/ben-ng/umpire
- Owner: ben-ng
- Created: 2014-06-29T01:07:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-29T08:09:00.000Z (over 10 years ago)
- Last Synced: 2024-10-13T11:44:34.120Z (26 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.org/package/umpire
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Umpire
[![Build Status](https://travis-ci.org/ben-ng/umpire.svg?branch=master)](https://travis-ci.org/ben-ng/umpire)
[![browser support](https://ci.testling.com/ben_ng/umpire.png)
](https://ci.testling.com/ben_ng/umpire)A logical framework.
## Usage
```javascript
var theory = new Umpire()theory.defineType('Real'
// Definitions should return what they matched
, function (token) {
var match = token.match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/)if(match) {
return match[0]
}
// If no match is possible, return false
else {
return false
}
})// Match on [Real, Real, ...]
theory.defineType('Vector', ['[', theory.repeat('Real', ','),']'])// Match on [Vector, Vector, ...]
theory.defineType('Matrix', ['[', theory.repeat('Vector', ','),']'])/// Assert on types
t.equal(theory.getType('0'), 'Real')
t.equal(theory.getType('-10.3e-9'), 'Real')
t.equal(theory.getType('-10.3ee'), false)
t.equal(theory.getType('[-1.3e9, 3]'), 'Vector')
t.equal(theory.getType('[[1, 2],[3, 4]]'), 'Matrix')
```