當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript transducers-js.into函數代碼示例

本文整理匯總了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]
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:transducers-js-tests.ts

示例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]
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:transducers-js-tests.ts

示例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]
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:transducers-js-tests.ts

示例4: partitionAllExample

function partitionAllExample () {
  var xf = t.partitionAll(3);
  t.into([], xf, [0,1,2,3,4,5]); // [[0,1,2],[3,4,5]]
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例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"]];
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例6: mapcatExample

function mapcatExample() {
  const xf = t.mapcat(reverse);
  t.into([], xf, [[3, 2, 1], [6, 5, 4]]); // [1, 2, 3, 4, 5, 6]
}
開發者ID:MrBigDog2U,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例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];
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例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"]
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例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"]];
}
開發者ID:MrBigDog2U,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts

示例10: dropWhileExample

function dropWhileExample() {
  const xf = t.dropWhile(n => n < 3);
  t.into([], xf, [0, 1, 2, 3, 4, 5]); // [3, 4, 5];
}
開發者ID:MrBigDog2U,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:transducers-js-tests.ts


注:本文中的transducers-js.into函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。