Skip to content

Commit c24e7d3

Browse files
committed
Document method
1 parent 4a07206 commit c24e7d3

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

TODO.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,6 @@ limitations under the License.
16351635
16361636
1. [ilogb](https://github.com/JuliaLang/openlibm/blob/master/src/s_ilogb.c) and [logb](https://github.com/JuliaLang/openlibm/blob/master/src/s_logb.c), although these may just be `float64-exponent`
16371637
1638-
16391638
1. stream module (e.g., flow-split, flow-join, flow-mean) => /utils /math etc
16401639
16411640
1. [hdbscan](https://github.com/lmcinnes/hdbscan)
@@ -1676,8 +1675,6 @@ limitations under the License.
16761675
16771676
1. [to-number](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.curry/index.js#L1160)
16781677
1679-
1. global var detection
1680-
16811678
1. feature detection [utils](https://github.com/williamkapke/node-compat-table/blob/gh-pages/testers.json)
16821679
16831680
1. port `https-server`

lib/node_modules/@stdlib/utils/named-typed-tuple/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,60 @@ var n = ctx.count;
11051105
// returns 3
11061106
```
11071107

1108+
<a name="method-for-each"></a>
1109+
1110+
#### tuple.forEach( fcn\[, thisArg] )
1111+
1112+
Invokes a callback for each tuple element.
1113+
1114+
```javascript
1115+
var factory = namedtypedtuple( [ 'x', 'y', 'z' ] );
1116+
1117+
var tuple = factory( [ 1.0, 0.0, -1.0 ], 'int32' );
1118+
1119+
var str = '';
1120+
1121+
function fcn( v, i, f ) {
1122+
str += f + '=' + v;
1123+
if ( i < tuple.length-1 ) {
1124+
str += ' ';
1125+
}
1126+
}
1127+
1128+
tuple.forEach( fcn );
1129+
1130+
console.log( str );
1131+
// => 'x=1 y=0 z=-1'
1132+
```
1133+
1134+
The callback is provided four arguments:
1135+
1136+
- `value`: tuple element
1137+
- `index`: tuple index
1138+
- `field`: tuple field name
1139+
- `tuple`: tuple on which the method is invoked
1140+
1141+
To set the callback execution context, provide a `thisArg`.
1142+
1143+
```javascript
1144+
var factory = namedtypedtuple( [ 'x', 'y', 'z' ] );
1145+
1146+
var tuple = factory( [ 1.0, 0.0, -1.0 ], 'int32' );
1147+
1148+
function fcn() {
1149+
this.count += 1;
1150+
}
1151+
1152+
var ctx = {
1153+
'count': 0
1154+
};
1155+
1156+
tuple.forEach( fcn, ctx );
1157+
1158+
var n = ctx.count;
1159+
// returns 3
1160+
```
1161+
11081162
</section>
11091163

11101164
<!-- /.usage -->

lib/node_modules/@stdlib/utils/named-typed-tuple/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,11 @@ tuple.forEach( fcn[, thisArg] )
691691
--------
692692
> var factory = {{alias}}( [ 'x', 'y', 'z' ] );
693693
> var p = factory( [ 1, 0, -1 ], 'int32' );
694-
> var str = '';
694+
> var str = ' ';
695695
> function fcn( v, i, f ) { str += f + '=' + v + ' '; };
696696
> p.forEach( fcn );
697697
> str
698-
'x=1 y=0 z=-1'
698+
' x=1 y=0 z=-1 '
699699

700700

701701
tuple.includes( searchElement[, fromIndex] )

0 commit comments

Comments
 (0)