本文整理汇总了TypeScript中transducers-js.into函数的典型用法代码示例。如果您正苦于以下问题:TypeScript into函数的具体用法?TypeScript into怎么用?TypeScript into使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了into函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: intoExample
function intoExample () {
var inc = function(n: number) { return n+1; };
var isEven = function(n: number) { return n % 2 == 0; };
var apush = function(arr: number[], x: number) { arr.push(x); return arr; };
var xf = t.comp(t.map(inc),t.filter(isEven));
t.into([], xf, [1,2,3,4]); // [2,4]
}
示例2: mapcatExample
function mapcatExample () {
var reverse = function(arr: number[]) {
var arr: number[] = Array.prototype.slice.call(arr, 0);
arr.reverse();
return arr;
};
var xf = t.mapcat(reverse);
t.into([], xf, [[3,2,1],[6,5,4]]); // [1,2,3,4,5,6]
}
示例3: mapExample
function mapExample () {
var inc = function(n: number) { return n+1; };
var xf = t.map(inc);
t.into([], xf, [1,2,3]); // [2,3,4]
}
示例4: partitionAllExample
function partitionAllExample () {
var xf = t.partitionAll(3);
t.into([], xf, [0,1,2,3,4,5]); // [[0,1,2],[3,4,5]]
}
示例5: partitionByExample
function partitionByExample () {
var xf = t.partitionBy(function(x: string|number) { return typeof x == "string"; });
t.into([], xf, [0,1,"foo","bar",2,3,"bar","baz"]); // [[0,1],["foo","bar"],[2,3],["bar","baz"]];
}
示例6: mapcatExample
function mapcatExample() {
const xf = t.mapcat(reverse);
t.into([], xf, [[3, 2, 1], [6, 5, 4]]); // [1, 2, 3, 4, 5, 6]
}
示例7: takeWhileExample
function takeWhileExample () {
var xf = t.takeWhile(function(n) { return n < 3; });
t.into([], xf, [0,1,2,3,4,5]); // [0,1,2];
}
示例8: keepIndexedExample
function keepIndexedExample () {
var xf = t.keepIndexed(function(i: number, x: string|number) { if (typeof x == "string") return "cool"; });
t.into([], xf, [0,1,"foo",3,4,"bar"]); // ["foo","bar"]
}
示例9: partitionByExample
function partitionByExample() {
const xf = t.partitionBy((x: string|number) => typeof x === "string");
t.into([], xf, [0, 1, "foo", "bar", 2, 3, "bar", "baz"]); // [[0, 1], ["foo", "bar"], [2, 3], ["bar", "baz"]];
}
示例10: dropWhileExample
function dropWhileExample() {
const xf = t.dropWhile(n => n < 3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [3, 4, 5];
}