yii-iiy / pipe.ts

🐚 pipe like promise for TS πŸ₯

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pipe.ts

🐚 pipe like promise for TS πŸ₯

🐌 Moved into fp.ts 🐌

test:

var y, z;
const result = new Pipe(1)
    .then(x => x + 1)
    .then(x => x * x)
    .then(x => x.toString())
    .then(x => x.toString())
    .run()
    .then(x => x + 5)
    .then(x => x + 0)
    .pop(x => (y = x + 1))
    .pop(x => (z = x + 1))
    .then(x => x + "c")
    .run()
    .pop();

console.log(result); // "450c"
console.log(y); // "4501"
console.log(z); // "4501"
var y, z;
const result = new Pipe(1)
    .then(x => x + 1)
    .then(x => x * x)
    .then(x => x.toString())
    .then(x => x.toString())
    .run()
    .then(x => x + 5)
    .then(x => x + 0)
    .pop(x => (y = x + 1))
    .pop(x => (z = x + 1))
    .then(x => x + "c")
    // .run()
    .pop();

console.log(result); // "4"
console.log(y); // "4501"
console.log(z); // "4501"
  • pop η”¨δΊŽε–ε€Ό
  • then η”¨δΊŽζ·»εŠ ι€»θΎ‘
  • run η”¨δΊŽθ§¦ε‘ι€»θΎ‘ζ‰§θ‘Œ

About

🐚 pipe like promise for TS πŸ₯

License:GNU Affero General Public License v3.0


Languages

Language:TypeScript 100.0%