Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
flintinatux committed Oct 30, 2018
1 parent e4f6953 commit a9be479
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
<p align="center">
<a href="https://www.npmjs.com/package/tinyfunk"><img src="https://img.shields.io/npm/v/tinyfunk.svg" alt="npm version" style="max-width:100%;"></a>
<a href="https://www.npmjs.com/package/tinyfunk"><img src="https://img.shields.io/npm/dm/tinyfunk.svg" alt="npm downloads" style="max-width:100%;"></a>
<a href="#"><img src="https://img.shields.io/badge/gzip--size-1.52%20kB-blue.svg" alt="gzip-size" style="max-width:100%;"></a>
<a href="#"><img src="https://img.shields.io/badge/gzip--size-1.53%20kB-blue.svg" alt="gzip-size" style="max-width:100%;"></a>
<br />
<a href="https://travis-ci.org/flintinatux/tinyfunk"><img src="https://travis-ci.org/flintinatux/tinyfunk.svg?branch=master" alt="Build Status" style="max-width:100%;"></a>
<a href="https://coveralls.io/github/flintinatux/tinyfunk?branch=master"><img src="https://coveralls.io/repos/github/flintinatux/tinyfunk/badge.svg?branch=master" alt="Coverage Status" style="max-width:100%;"></a>
<a href="https://nodesecurity.io/orgs/flintinatux/projects/d5f96f7c-898a-4244-a9d2-4f3c429d5f3d"><img src="https://nodesecurity.io/orgs/flintinatux/projects/d5f96f7c-898a-4244-a9d2-4f3c429d5f3d/badge" alt="NSP Status" style="max-width:100%;"></a>
</p>

## Documentation
Expand Down Expand Up @@ -137,6 +136,7 @@ If you've lived with FP long enough, you are likely familiar with most of the fu
| `tail` | `[a] -> [a]` |
| `take` | `Number -> [a] -> [a]` |
| `tap` | `(a -> b) -> a -> a` |
| `test` | `RegExp -> String -> Boolean` |
| `then` | `(a -> Promise b) -> a -> Promise b` |
| `thrush` | `a -> (a -> b) -> b` |
| `unapply` | `([a] -> b) -> a... -> b` |
Expand Down
6 changes: 6 additions & 0 deletions src.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ const tap = curry((f, x) =>
(f(x), x)
)

// test :: RegExp -> String -> Boolean
const test = curry((regexp, string) =>
regexp.test(string)
)

// then :: (a -> Promise b) -> a -> Promise b
const then = curry((f, x) =>
Promise.resolve(x).then(f)
Expand Down Expand Up @@ -474,6 +479,7 @@ _assign(exports, {
tail,
take,
tap,
test,
then,
thrush,
unapply,
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { expect } = require('chai')

const { test } = require('..')

describe('test', () => {
const pattern = /good/

it('tests a string against a RegExp', () => {
expect(test(pattern, 'good news')).to.be.true
expect(test(pattern, 'bad news')).to.be.false
})

it('is curried', () =>
expect(test(pattern)('good news')).to.be.true
)
})
2 changes: 1 addition & 1 deletion tinyfunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9be479

Please sign in to comment.