@typed-f/function
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -6,2 +6,14 @@ # Change Log | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/Ailrun/typed-f/compare/v0.1.0...v0.2.0) (2018-08-22) | ||
### Features | ||
* **function:** add function monoid (id, compose, pipe) ([#13](https://github.com/Ailrun/typed-f/issues/13)) ([76618ae](https://github.com/Ailrun/typed-f/commit/76618ae)) | ||
<a name="0.1.0"></a> | ||
@@ -8,0 +20,0 @@ # [0.1.0](https://github.com/Ailrun/typed-f/compare/v0.0.1...v0.1.0) (2018-08-14) |
@@ -10,3 +10,9 @@ import { Fun } from './'; | ||
export declare type CurriedFun<F extends Function> = CurriedFun0<F> & CurriedFun1<F> & CurriedFun2<F> & CurriedFun3<F> & CurriedFun4<F>; | ||
/** | ||
* @todo | ||
* Return valid type for few arities like 0, 1, 2, 3, 4, 5, 6 | ||
* (We cannot give valid type for all arities since | ||
* there is no type arithematic operators for literal type). | ||
*/ | ||
export declare function curry<F extends Fun>(f: F, arity?: F extends Fun<infer A> ? A['length'] : number): CurriedFun<F>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _createCurried_1 = require("./_createCurried"); | ||
/** | ||
* @todo | ||
* Return valid type for few arities like 0, 1, 2, 3, 4, 5, 6 | ||
* (We cannot give valid type for all arities since | ||
* there is no type arithematic operators for literal type). | ||
*/ | ||
function curry(f, arity) { | ||
@@ -5,0 +11,0 @@ arity = arity !== undefined ? arity : f.length; |
{ | ||
"name": "@typed-f/function", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -27,6 +27,17 @@ "Utility", | ||
"build": "tsc -p ./tsconfig.json", | ||
"watch": "tsc -w -p ./tsconfig.json" | ||
"watch": "tsc -w -p ./tsconfig.json", | ||
"test:behaviour": "jest", | ||
"test:behaviour:coverage": "jest --collectCoverage", | ||
"test:lint": "run-s test:lint:*", | ||
"test:lint:src": "tslint -p . -c ./tslint.json -t codeFrame", | ||
"test:lint:tests": "tslint -p ./tests -c ./tests/tslint.json -t codeFrame" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^23.3.1", | ||
"@types/node": "^10.7.0", | ||
"jest": "^23.5.0", | ||
"npm-run-all": "^4.1.3", | ||
"rimraf": "^2.6.2", | ||
"ts-jest": "^23.1.3", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.0.1" | ||
@@ -37,3 +48,3 @@ }, | ||
}, | ||
"gitHead": "a1925ab6cb01347972f566478cc9c0fc289c2e31" | ||
"gitHead": "4e8bd2dfff44251ab307a094001a3377843a44cf" | ||
} |
@@ -0,4 +1,10 @@ | ||
/* | ||
* Copyright 2018-present Junyoung Clare Jang | ||
*/ | ||
import { Fun } from './'; | ||
export function _createCurried<F extends Fun>(f: F, arity: number, args: any[]) { | ||
export function _createCurried<F extends Fun>( | ||
f: F, arity: number, | ||
args: any[], | ||
) { | ||
function curried(this: any) { | ||
@@ -5,0 +11,0 @@ const length = arguments.length; |
@@ -0,1 +1,4 @@ | ||
/* | ||
* Copyright 2018-present Junyoung Clare Jang | ||
*/ | ||
import { Fun } from './'; | ||
@@ -5,4 +8,7 @@ | ||
interface CurriedFunApply<AS extends any[], F extends Function> extends Fun<AS, CurriedFun<F>> {} | ||
//tslint:disable-next-line: ban-types | ||
interface CurriedFunApply<AS extends any[], F extends Function> | ||
extends Fun<AS, CurriedFun<F>> {} | ||
//tslint:disable-next-line: ban-types | ||
type CurriedFun0<F extends Function> = | ||
@@ -15,2 +21,3 @@ F extends Fun ? ( | ||
never; | ||
//tslint:disable-next-line: ban-types | ||
type CurriedFun1<F extends Function> = | ||
@@ -23,2 +30,3 @@ F extends (a0: infer A0, ...args: infer A) => infer R ? ( | ||
never; | ||
//tslint:disable-next-line: ban-types | ||
type CurriedFun2<F extends Function> = | ||
@@ -31,3 +39,5 @@ F extends (a0: infer A0, a1: infer A1, ...args: infer A) => infer R ? ( | ||
never; | ||
//tslint:disable-next-line: ban-types | ||
type CurriedFun3<F extends Function> = | ||
//tslint:disable-next-line: max-line-length | ||
F extends (a0: infer A0, a1: infer A1, a2: infer A2, ...args: infer A) => infer R ? ( | ||
@@ -39,3 +49,5 @@ F extends Fun<[A0, A1, A2], R> ? | ||
never; | ||
//tslint:disable-next-line: ban-types | ||
type CurriedFun4<F extends Function> = | ||
//tslint:disable-next-line: max-line-length | ||
F extends (a0: infer A0, a1: infer A1, a2: infer A2, a3: infer A3, ...args: infer A) => infer R ? ( | ||
@@ -48,2 +60,3 @@ F extends Fun<[A0, A1, A2, A3], R> ? | ||
//tslint:disable-next-line: ban-types | ||
export type CurriedFun<F extends Function> = | ||
@@ -57,6 +70,13 @@ & CurriedFun0<F> | ||
export function curry<F extends Fun>(f: F, arity?: F extends Fun<infer A> ? A['length'] : number): CurriedFun<F> { | ||
arity = arity !== undefined ? arity : (f.length as F extends Fun<infer A> ? A['length'] : number); | ||
/** | ||
* @todo | ||
* Return valid type for few arities like 0, 1, 2, 3, 4, 5, 6 | ||
* (We cannot give valid type for all arities since | ||
* there is no type arithematic operators for literal type). | ||
*/ | ||
export function curry<F extends Fun>( | ||
f: F, | ||
arity: F extends Fun<infer A> ? A['length'] : number = f.length as any, | ||
): CurriedFun<F> { | ||
return _createCurried(f, arity, []) as any; | ||
} |
@@ -0,2 +1,8 @@ | ||
/* | ||
* Copyright 2018-present Junyoung Clare Jang | ||
*/ | ||
export * from './types'; | ||
export * from './id'; | ||
export * from './compose'; | ||
export * from './pipe'; | ||
export * from './curry'; |
@@ -0,1 +1,4 @@ | ||
/* | ||
* Copyright 2018-present Junyoung Clare Jang | ||
*/ | ||
export type Fun<A extends any[] = any[], R = any> = (...args: A) => R; |
@@ -6,3 +6,6 @@ { | ||
"outDir": "./dist" | ||
} | ||
}, | ||
"include": [ | ||
"./src" | ||
] | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24676
8
28
600