pepka 1.6.19 → 1.6.20

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/dist/bundle.cjs CHANGED
@@ -49,12 +49,8 @@ const endlessph = (fn) => {
49
49
  const zero = 0;
50
50
  function curry2(fn) {
51
51
  function curried2(a, ...args) {
52
- const withPlaceholder1 = a === __;
53
- const aln = args.length === 1;
54
- if (aln && withPlaceholder1)
55
- throw new Error('Senseless placeholder usage.');
56
- return aln
57
- ? withPlaceholder1
52
+ return args.length > zero
53
+ ? a === __
58
54
  ? endlessph((a) => fn(a, args[zero]))
59
55
  : fn(a, args[zero])
60
56
  : (b) => fn(a, b);
package/dist/bundle.mjs CHANGED
@@ -47,12 +47,8 @@ const endlessph = (fn) => {
47
47
  const zero = 0;
48
48
  function curry2(fn) {
49
49
  function curried2(a, ...args) {
50
- const withPlaceholder1 = a === __;
51
- const aln = args.length === 1;
52
- if (aln && withPlaceholder1)
53
- throw new Error('Senseless placeholder usage.');
54
- return aln
55
- ? withPlaceholder1
50
+ return args.length > zero
51
+ ? a === __
56
52
  ? endlessph((a) => fn(a, args[zero]))
57
53
  : fn(a, args[zero])
58
54
  : (b) => fn(a, b);
package/package.json CHANGED
@@ -41,7 +41,7 @@
41
41
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
42
42
  "all": "npm run dev && npm run prod"
43
43
  },
44
- "version": "1.6.19",
44
+ "version": "1.6.20",
45
45
  "devDependencies": {
46
46
  "@rollup/plugin-commonjs": "^29.0.0",
47
47
  "@rollup/plugin-node-resolve": "^16.0.3",
package/src/curry.ts CHANGED
@@ -68,26 +68,8 @@ type Curried2<p0, p1, ReturnT> = {
68
68
  (a: p0, b: p1): ReturnT
69
69
  }
70
70
 
71
- const curried2 =
72
- <p0, p1, ReturnT>(fn: (a: p0, b: p1) => ReturnT) => {
73
-
74
- const impl = (
75
- a: p0 | Placeholder,
76
- ...args: [b?: p1]
77
- ): ReturnT | ((b: p1) => ReturnT) => {
78
- if (args.length === 0) {
79
- return (b: p1) => fn(a as p0, b)
80
- }
81
- const b = args[0]
82
- return fn(a as p0, b as p1)
83
- }
84
-
85
- return impl as Curried2<p0, p1, ReturnT>
86
- }
87
-
88
-
89
71
  type Func2 = (a: any, b: any) => any
90
- const zero = 0
72
+ const zero = 0, one = 1
91
73
  export function curry2<Func extends Func2>(fn: Func) {
92
74
  type p0 = Parameters<Func>[0]
93
75
  type p1 = Parameters<Func>[1]
@@ -97,12 +79,8 @@ export function curry2<Func extends Func2>(fn: Func) {
97
79
  function curried2(a: p0 ): (b: p1) => ReturnT
98
80
  function curried2(a: p0, b: p1): ReturnT
99
81
  function curried2(a: p0 | Placeholder, ...args: [b?: p1]) {
100
- const withPlaceholder1 = a===__
101
- const aln = args.length===1
102
- if(aln && withPlaceholder1)
103
- throw new Error('Senseless placeholder usage.')
104
- return aln
105
- ? withPlaceholder1
82
+ return args.length>zero
83
+ ? a===__
106
84
  ? endlessph((a: p0) => fn(a, args[zero]) as ReturnType<Func>)
107
85
  : fn(a, args[zero]) as ReturnType<Func>
108
86
  : (b: p1) => fn(a, b) as Curried2<p0, p1, ReturnT>