|
4534 | 4534 | "id": "Stdlib.Iterator",
|
4535 | 4535 | "name": "Iterator",
|
4536 | 4536 | "docstrings": [
|
4537 |
| - "Bindings to JavaScript iterators.\n\nSee [`iterator protocols`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN." |
| 4537 | + "Bindings to JavaScript iterators.\n\nSee [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator) on MDN." |
4538 | 4538 | ],
|
4539 | 4539 | "items": [
|
4540 | 4540 | {
|
|
4569 | 4569 | "kind": "value",
|
4570 | 4570 | "name": "toArray",
|
4571 | 4571 | "docstrings": [
|
4572 |
| - "Turns an iterator into an array of the remaining values.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArray` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map->Map.keys->Iterator.toArray\n\nConsole.log(mapKeysAsArray) // Logs [\"someKey\", \"someKey2\"] to the console.\n```" |
| 4572 | + "Turns an iterator into an array of the remaining values.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArray` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [Iterator.prototype.toArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/toArray) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map->Map.keys->Iterator.toArray\n\nmapKeysAsArray->assertEqual([\"someKey\", \"someKey2\"])\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers.\n```" |
4573 | 4573 | ],
|
4574 | 4574 | "signature": "let toArray: t<'a> => array<'a>"
|
4575 | 4575 | },
|
|
4578 | 4578 | "kind": "value",
|
4579 | 4579 | "name": "toArrayWithMapper",
|
4580 | 4580 | "docstrings": [
|
4581 |
| - "`toArray(iterator)` turns `iterator` into an array of its remaining values, applying the provided mapper function on each item.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArrayWithMapper` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map\n ->Map.keys\n ->Iterator.toArrayWithMapper(key => key->String.length)\n\nConsole.log(mapKeysAsArray) // Logs [7, 8] to the console.\n```" |
| 4581 | + "`toArray(iterator)` turns `iterator` into an array of its remaining values, applying the provided mapper function on each item.\nRemember that each invocation of `next` of an iterator consumes a value. `Iterator.toArrayWithMapper` will consume all remaining values of the iterator and return them in an array to you.\n\nSee [Iterator.prototype.toArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/toArray) on MDN.\n\n## Examples\n```rescript\nlet map = Map.make()\nmap->Map.set(\"someKey\", \"someValue\")\nmap->Map.set(\"someKey2\", \"someValue2\")\n\n// `Map.keys` returns all keys of the map as an iterator.\nlet mapKeysAsArray = map\n ->Map.keys\n ->Iterator.toArrayWithMapper(key => key->String.length)\n\nmapKeysAsArray->assertEqual([7, 8])\n```" |
4582 | 4582 | ],
|
4583 | 4583 | "signature": "let toArrayWithMapper: (t<'a>, 'a => 'b) => array<'b>"
|
4584 | 4584 | },
|
|
4587 | 4587 | "kind": "value",
|
4588 | 4588 | "name": "forEach",
|
4589 | 4589 | "docstrings": [
|
4590 |
| - "`forEach(iterator, fn)` consumes all values in the iterator and runs the callback `fn` for each value.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet iterator: Iterator.t<string> = %raw(`\n (() => {\n var array1 = ['a', 'b', 'c'];\n var iterator1 = array1[Symbol.iterator]();\n return iterator1\n })()\n`)\niterator->Iterator.forEach(v => {\n switch v {\n | Some(\"a\" | \"b\" | \"c\") => assert(true)\n | other =>\n other\n ->Option.isNone\n ->assertEqual(true)\n }\n})\n```" |
| 4590 | + "`forEach(iterator, fn)` consumes all values in the iterator and runs the callback `fn` for each value.\n\nSee [iterator protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) on MDN.\n\n## Examples\n```rescript\nlet iterator: Iterator.t<string> = [\"a\", \"b\", \"c\"]->Array.values\nlet acc = ref(\"\")\niterator->Iterator.forEach(v => {\n acc := acc.contents ++ v\n})\n\nacc.contents->assertEqual(\"abc\")\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
4591 | 4591 | ],
|
4592 |
| - "signature": "let forEach: (t<'a>, option<'a> => unit) => unit" |
| 4592 | + "signature": "let forEach: (t<'a>, 'a => unit) => unit" |
4593 | 4593 | },
|
4594 | 4594 | {
|
4595 | 4595 | "id": "Stdlib.Iterator.ignore",
|
|
4599 | 4599 | "`ignore(iterator)` ignores the provided iterator and returns unit.\n\n This helper is useful when you want to discard a value (for example, the result of an operation with side effects)\n without having to store or process it further."
|
4600 | 4600 | ],
|
4601 | 4601 | "signature": "let ignore: t<'a> => unit"
|
| 4602 | + }, |
| 4603 | + { |
| 4604 | + "id": "Stdlib.Iterator.drop", |
| 4605 | + "kind": "value", |
| 4606 | + "name": "drop", |
| 4607 | + "docstrings": [ |
| 4608 | + "`drop((iterator, n))` returns a new iterator helper object that skips the given number of elements at the start of this iterator.\n\nSee [Iterator.prototype.drop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/drop) on MDN.\n\n## Examples\n```rescript\nlet fibonacci: Iterator.t<int> = [ 1, 1, 2, 3, 5, 8, 13, 21 ]->Array.values\n\nlet seq = fibonacci->Iterator.drop(2)\nseq->Iterator.next->assertEqual({done: false, value: Some(2)})\nseq->Iterator.next->assertEqual({done: false, value: Some(3)})\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers.\n```" |
| 4609 | + ], |
| 4610 | + "signature": "let drop: (t<'a>, int) => t<'a>" |
| 4611 | + }, |
| 4612 | + { |
| 4613 | + "id": "Stdlib.Iterator.every", |
| 4614 | + "kind": "value", |
| 4615 | + "name": "every", |
| 4616 | + "docstrings": [ |
| 4617 | + "`every(iterator, fn)` tests whether all elements in the iterator pass the test implemented by the provided function.\n\nSee [Iterator.prototype.every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/every) on MDN.\n\n## Examples\n```rescript\nlet fibonacci: Iterator.t<int> = [ 1, 1, 2, 3, 5, 8, 13, 21 ]->Array.values\n\nlet areAllEven = fibonacci->Iterator.every(n => n % 2 == 0)\nareAllEven->assertEqual(false)\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4618 | + ], |
| 4619 | + "signature": "let every: (t<'a>, 'a => bool) => bool" |
| 4620 | + }, |
| 4621 | + { |
| 4622 | + "id": "Stdlib.Iterator.filter", |
| 4623 | + "kind": "value", |
| 4624 | + "name": "filter", |
| 4625 | + "docstrings": [ |
| 4626 | + "`filter(iterator, fn)` returns a new iterator helper object that contains the elements of the original iterator that pass the test implemented by the provided function.\n\nSee [Iterator.prototype.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/filter) on MDN.\n\n## Examples\n```rescript\nlet fibonacci: Iterator.t<int> = [ 1, 1, 2, 3, 5, 8, 13, 21 ]->Array.values\n\nlet seq = fibonacci->Iterator.filter(n => n % 2 == 0)\nseq->Iterator.next->assertEqual({done: false, value: Some(2)})\nseq->Iterator.next->assertEqual({done: false, value: Some(8)})\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4627 | + ], |
| 4628 | + "signature": "let filter: (t<'a>, 'a => bool) => t<'a>" |
| 4629 | + }, |
| 4630 | + { |
| 4631 | + "id": "Stdlib.Iterator.find", |
| 4632 | + "kind": "value", |
| 4633 | + "name": "find", |
| 4634 | + "docstrings": [ |
| 4635 | + "`find(iterator, fn)` returns the value of the first element in the iterator that satisfies the provided testing function.\n\nSee [Iterator.prototype.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/find) on MDN.\n\n## Examples\n```rescript\nlet fibonacci: Iterator.t<int> = [ 1, 1, 2, 3, 5, 8, 13, 21 ]->Array.values\n\nlet seq = fibonacci->Iterator.find(n => n % 2 == 0)\nseq->assertEqual(Some(2))\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4636 | + ], |
| 4637 | + "signature": "let find: (t<'a>, 'a => bool) => option<'a>" |
| 4638 | + }, |
| 4639 | + { |
| 4640 | + "id": "Stdlib.Iterator.flatMap", |
| 4641 | + "kind": "value", |
| 4642 | + "name": "flatMap", |
| 4643 | + "docstrings": [ |
| 4644 | + "`flatMap(iterator, fn)` returns a new iterator helper object that contains the elements of the original iterator that pass the test implemented by the provided function.\n\nSee [Iterator.prototype.flatMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/flatMap) on MDN.\n\n## Examples\n```rescript\nlet map1 = Map.fromArray([(\"a\", 1), (\"b\", 2), (\"c\", 3)])\nlet map2 = Map.fromArray([(\"d\", 4), (\"e\", 5), (\"f\", 6)])\n\nlet letters =\n [map1, map2]\n ->Array.values\n ->Iterator.flatMap(m => Map.keys(m))\n ->Array.fromIterator\nletters->assertEqual([\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"])\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4645 | + ], |
| 4646 | + "signature": "let flatMap: (t<'a>, 'a => t<'b>) => t<'b>" |
| 4647 | + }, |
| 4648 | + { |
| 4649 | + "id": "Stdlib.Iterator.map", |
| 4650 | + "kind": "value", |
| 4651 | + "name": "map", |
| 4652 | + "docstrings": [ |
| 4653 | + "`map(iterator, fn)` returns a new iterator helper object that yields elements of the iterator, each transformed by a mapping function.\n\nSee [Iterator.prototype.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/map) on MDN.\n\n## Examples\n```rescript\nlet map = Map.fromArray([(\"a\", 1), (\"b\", 2), (\"c\", 3)])\nlet letters = map->Map.keys->Iterator.map(v => v->String.toUpperCase)->Array.fromIterator\nletters->assertEqual([\"A\", \"B\", \"C\"])\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4654 | + ], |
| 4655 | + "signature": "let map: (t<'a>, 'a => 'b) => t<'b>" |
| 4656 | + }, |
| 4657 | + { |
| 4658 | + "id": "Stdlib.Iterator.reduce", |
| 4659 | + "kind": "value", |
| 4660 | + "name": "reduce", |
| 4661 | + "docstrings": [ |
| 4662 | + "`reduce(iterator, fn, initialValue)` applies a function against an accumulator and each element in the iterator (from left to right) to reduce it to a single value.\n\nSee [Iterator.prototype.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/reduce) on MDN.\n\n## Examples\n```rescript\nlet numbers: Iterator.t<int> = [ 1, 2, 3 ]->Array.values\n\nlet sum = numbers->Iterator.reduce((acc, n) => acc + n, ~initialValue=0)\nsum->assertEqual(6)\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4663 | + ], |
| 4664 | + "signature": "let reduce: (t<'a>, ('acc, 'a) => 'acc, ~initialValue: 'acc=?) => 'acc" |
| 4665 | + }, |
| 4666 | + { |
| 4667 | + "id": "Stdlib.Iterator.some", |
| 4668 | + "kind": "value", |
| 4669 | + "name": "some", |
| 4670 | + "docstrings": [ |
| 4671 | + "`some(iterator, fn)` The some() method of Iterator instances is similar to Array.some: \nit tests whether at least one element produced by the iterator passes the test implemented by the provided function. \nIt returns a boolean value.\n\nSee [Iterator.prototype.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/some) on MDN.\n\n## Examples\n```rescript\nlet numbers: Iterator.t<int> = [ 1, 2, 3 ]->Array.values\n\nlet hasEven = numbers->Iterator.some(n => n % 2 == 0)\nhasEven->assertEqual(true)\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4672 | + ], |
| 4673 | + "signature": "let some: (t<'a>, 'a => bool) => bool" |
| 4674 | + }, |
| 4675 | + { |
| 4676 | + "id": "Stdlib.Iterator.take", |
| 4677 | + "kind": "value", |
| 4678 | + "name": "take", |
| 4679 | + "docstrings": [ |
| 4680 | + "`take((iterator, n))` returns a new iterator helper object that contains the first `n` elements of this iterator.\n\nSee [Iterator.prototype.take](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/take) on MDN.\n\n## Examples\n```rescript\nlet fibonacci: Iterator.t<int> = [ 1, 1, 2, 3, 5, 8, 13, 21 ]->Array.values\n\nlet seq = fibonacci->Iterator.take(2)\nseq->Iterator.next->assertEqual({done: false, value: Some(1)})\nseq->Iterator.next->assertEqual({done: false, value: Some(1)})\nseq->Iterator.next->assertEqual({done: true, value: None})\n```\n\n## Remark\n\nSince March 2025, this feature works across the latest devices and browser versions.\nThis feature might not work in older devices or browsers." |
| 4681 | + ], |
| 4682 | + "signature": "let take: (t<'a>, int) => t<'a>" |
4602 | 4683 | }
|
4603 | 4684 | ]
|
4604 | 4685 | },
|
|
11742 | 11823 | "`ignore(array)` ignores the provided array and returns unit.\n\n This helper is useful when you want to discard a value (for example, the result of an operation with side effects)\n without having to store or process it further."
|
11743 | 11824 | ],
|
11744 | 11825 | "signature": "let ignore: array<'a> => unit"
|
| 11826 | + }, |
| 11827 | + { |
| 11828 | + "id": "Stdlib.Array.entries", |
| 11829 | + "kind": "value", |
| 11830 | + "name": "entries", |
| 11831 | + "docstrings": [ |
| 11832 | + "`entries(array)` returns a new array iterator object that contains the key/value pairs for each index in the array.\n\nSee [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator : Iterator.t<(int, int)> = array->Array.entries\niterator->Iterator.next->assertEqual({done: false, value: Some((0, 5))})\niterator->Iterator.next->assertEqual({done: false, value: Some((1, 6))})\n```" |
| 11833 | + ], |
| 11834 | + "signature": "let entries: array<'a> => Iterator.t<(int, 'a)>" |
| 11835 | + }, |
| 11836 | + { |
| 11837 | + "id": "Stdlib.Array.values", |
| 11838 | + "kind": "value", |
| 11839 | + "name": "values", |
| 11840 | + "docstrings": [ |
| 11841 | + "`values(array)` returns a new array iterator object that contains the values for each index in the array.\n\nSee [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator : Iterator.t<int> = array->Array.values\niterator->Iterator.next->assertEqual({done: false, value: Some(5)})\niterator->Iterator.next->assertEqual({done: false, value: Some(6)})\n```" |
| 11842 | + ], |
| 11843 | + "signature": "let values: array<'a> => Iterator.t<'a>" |
11745 | 11844 | }
|
11746 | 11845 | ]
|
11747 | 11846 | },
|
|
0 commit comments