Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "liftjs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"homepage": "https://github.com/atomable/lift.js/", | ||
@@ -5,0 +5,0 @@ "description": "lift.js is a compact monad opinionated javascript library", |
120
README.md
@@ -20,9 +20,9 @@ # lift.js | ||
```javascript | ||
lift(name, func); | ||
lift(name, func); | ||
``` | ||
```javascript | ||
const justWithLog = Just(5); | ||
Just.lift('log', value => should(value).equal(5)); | ||
justWithLog.log(); | ||
// console> 5 | ||
const justWithLog = Just(5); | ||
Just.lift('log', console.log); | ||
justWithLog.log(); | ||
// console> 5 | ||
``` | ||
@@ -33,10 +33,10 @@ | ||
```javascript | ||
const Person = Monad(); | ||
const person = Person({ firstname: 'Bill', lastname: 'Murray' }); | ||
const Person = Monad(); | ||
const person = Person({ firstname: 'Bill', lastname: 'Murray' }); | ||
const FullName = Monad(); | ||
Person.lift('compose', person => FullName(`${person.firstname}, ${person.lastname}`)); | ||
const FullName = Monad(); | ||
Person.lift('compose', person => FullName(`${person.firstname}, ${person.lastname}`)); | ||
person.compose().run(console.log); | ||
// console> Bill, Murray | ||
person.compose().run(console.log); | ||
// console> Bill, Murray | ||
``` | ||
@@ -50,27 +50,27 @@ | ||
```javascript | ||
bind(func, args) | ||
bind(func, args) | ||
``` | ||
```javascript | ||
const justWithValue = Just(5).bind((value)=> Just(value)); | ||
const justWithValue = Just(5).bind((value)=> Just(value)); | ||
// Just[5] | ||
// Just[5] | ||
``` | ||
### of, alias: pure | ||
```javascript | ||
of(value) | ||
of(value) | ||
``` | ||
```javascript | ||
const justWithValue = Just(5).of(6); | ||
// Just[6] | ||
const justWithValue = Just(5).of(6); | ||
// Just[6] | ||
const justWithValue = Just(5).of(Just(6)); | ||
// Just[6] | ||
const justWithValue = Just(5).of(Just(6)); | ||
// Just[6] | ||
``` | ||
### get | ||
```javascript | ||
get() | ||
get() | ||
``` | ||
```javascript | ||
const value = Just(5).get(); | ||
//5 | ||
const value = Just(5).get(); | ||
//5 | ||
``` | ||
@@ -80,7 +80,7 @@ | ||
```javascript | ||
map(func) | ||
map(func) | ||
``` | ||
```javascript | ||
const justWithValue = Just(7).map(value => value * 2); | ||
// Just[14] | ||
const justWithValue = Just(7).map(value => value * 2); | ||
// Just[14] | ||
``` | ||
@@ -90,15 +90,15 @@ | ||
```javascript | ||
join() | ||
join() | ||
``` | ||
```javascript | ||
const justWithValue = Just(Just(5)).join() | ||
// Just[5] | ||
const justWithValue = Just(Just(5)).join() | ||
// Just[5] | ||
``` | ||
### toMaybe | ||
```javascript | ||
toMaybe() | ||
toMaybe() | ||
``` | ||
```javascript | ||
const maybeWithValue = Just(5).toMaybe(); | ||
// Maybe[5] | ||
const maybeWithValue = Just(5).toMaybe(); | ||
// Maybe[5] | ||
``` | ||
@@ -108,7 +108,7 @@ | ||
```javascript | ||
run(func) | ||
run(func) | ||
``` | ||
```javascript | ||
Just(5).run(value => console.log(value)); | ||
// console> 5 | ||
Just(5).run(value => console.log(value)); | ||
// console> 5 | ||
``` | ||
@@ -120,19 +120,19 @@ | ||
```javascript | ||
none() | ||
none() | ||
``` | ||
```javascript | ||
const maybeWithValue = Maybe().none() | ||
// Maybe[] | ||
const maybeWithValue = Maybe().none() | ||
// Maybe[] | ||
const maybeWithValue = Maybe().nothing() | ||
// Maybe[] | ||
const maybeWithValue = Maybe().nothing() | ||
// Maybe[] | ||
const maybeWithValue = Maybe() | ||
// Maybe[] | ||
const maybeWithValue = Maybe() | ||
// Maybe[] | ||
const maybeWithValue = Maybe(undefined) | ||
// Maybe[] | ||
const maybeWithValue = Maybe(undefined) | ||
// Maybe[] | ||
const maybeWithValue = Maybe(null) | ||
// Maybe[] | ||
const maybeWithValue = Maybe(null) | ||
// Maybe[] | ||
``` | ||
@@ -142,7 +142,7 @@ | ||
```javascript | ||
isNone() | ||
isNone() | ||
``` | ||
```javascript | ||
const value = Maybe(5).isNone(); | ||
// false | ||
const value = Maybe(5).isNone(); | ||
// false | ||
``` | ||
@@ -152,7 +152,7 @@ | ||
```javascript | ||
isJust() | ||
isJust() | ||
``` | ||
```javascript | ||
const value = Maybe(5).isJust(); | ||
// true | ||
const value = Maybe(5).isJust(); | ||
// true | ||
``` | ||
@@ -162,7 +162,7 @@ | ||
```javascript | ||
orJust() | ||
orJust() | ||
``` | ||
```javascript | ||
const maybeWithValue = Maybe().orJust(15); | ||
// Maybe[15] | ||
const maybeWithValue = Maybe().orJust(15); | ||
// Maybe[15] | ||
``` | ||
@@ -172,10 +172,10 @@ | ||
```javascript | ||
orElse(monad) | ||
orElse(monad) | ||
``` | ||
```javascript | ||
const maybeWithValue = Maybe(5).orElse(Maybe(15)); | ||
// Maybe[5] | ||
const maybeWithValue = Maybe(5).orElse(Maybe(15)); | ||
// Maybe[5] | ||
const maybeWithValue = Maybe().orElse(Just(15)); | ||
// Just[5] | ||
const maybeWithValue = Maybe().orElse(Just(15)); | ||
// Just[5] | ||
``` | ||
@@ -196,2 +196,2 @@ | ||
Based on [Douglas Crockford MONAD](https://github.com/douglascrockford/monad/blob/master/monad.js). | ||
Special thanks to [Monet](https://github.com/cwmyers/monet.js) for the inspiration. | ||
Special thanks to [Monet](https://github.com/cwmyers/monet.js) for the inspiration. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186
25787