You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/math/iter/divide/README.md
+21-5Lines changed: 21 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,26 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the
68
68
-**next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
69
69
-**return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
70
70
71
+
If provided a numeric value as an [`iterator`][mdn-iterator-protocol] argument, the value is broadcast as an **infinite**[iterator][mdn-iterator-protocol] which **always** returns the provided value.
72
+
73
+
```javascript
74
+
var array2iterator =require( '@stdlib/array/to-iterator' );
75
+
76
+
var arr =array2iterator( [ 1.0, 2.0 ] );
77
+
78
+
var it =iterDivide( arr, 4.0 );
79
+
// returns <Object>
80
+
81
+
var v =it.next().value;
82
+
// returns 0.25
83
+
84
+
v =it.next().value;
85
+
// returns 0.5
86
+
87
+
var bool =it.next().done;
88
+
// returns true
89
+
```
90
+
71
91
</section>
72
92
73
93
<!-- /.usage -->
@@ -96,7 +116,6 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the
96
116
97
117
```javascript
98
118
var iterSineWave =require( '@stdlib/simulate/iter/sine-wave' );
99
-
var iterConstant =require( '@stdlib/iter/constant' );
100
119
var iterDivide =require( '@stdlib/math/iter/divide' );
101
120
102
121
// Create an iterator which generates a sine wave:
@@ -106,11 +125,8 @@ var sine = iterSineWave({
106
125
'iter':100
107
126
});
108
127
109
-
// Create an iterator which always returns the same value:
110
-
var scalar =iterConstant( 10.0 );
111
-
112
128
// Create an iterator which scales the sine wave amplitude:
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/math/iter/divide/docs/types/index.d.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ type Iterator = Iter | IterableIterator;
30
30
*
31
31
* ## Notes
32
32
*
33
+
* - If provided a numeric value as an iterator argument, the value is broadcast as an **infinite** iterator which **always** returns the provided value.
33
34
* - If an iterated value is non-numeric (including `NaN`), the function returns `NaN`. If non-numeric iterated values are possible, you are advised to provide an iterator which type checks and handles non-numeric values accordingly.
34
35
* - The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once **one** of the provided iterators ends.
35
36
* - If an environment supports `Symbol.iterator` and all provided iterators are iterable, the returned iterator is iterable.
@@ -56,7 +57,7 @@ type Iterator = Iter | IterableIterator;
0 commit comments