pepka 0.12.2 → 0.13.0-b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +19 -19
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
- package/CODE_OF_CONDUCT.md +76 -76
- package/CONTRIBUTING.md +3 -3
- package/LICENSE +21 -21
- package/README.md +36 -10
- package/dist/bundle.d.ts +18 -11
- package/dist/bundle.dev.js +119 -77
- package/dist/bundle.js +1 -1
- package/dist/es/quick.js +1 -0
- package/dist/es/types.js +1 -0
- package/package.json +14 -16
- package/rollup.config.js +34 -33
- package/src/common.ts +14 -14
- package/src/curry.ts +99 -53
- package/src/index.ts +6 -5
- package/src/quick.ts +98 -97
- package/src/safe.ts +392 -404
- package/src/types.ts +14 -7
- package/src/uncurry.ts +11 -0
- package/src/utils.ts +11 -11
- package/test/in-browser.ts +3 -3
- package/test/workbench.html +9 -9
- package/tsconfig.json +18 -20
- package/tslint.json +24 -24
package/src/types.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
|
|
1
|
+
export type Cond = (...xs: any[]) => boolean
|
|
2
|
+
export interface AnyObject {
|
|
3
|
+
[k: string]: any
|
|
4
|
+
}
|
|
5
|
+
export type AnyArgs = any[]
|
|
6
|
+
export type Curried<
|
|
7
|
+
Args extends AnyArgs = AnyArgs,
|
|
8
|
+
ReturnT = any
|
|
9
|
+
> = (arg: Args[number]) => Curried<Args> | ReturnT
|
|
10
|
+
export type Reducer = <T>(accum: T, cur: any, index: number) => T
|
|
11
|
+
export type AnyFunc<
|
|
12
|
+
ReturnT = any,
|
|
13
|
+
Args extends AnyArgs = AnyArgs
|
|
14
|
+
> = (...args: Args) => ReturnT
|
package/src/uncurry.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { qreduce } from "./quick"
|
|
2
|
+
import { AnyFunc, Curried } from "./types"
|
|
3
|
+
|
|
4
|
+
// TODO: possibly introduce a second argument limiting unfolding.
|
|
5
|
+
export const uncurry = <
|
|
6
|
+
Args extends any[] = any[],
|
|
7
|
+
ReturnT = any
|
|
8
|
+
>(fn: Curried<Args>): AnyFunc =>
|
|
9
|
+
(...args: Args) => qreduce(
|
|
10
|
+
((fn: Curried<Args>, arg: any) => fn ? fn(arg) : fn), fn, args
|
|
11
|
+
) as ReturnT
|
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const undef = undefined
|
|
4
|
-
export const nul = null
|
|
5
|
-
export const to = (s: any) => typeof s
|
|
6
|
-
export const isNull = (s: any) => s===nul
|
|
7
|
-
export const isUndef = (s: any) => s===undef
|
|
8
|
-
export const isNum = (s: any) => to(s)=='number'
|
|
9
|
-
export const isArray = (s: any) => Array.isArray(s)
|
|
10
|
-
export const isFunc = (s: any) => to(s)==='function'
|
|
11
|
-
export const isStr = (s: any) => to(s)==='string'
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const undef = undefined
|
|
4
|
+
export const nul = null
|
|
5
|
+
export const to = (s: any) => typeof s
|
|
6
|
+
export const isNull = (s: any) => s===nul
|
|
7
|
+
export const isUndef = (s: any) => s===undef
|
|
8
|
+
export const isNum = (s: any) => to(s)=='number'
|
|
9
|
+
export const isArray = (s: any) => Array.isArray(s)
|
|
10
|
+
export const isFunc = (s: any) => to(s)==='function'
|
|
11
|
+
export const isStr = (s: any) => to(s)==='string'
|
|
12
12
|
export const isObj = (s: any) => !isNull(s) && to(s)==='object'
|
package/test/in-browser.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as pepka from '../src/index'
|
|
2
|
-
|
|
3
|
-
;(window as any).pepka = pepka
|
|
1
|
+
import * as pepka from '../src/index'
|
|
2
|
+
|
|
3
|
+
;(window as any).pepka = pepka
|
|
4
4
|
;Object.assign((window as any), pepka)
|
package/test/workbench.html
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>pepka's workbench</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<script src="../dist/bundle.dev.js"></script>
|
|
9
|
-
</body>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>pepka's workbench</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<script src="../dist/bundle.dev.js"></script>
|
|
9
|
+
</body>
|
|
10
10
|
</html>
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"src/node_modules/ts-toolbelt/out/index.d.ts"
|
|
20
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"moduleResolution": "Node",
|
|
4
|
+
"lib": [ "esnext", "DOM" ],
|
|
5
|
+
"strictNullChecks": true,
|
|
6
|
+
"target": "esnext",
|
|
7
|
+
"module": "esnext",
|
|
8
|
+
"allowJs": false,
|
|
9
|
+
"sourceMap": false,
|
|
10
|
+
"emitDecoratorMetadata": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"noUnusedParameters": true,
|
|
13
|
+
"noUnusedLocals": false,
|
|
14
|
+
"outDir": "dist/es",
|
|
15
|
+
"rootDir": "src",
|
|
16
|
+
"baseUrl": "."
|
|
17
|
+
},
|
|
18
|
+
"include": [ "src/**/*" ]
|
|
21
19
|
}
|
package/tslint.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"defaultSeverity": "error",
|
|
3
|
-
"jsRules": {},
|
|
4
|
-
"rules": {
|
|
5
|
-
"semicolon": false,
|
|
6
|
-
"whitespace": false,
|
|
7
|
-
"quotemark": [true, "single"],
|
|
8
|
-
"max-line-length": {
|
|
9
|
-
"options": [120]
|
|
10
|
-
},
|
|
11
|
-
"new-parens": true,
|
|
12
|
-
"no-arg": true,
|
|
13
|
-
"no-console": {
|
|
14
|
-
"severity": "warning",
|
|
15
|
-
"options": [
|
|
16
|
-
"debug",
|
|
17
|
-
"info",
|
|
18
|
-
"time",
|
|
19
|
-
"timeEnd",
|
|
20
|
-
"trace"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"rulesDirectory": []
|
|
1
|
+
{
|
|
2
|
+
"defaultSeverity": "error",
|
|
3
|
+
"jsRules": {},
|
|
4
|
+
"rules": {
|
|
5
|
+
"semicolon": false,
|
|
6
|
+
"whitespace": false,
|
|
7
|
+
"quotemark": [true, "single"],
|
|
8
|
+
"max-line-length": {
|
|
9
|
+
"options": [120]
|
|
10
|
+
},
|
|
11
|
+
"new-parens": true,
|
|
12
|
+
"no-arg": true,
|
|
13
|
+
"no-console": {
|
|
14
|
+
"severity": "warning",
|
|
15
|
+
"options": [
|
|
16
|
+
"debug",
|
|
17
|
+
"info",
|
|
18
|
+
"time",
|
|
19
|
+
"timeEnd",
|
|
20
|
+
"trace"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"rulesDirectory": []
|
|
25
25
|
}
|