@matechs/effect
Advanced tools
Comparing version 0.1.0 to 0.1.1
/// <reference types="node" /> | ||
import { Eq } from "fp-ts/lib/Eq"; | ||
import { FunctionN, Lazy, Predicate } from "fp-ts/lib/function"; | ||
import { FunctionN, Lazy, Predicate, Refinement } from "fp-ts/lib/function"; | ||
import { Option } from "fp-ts/lib/Option"; | ||
@@ -136,2 +136,3 @@ import { ReadStream } from "fs"; | ||
export declare function filterWith<A>(f: Predicate<A>): <R, E>(stream: Stream<R, E, A>) => Stream<R, E, A>; | ||
export declare function filterRefineWith<A, B extends A>(f: Refinement<A, B>): <R, E>(stream: Stream<R, E, A>) => Stream<R, E, B>; | ||
/** | ||
@@ -317,4 +318,4 @@ * Filter the stream so that only items that are not equal to the previous item emitted are emitted | ||
} | ||
export declare const instances: Monad3E<URI>; | ||
export declare const streamMonad: Monad3E<URI>; | ||
export declare function fromObjectReadStream<A>(stream: ReadStream): managed.Managed<unknown, Error, Fold<unknown, Error, A>>; | ||
export declare function fromObjectReadStreamB<A>(stream: ReadStream, batch: number, every: number): managed.Managed<unknown, Error, Fold<unknown, Error, A[]>>; |
@@ -370,2 +370,8 @@ "use strict"; | ||
exports.filterWith = filterWith; | ||
function filterRefineWith(f) { | ||
return function (stream) { | ||
return map(filter(stream, function (x) { return f(x); }), function (x) { return x; }); | ||
}; | ||
} | ||
exports.filterRefineWith = filterRefineWith; | ||
/** | ||
@@ -969,3 +975,3 @@ * Filter the stream so that only items that are not equal to the previous item emitted are emitted | ||
exports.URI = "matechs/Stream"; | ||
exports.instances = { | ||
exports.streamMonad = { | ||
URI: exports.URI, | ||
@@ -972,0 +978,0 @@ map: map, |
{ | ||
"name": "@matechs/effect", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -40,3 +40,3 @@ "private": false, | ||
}, | ||
"gitHead": "86484c8317b3d971fd95909e5b08257c3a7b6a58" | ||
"gitHead": "d2c0657b6e2940317fedebd428f96bc9c65908f0" | ||
} |
@@ -6,46 +6,3 @@ # Introduction | ||
It aims to provide a strong foundational block to build typescript code in a more testable and standardized way. | ||
This library is composed at its core by the `@matechs/effect` package that exposes 2 effects | ||
- `type Effect<R, E, A> = (r: R) => Wave<E, A>` | ||
The underlying `Wave` is provided by `Waveguide`. | ||
You can think of this type as a computation that requires an environment `R` to run. | ||
The module exposes 2 instances of the typeclass `type EffectMonad<T extends URIS3> = Monad3E<T> & MonadThrow3<T> & Bifunctor3<T>`: | ||
- `effectMonad` for `Effect<R, E, A>` | ||
- `concurrentEffectMonad` for `Effect<R, E, A>` provides concurrent `ap` | ||
Pipeable functions are also exported for both instances (default `Effect`, `parAp`, `parApFirst`, `parApSecond` for parallel) | ||
Interesting integrations and usage examples can be found in `packages/orm`, `packages/http`, `packages/rpc`, `packages/tracing` | ||
## Details | ||
For details about the additional types and overloads please refer to documentation in `packages/effect` | ||
## Notes | ||
This package is a work in progress syntax and functions might change, feedback are welcome and contributions even more! | ||
The primary difference with waveguide itself is in how we manage the `R` parameter and in the utilities that we provide around environment management. The focus on this library is making environmental effects easy while providing valuable integrations out of the box where `Waveguide` itself poses primary focus around the underlying `Wave<E, A>` | ||
## Ecosystem | ||
- `@matechs/tracing` : provides integration with opentracing-js | ||
- `@matechs/http` : provides integration with axios | ||
- `@matechs/orm` : provides integration with typeorm | ||
- `@matechs/rpc` : no boilerplate rpc for your effects | ||
- `@matechs/express` : provides integration with express | ||
- `@matechs/graceful` : utility to handle graceful exit | ||
## Thanks | ||
This library would have not been feasibly possible without the strong foundations of [fp-ts](https://github.com/gcanti/fp-ts) and [Waveguide](https://github.com/rzeigler/waveguide) & huge thanks to the Authors. | ||
Another huge thanks goes to both the scala community (ZIO in specific) and the haskell community (RIO & Polysemy) from which inspiration is taken. | ||
All of the above projects are advised! | ||
# Notes | ||
The best place to look for concrete usage are tests & demo folders of each package |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5134
0
286453
7