-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from functional-jslib/next-curry-refactor
Next curry refactor
- Loading branch information
Showing
27 changed files
with
1,669 additions
and
1,688 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env']], | ||
plugins: [ | ||
'@babel/plugin-syntax-object-rest-spread', | ||
'@babel/plugin-proposal-object-rest-spread' | ||
presets: [ | ||
'@babel/preset-typescript', | ||
'@babel/preset-env' | ||
] | ||
}; |
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
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import {curry} from '../function/curry'; | ||
import {BinaryPred} from "../types"; | ||
|
||
export const | ||
|
||
/** | ||
* Equality operator. | ||
* @function module:boolean.equal | ||
* @param a {*} | ||
* @param b {*} | ||
* @param [a=undefined] {any} | ||
* @param [b=undefined] {any} | ||
* @returns {boolean} | ||
*/ | ||
equal = curry((a, b) => a === b); | ||
equal: BinaryPred<any> = curry((a, b) => a === b) as BinaryPred<any>; |
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import {curry2} from '../function/curry'; | ||
import {equal} from './equal'; | ||
import {PolyPred} from "../types"; | ||
|
||
export const | ||
/** | ||
* Equality operator for all. | ||
* @curried - Curried at upto 2 args. | ||
* @function module:boolean.equalAll | ||
* @param a {*} - Item `0`. | ||
* @param args {...*} - Others | ||
* @returns {boolean} | ||
*/ | ||
equalAll = curry2((a, ...args) => args.every(b => equal(a, b))); | ||
equalAll: PolyPred<any> = curry2((a, ...args) => | ||
args.every(b => equal(a, b)) | ||
) as PolyPred<any>; |
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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import {isset} from '../object/isset'; | ||
import {MapFunc} from "../types"; | ||
|
||
export const toFunctor = x => !isset(x) || !x.map ? new Functor(x) : x; | ||
export const toFunctor = (x: any): Functor<any> => !isset(x) || !x.map ? new Functor(x) : x; | ||
|
||
export default class Functor<T> { | ||
readonly value?:T; | ||
constructor(value?: T) {this.value = value;} | ||
readonly value?: T; | ||
|
||
constructor(value?: T) { | ||
this.value = value; | ||
} | ||
|
||
valueOf(): T { | ||
return this.value; | ||
} | ||
map(fn: (x: T) => T): Functor<T> { | ||
return new Functor(fn(this.valueOf())); | ||
|
||
map(fn: MapFunc<T, Functor<T>>): Functor<T> { | ||
return new Functor(fn(this.valueOf(), 0, this)); | ||
} | ||
fmap (fn: (x: T) => T): Functor<T> { | ||
|
||
fmap(fn: MapFunc<T, Functor<T>>): Functor<T> { | ||
return this.map(fn); | ||
} | ||
} |
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
Oops, something went wrong.