Comparing version 1.1.6 to 1.2.0
@@ -401,2 +401,17 @@ function pipe(source) { | ||
function tap(f) { | ||
return function(source) { | ||
return function(sink) { | ||
return _1(source, function(signal) { | ||
if ("number" != typeof signal) { | ||
if (signal.tag) { | ||
_1(f, signal[0]); | ||
} | ||
} | ||
return sink(signal); | ||
}); | ||
}; | ||
}; | ||
} | ||
function map$1(f) { | ||
@@ -411,4 +426,4 @@ return function(source) { | ||
: signal.tag | ||
? __(1, [_1(f, signal[0])]) | ||
: __(0, [signal[0]]); | ||
? __(1, [_1(f, signal[0])]) | ||
: __(0, [signal[0]]); | ||
return sink(tmp); | ||
@@ -1077,4 +1092,5 @@ }); | ||
} else { | ||
talkback[0] = signal[0]; | ||
return talkback[0](0); | ||
var x = signal[0]; | ||
talkback[0] = x; | ||
return x(0); | ||
} | ||
@@ -1242,3 +1258,3 @@ }); | ||
return function(sink) { | ||
var skip = [!1]; | ||
var skip$$1 = [!1]; | ||
var id = [void 0]; | ||
@@ -1259,6 +1275,6 @@ var $$clearTimeout$1 = function(param) { | ||
} else if (signal.tag) { | ||
if (skip[0]) { | ||
if (skip$$1[0]) { | ||
return 0; | ||
} else { | ||
skip[0] = !0; | ||
skip$$1[0] = !0; | ||
$$clearTimeout$1(); | ||
@@ -1268,3 +1284,3 @@ id[0] = some( | ||
id[0] = void 0; | ||
skip[0] = !1; | ||
skip$$1[0] = !1; | ||
return 0; | ||
@@ -1408,2 +1424,16 @@ }, _1(throttleF, signal[0])) | ||
function toPromise(source) { | ||
return new Promise(function(resolve, param) { | ||
return _1(takeLast(1)(source), function(signal) { | ||
if ("number" == typeof signal) { | ||
return 0; | ||
} else if (signal.tag) { | ||
return resolve(signal[0]); | ||
} else { | ||
return signal[0](0); | ||
} | ||
}); | ||
}); | ||
} | ||
export { | ||
@@ -1419,2 +1449,3 @@ pipe, | ||
never, | ||
tap, | ||
map$1 as map, | ||
@@ -1444,3 +1475,4 @@ filter, | ||
sample, | ||
delay | ||
delay, | ||
toPromise | ||
}; |
@@ -221,2 +221,63 @@ function __(tag, block) { | ||
function takeLast(max) { | ||
return function(source) { | ||
return function(sink) { | ||
var queue = new Array(); | ||
return captureTalkback(source, function(signal, talkback) { | ||
if ("number" == typeof signal) { | ||
return (function makeTrampoline(sink, f) { | ||
var state = [!1, !1, !1]; | ||
return sink( | ||
__(0, [ | ||
function(signal) { | ||
var match = state[0]; | ||
if (signal || match) { | ||
return 0; | ||
} else { | ||
state[2] = !0; | ||
if (state[1]) { | ||
return 0; | ||
} else { | ||
state[1] = !0; | ||
!(function(_param) { | ||
while (1) { | ||
var match = f(); | ||
if (void 0 !== match) { | ||
state[2] = !1; | ||
sink(__(1, [valFromOption(match)])); | ||
if (state[2]) { | ||
continue; | ||
} else { | ||
return 0; | ||
} | ||
} else { | ||
state[0] = !0; | ||
return sink(0); | ||
} | ||
} | ||
})(); | ||
state[1] = !1; | ||
return 0; | ||
} | ||
} | ||
} | ||
]) | ||
); | ||
})(sink, function() { | ||
return queue.shift(); | ||
}); | ||
} else if (signal.tag) { | ||
if (queue.length >= max && max > 0) { | ||
queue.shift(); | ||
} | ||
queue.push(signal[0]); | ||
return talkback(0); | ||
} else { | ||
return talkback(0); | ||
} | ||
}); | ||
}; | ||
}; | ||
} | ||
function fromListener(addListener, removeListener) { | ||
@@ -424,2 +485,17 @@ return function(sink) { | ||
exports.tap = function tap(f) { | ||
return function(source) { | ||
return function(sink) { | ||
return _1(source, function(signal) { | ||
if ("number" != typeof signal) { | ||
if (signal.tag) { | ||
_1(f, signal[0]); | ||
} | ||
} | ||
return sink(signal); | ||
}); | ||
}; | ||
}; | ||
}; | ||
exports.map = function map$1(f) { | ||
@@ -434,4 +510,4 @@ return function(source) { | ||
: signal.tag | ||
? __(1, [_1(f, signal[0])]) | ||
: __(0, [signal[0]]); | ||
? __(1, [_1(f, signal[0])]) | ||
: __(0, [signal[0]]); | ||
return sink(tmp); | ||
@@ -758,62 +834,3 @@ }); | ||
exports.takeLast = function takeLast(max) { | ||
return function(source) { | ||
return function(sink) { | ||
var queue = new Array(); | ||
return captureTalkback(source, function(signal, talkback) { | ||
if ("number" == typeof signal) { | ||
return (function makeTrampoline(sink, f) { | ||
var state = [!1, !1, !1]; | ||
return sink( | ||
__(0, [ | ||
function(signal) { | ||
var match = state[0]; | ||
if (signal || match) { | ||
return 0; | ||
} else { | ||
state[2] = !0; | ||
if (state[1]) { | ||
return 0; | ||
} else { | ||
state[1] = !0; | ||
!(function(_param) { | ||
while (1) { | ||
var match = f(); | ||
if (void 0 !== match) { | ||
state[2] = !1; | ||
sink(__(1, [valFromOption(match)])); | ||
if (state[2]) { | ||
continue; | ||
} else { | ||
return 0; | ||
} | ||
} else { | ||
state[0] = !0; | ||
return sink(0); | ||
} | ||
} | ||
})(); | ||
state[1] = !1; | ||
return 0; | ||
} | ||
} | ||
} | ||
]) | ||
); | ||
})(sink, function() { | ||
return queue.shift(); | ||
}); | ||
} else if (signal.tag) { | ||
if (queue.length >= max && max > 0) { | ||
queue.shift(); | ||
} | ||
queue.push(signal[0]); | ||
return talkback(0); | ||
} else { | ||
return talkback(0); | ||
} | ||
}); | ||
}; | ||
}; | ||
}; | ||
exports.takeLast = takeLast; | ||
@@ -1101,4 +1118,5 @@ exports.takeWhile = function takeWhile(predicate) { | ||
} else { | ||
talkback[0] = signal[0]; | ||
return talkback[0](0); | ||
var x = signal[0]; | ||
talkback[0] = x; | ||
return x(0); | ||
} | ||
@@ -1246,3 +1264,3 @@ }); | ||
return function(sink) { | ||
var skip = [!1]; | ||
var skip$$1 = [!1]; | ||
var id = [void 0]; | ||
@@ -1263,6 +1281,6 @@ var $$clearTimeout$1 = function(param) { | ||
} else if (signal.tag) { | ||
if (skip[0]) { | ||
if (skip$$1[0]) { | ||
return 0; | ||
} else { | ||
skip[0] = !0; | ||
skip$$1[0] = !0; | ||
$$clearTimeout$1(); | ||
@@ -1272,3 +1290,3 @@ id[0] = some( | ||
id[0] = void 0; | ||
skip[0] = !1; | ||
skip$$1[0] = !1; | ||
return 0; | ||
@@ -1411,1 +1429,15 @@ }, _1(throttleF, signal[0])) | ||
}; | ||
exports.toPromise = function toPromise(source) { | ||
return new Promise(function(resolve, param) { | ||
return _1(takeLast(1)(source), function(signal) { | ||
if ("number" == typeof signal) { | ||
return 0; | ||
} else if (signal.tag) { | ||
return resolve(signal[0]); | ||
} else { | ||
return signal[0](0); | ||
} | ||
}); | ||
}); | ||
}; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var Curry = require("bs-platform/lib/js/curry.js"); | ||
var Wonka = require("../wonka.js"); | ||
var Caml_option = require("bs-platform/lib/js/caml_option.js"); | ||
@@ -294,2 +295,16 @@ var Wonka_helpers = require("../wonka_helpers.js"); | ||
function toPromise(source) { | ||
return new Promise((function (resolve, param) { | ||
return Curry._1(Wonka.takeLast(1)(source), (function (signal) { | ||
if (typeof signal === "number") { | ||
return /* () */0; | ||
} else if (signal.tag) { | ||
return resolve(signal[0]); | ||
} else { | ||
return signal[0](/* Pull */0); | ||
} | ||
})); | ||
})); | ||
} | ||
exports.fromListener = fromListener; | ||
@@ -303,2 +318,3 @@ exports.fromDomEvent = fromDomEvent; | ||
exports.delay = delay; | ||
exports.toPromise = toPromise; | ||
/* No side effect */ |
@@ -175,2 +175,18 @@ 'use strict'; | ||
function tap(f) { | ||
return (function (source) { | ||
return (function (sink) { | ||
return Curry._1(source, (function (signal) { | ||
if (typeof signal !== "number") { | ||
if (signal.tag) { | ||
Curry._1(f, signal[0]); | ||
} | ||
} | ||
return sink(signal); | ||
})); | ||
}); | ||
}); | ||
} | ||
function map(f) { | ||
@@ -813,4 +829,5 @@ return (function (source) { | ||
} else { | ||
talkback[0] = signal[0]; | ||
return talkback[0](/* Pull */0); | ||
var x = signal[0]; | ||
talkback[0] = x; | ||
return x(/* Pull */0); | ||
} | ||
@@ -839,2 +856,3 @@ })); | ||
exports.never = never; | ||
exports.tap = tap; | ||
exports.map = map; | ||
@@ -841,0 +859,0 @@ exports.filter = filter; |
{ | ||
"name": "wonka", | ||
"version": "1.1.6", | ||
"version": "1.2.0", | ||
"author": "Phil Pluckthun <phil@kitten.sh>", | ||
@@ -60,2 +60,3 @@ "source": "./src/index.js", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^1.15.3", | ||
"rimraf": "^2.6.3", | ||
@@ -62,0 +63,0 @@ "terser": "^3.14.1" |
@@ -16,1 +16,3 @@ import { Sink, Source, Operator } from '../wonka_types'; | ||
export const delay: <A>(duration: number) => Operator<A, A>; | ||
export const toPromise: <A>(source: Source<A>) => Promise<A>; |
@@ -5,2 +5,3 @@ | ||
import * as Curry from "bs-platform/lib/es6/curry.js"; | ||
import * as Wonka from "../wonka.js"; | ||
import * as Caml_option from "bs-platform/lib/es6/caml_option.js"; | ||
@@ -294,2 +295,16 @@ import * as Wonka_helpers from "../wonka_helpers.js"; | ||
function toPromise(source) { | ||
return new Promise((function (resolve, param) { | ||
return Curry._1(Wonka.takeLast(1)(source), (function (signal) { | ||
if (typeof signal === "number") { | ||
return /* () */0; | ||
} else if (signal.tag) { | ||
return resolve(signal[0]); | ||
} else { | ||
return signal[0](/* Pull */0); | ||
} | ||
})); | ||
})); | ||
} | ||
export { | ||
@@ -304,4 +319,5 @@ fromListener , | ||
delay , | ||
toPromise , | ||
} | ||
/* No side effect */ |
@@ -175,2 +175,18 @@ | ||
function tap(f) { | ||
return (function (source) { | ||
return (function (sink) { | ||
return Curry._1(source, (function (signal) { | ||
if (typeof signal !== "number") { | ||
if (signal.tag) { | ||
Curry._1(f, signal[0]); | ||
} | ||
} | ||
return sink(signal); | ||
})); | ||
}); | ||
}); | ||
} | ||
function map(f) { | ||
@@ -813,4 +829,5 @@ return (function (source) { | ||
} else { | ||
talkback[0] = signal[0]; | ||
return talkback[0](/* Pull */0); | ||
var x = signal[0]; | ||
talkback[0] = x; | ||
return x(/* Pull */0); | ||
} | ||
@@ -840,2 +857,3 @@ })); | ||
never , | ||
tap , | ||
map , | ||
@@ -842,0 +860,0 @@ filter , |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
315053
7099
9