@ject/pipe
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -5,25 +5,17 @@ 'use strict'; | ||
var oneself = require('@ject/oneself'); | ||
var nullish = require('@typen/nullish'); | ||
const duopipe = (alpha, beta) => { | ||
let a = nullish.nullish(alpha), | ||
b = nullish.nullish(beta); | ||
if (!a && !b) return x => beta(alpha(x)); | ||
if (!a) return alpha; | ||
if (!b) return beta; | ||
return oneself.oneself; | ||
if (!alpha) return beta; | ||
if (!beta) return alpha; | ||
return x => beta(alpha(x)); | ||
}; | ||
const pipemany = (...funcs) => { | ||
var _func; | ||
let l = funcs.length, | ||
func = void 0, | ||
temp = void 0; | ||
let size = funcs.length, | ||
func, | ||
temp; | ||
while (l >= 0) if (func = funcs[l--]) break; | ||
while (size >= 0) if (func = funcs[size--]) break; | ||
while (l >= 0) if (temp = funcs[l--]) func = duopipe(temp, func); | ||
while (size >= 0) if (temp = funcs[size--]) func = duopipe(temp, func); | ||
return (_func = func) !== null && _func !== void 0 ? _func : oneself.oneself; | ||
return func; | ||
}; | ||
@@ -30,0 +22,0 @@ const pipe = (...funcs) => { |
@@ -1,24 +0,16 @@ | ||
import { oneself } from '@ject/oneself'; | ||
import { nullish } from '@typen/nullish'; | ||
const duopipe = (alpha, beta) => { | ||
let a = nullish(alpha), | ||
b = nullish(beta); | ||
if (!a && !b) return x => beta(alpha(x)); | ||
if (!a) return alpha; | ||
if (!b) return beta; | ||
return oneself; | ||
if (!alpha) return beta; | ||
if (!beta) return alpha; | ||
return x => beta(alpha(x)); | ||
}; | ||
const pipemany = (...funcs) => { | ||
var _func; | ||
let l = funcs.length, | ||
func = void 0, | ||
temp = void 0; | ||
let size = funcs.length, | ||
func, | ||
temp; | ||
while (l >= 0) if (func = funcs[l--]) break; | ||
while (size >= 0) if (func = funcs[size--]) break; | ||
while (l >= 0) if (temp = funcs[l--]) func = duopipe(temp, func); | ||
while (size >= 0) if (temp = funcs[size--]) func = duopipe(temp, func); | ||
return (_func = func) !== null && _func !== void 0 ? _func : oneself; | ||
return func; | ||
}; | ||
@@ -25,0 +17,0 @@ const pipe = (...funcs) => { |
{ | ||
"name": "@ject/pipe", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Util for functions", | ||
@@ -17,6 +17,2 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"dependencies": { | ||
"@ject/oneself": "^0.0.2", | ||
"@typen/nullish": "^0.1.5" | ||
}, | ||
"repository": { | ||
@@ -36,3 +32,3 @@ "type": "git", | ||
"homepage": "https://github.com/hoyeungw/ject#readme", | ||
"gitHead": "010a3b2c7f22f87d6de66d1e7958d2a07ef525a0" | ||
"gitHead": "adaf96f56fe0e1549e5742816fb34faca21eaf51" | ||
} |
0
4587
57
- Removed@ject/oneself@^0.0.2
- Removed@typen/nullish@^0.1.5
- Removed@ject/oneself@0.0.2(transitive)
- Removed@typen/nullish@0.1.19(transitive)