@effect-ts/system
Version:
Effect-TS is a zero dependency set of libraries to write highly productive, purely functional TypeScript at scale.
38 lines (30 loc) • 663 B
text/typescript
// ets_tracing: off
declare global {
interface Object {
/**
* To be used like
* ```ts
* T.succeed(1)["|>"](T.map(n => n + 1))["|>"](T.map(n => n + 2))
* ```
*
* @ets_optimize operator
*/
["|>"]<Self, Result>(this: Self, next: (value: Self) => Result): Result
}
}
let patched = false
export function patch() {
if (patched || Object.prototype["|>"]) {
return
}
Object.defineProperty(Object.prototype, "|>", {
value<Self, Result>(this: Self, next: (value: Self) => Result): Result {
return next(this)
},
enumerable: false,
writable: true
})
patched = true
}
patch()
export {}