-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
78 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cat | ||
===== | ||
|
||
Usage: ```cat(...)``` | ||
|
||
Returns a regex op that matches (all) values in sequence, returning a map | ||
containing the keys of each pred and the corresponding value. | ||
|
||
[Source](https://github.com/mrijk/speculaas/blob/master/lib/cat.js) | ||
|
||
Example: | ||
|
||
```js | ||
const s = require('speculaas'); | ||
const {isBoolean, isString} = s.utils; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
getSpec | ||
===== | ||
|
||
Usage: ```getSpec(k)``` | ||
|
||
Returns spec registered for keyword/symbol/var k, or undefined. | ||
|
||
[Source](https://github.com/mrijk/speculaas/blob/master/lib/def.js) | ||
|
||
Example: | ||
|
||
```js | ||
const s = require('speculaas'); | ||
const {isOdd} = s.utils; | ||
|
||
s.def('::odd?', isOdd); | ||
s.getSpec('::odd?'); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const {expect} = require('chai'); | ||
|
||
const s = require('../lib/spec'); | ||
const {isOdd} = s.utils; | ||
|
||
describe('Test the define function', () => { | ||
|
||
it('should allow an array as predicate', () => { | ||
const suit = [':club', ':diamond', ':heart', ':spade']; | ||
s.def('::suit', suit); | ||
expect(s.isValid('::suit', ':club')).to.be.true; | ||
}); | ||
|
||
it('should accept a Symbol', () => { | ||
const odd = Symbol(); | ||
s.def(odd, isOdd); | ||
expect(s.isValid(odd, 13)).to.be.true; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const {expect} = require('chai'); | ||
|
||
const s = require('../lib/spec'); | ||
const {isOdd, isInteger} = s.utils; | ||
|
||
describe('Test the getSpec function', () => { | ||
|
||
it('should return an existing spec', () => { | ||
s.def('::odd?', s.and(isInteger, isOdd)); | ||
expect(s.getSpec('::odd?')).to.exist; | ||
}); | ||
|
||
it('should return null on an non-existing spec', () => { | ||
expect(s.getSpec('::foobar?')).to.be.undefined; | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.