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/src/types.ts CHANGED
@@ -1,7 +1,14 @@
1
-
2
- export type Cond = (...xs: any[]) => boolean
3
- export interface AnyObject {
4
- [k: string]: any
5
- }
6
- export type Reducer = <T>(accum: T, cur: any, index: number) => T
7
- export type AnyFunc = (...args: any[]) => any
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'
@@ -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)
@@ -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
- "lib": [ "esnext", "DOM" ],
4
- "strictNullChecks": true,
5
- "target": "esnext",
6
- "module": "esnext",
7
- "allowJs": false,
8
- "sourceMap": false,
9
- "emitDecoratorMetadata": true,
10
- "experimentalDecorators": true,
11
- "noUnusedParameters": true,
12
- "noUnusedLocals": false,
13
- "outDir": "dist/es",
14
- "rootDir": "src",
15
- "baseUrl": "."
16
- },
17
- "include": [
18
- "src/**/*",
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
  }