Skip to content

Commit e00e353

Browse files
Zuhair-CSkgryte
andauthored
chore: resolve javascript lint errors
PR-URL: #8158 Closes: #8155 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 29d3bbb commit e00e353

File tree

4 files changed

+41
-48
lines changed

4 files changed

+41
-48
lines changed

lib/node_modules/@stdlib/utils/object-inverse-by/README.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var invertBy = require( '@stdlib/utils/object-inverse-by' );
3232

3333
#### invertBy( obj, \[options,] transform )
3434

35-
Inverts an `object`, such that keys become values and values become keys, according to a `transform` function.
35+
Inverts an object, such that keys become values and values become keys, according to a transform function.
3636

3737
```javascript
3838
function transform( key, value ) {
@@ -46,11 +46,11 @@ var out = invertBy( obj, transform );
4646
// returns { 'beep': 'a', 'boop': 'b' }
4747
```
4848

49-
The function accepts the following `options`:
49+
The function accepts the following options:
5050

51-
- **duplicates**: `boolean` indicating whether to store keys mapped to duplicate values in `arrays`. Default: `true`.
51+
- **duplicates**: boolean indicating whether to store keys mapped to duplicate values in arrays. Default: `true`.
5252

53-
By default, keys mapped to duplicate values are stored in `arrays`.
53+
By default, keys mapped to duplicate values are stored in arrays.
5454

5555
```javascript
5656
function transform( key, value ) {
@@ -64,7 +64,7 @@ var out = invertBy( obj, transform );
6464
// returns { 'beep': [ 'a', 'b' ] }
6565
```
6666

67-
To **not** allow duplicates, set the `duplicates` option to `false`. The output `key-value` pair will be the `key` most recently inserted into the input `object`.
67+
To **not** allow duplicates, set the `duplicates` option to `false`. The output key-value pair will be the key most recently inserted into the input object.
6868

6969
```javascript
7070
function transform( key, value ) {
@@ -82,7 +82,7 @@ var out = invertBy( obj, opts, transform );
8282
// returns { 'beep': 'c', 'boop': 'b' }
8383
```
8484

85-
The `transform` function is provided three arguments:
85+
The transform function is provided three arguments:
8686

8787
- **key**: object key.
8888
- **value**: object value corresponding to `key`.
@@ -112,7 +112,7 @@ var out = invertBy( obj, transform );
112112

113113
## Notes
114114

115-
- Beware when providing `objects` having values which are themselves `objects`. This function relies on native `object` serialization (`#toString`) when converting `transform` function return values to keys.
115+
- Beware when providing objects having values which are themselves objects. This function relies on native object serialization (`#toString`) when converting transform function return values to keys.
116116

117117
```javascript
118118
function transform( key, value ) {
@@ -129,7 +129,7 @@ var out = invertBy( obj, transform );
129129
// returns { '1,2,3': 'a', '[object Object]': 'b' }
130130
```
131131

132-
- Insertion order is not guaranteed, as `object` key enumeration is not specified according to the [ECMAScript specification][ecma-262-for-in]. In practice, however, most engines use insertion order to sort an `object`'s keys, thus allowing for deterministic inversion.
132+
- In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the [ECMAScript specification][ecma-262-for-in] in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
133133
134134
</section>
135135
@@ -142,27 +142,24 @@ var out = invertBy( obj, transform );
142142
<!-- eslint no-undef: "error" -->
143143
144144
```javascript
145-
var randu = require( '@stdlib/random/base/randu' );
146-
var round = require( '@stdlib/math/base/special/round' );
145+
var objectKeys = require( '@stdlib/utils/keys' );
146+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
147147
var invertBy = require( '@stdlib/utils/object-inverse-by' );
148148
149-
var keys;
150-
var arr;
151-
var out;
152-
var i;
153-
154149
function transform( key, value ) {
155150
return value;
156151
}
157152
158-
// Create an array of random integers...
159-
arr = new Array( 1000 );
160-
for ( i = 0; i < arr.length; i++ ) {
161-
arr[ i ] = round( randu()*100.0 );
162-
}
153+
// Create an array of random integers:
154+
var arr = discreteUniform( 1000, 0, 100, {
155+
'dtype': 'generic'
156+
});
157+
163158
// Invert the array to determine value frequency...
164-
out = invertBy( arr, transform );
165-
keys = Object.keys( out );
159+
var out = invertBy( arr, transform );
160+
var keys = objectKeys( out );
161+
162+
var i;
166163
for ( i = 0; i < keys.length; i++ ) {
167164
if ( out[ i ] ) {
168165
out[ i ] = out[ i ].length;

lib/node_modules/@stdlib/utils/object-inverse-by/docs/repl.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
serialization (`#toString`) when converting transform function return values
1616
to keys.
1717

18-
Insertion order is not guaranteed, as object key enumeration is not
19-
specified according to the ECMAScript specification. In practice, however,
20-
most engines use insertion order to sort an object's keys, thus allowing for
21-
deterministic inversion.
18+
In older JavaScript engines, insertion order is not guaranteed, as object
19+
key enumeration was not specified according to the ECMAScript specification
20+
in earlier editions. In practice, however, most older engines use insertion
21+
order to sort an object's keys, thus allowing for deterministic inversion.
2222

2323
Parameters
2424
----------

lib/node_modules/@stdlib/utils/object-inverse-by/docs/types/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ type Transform = Nullary | Unary | Binary | Ternary;
7979
*
8080
* - The transform function is provided three arguments:
8181
*
82-
* - `key`: object key
83-
* - `value`: object value corresponding to `key`
84-
* - `obj`: the input object
82+
* - `key`: object key.
83+
* - `value`: object value corresponding to `key`.
84+
* - `obj`: the input object.
8585
*
8686
* - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
8787
*
88-
* - Insertion order is not guaranteed, as object key enumeration is not specified according to the ECMAScript specification. In practice, however, most engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
88+
* - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
8989
*
9090
* @param obj - input object
9191
* @param transform - transform function
@@ -122,13 +122,13 @@ declare function invertBy( obj: any, transform: Transform ): any;
122122
*
123123
* - The transform function is provided three arguments:
124124
*
125-
* - `key`: object key
126-
* - `value`: object value corresponding to `key`
127-
* - `obj`: the input object
125+
* - `key`: object key.
126+
* - `value`: object value corresponding to `key`.
127+
* - `obj`: the input object.
128128
*
129129
* - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
130130
*
131-
* - Insertion order is not guaranteed, as object key enumeration is not specified according to the ECMAScript specification. In practice, however, most engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
131+
* - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
132132
*
133133
* @param obj - input object
134134
* @param opts - function options

lib/node_modules/@stdlib/utils/object-inverse-by/examples/index.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@
1919
'use strict';
2020

2121
var objectKeys = require( '@stdlib/utils/keys' );
22-
var randu = require( '@stdlib/random/base/randu' );
23-
var round = require( '@stdlib/math/base/special/round' );
22+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2423
var invertBy = require( './../lib' );
2524

26-
var keys;
27-
var arr;
28-
var out;
29-
var i;
30-
3125
function transform( key, value ) {
3226
return value;
3327
}
3428

35-
// Create an array of random integers...
36-
arr = new Array( 1000 );
37-
for ( i = 0; i < arr.length; i++ ) {
38-
arr[ i ] = round( randu()*100.0 );
39-
}
29+
// Create an array of random integers:
30+
var arr = discreteUniform( 1000, 0, 100, {
31+
'dtype': 'generic'
32+
});
33+
4034
// Invert the array to determine value frequency...
41-
out = invertBy( arr, transform );
42-
keys = objectKeys( out );
35+
var out = invertBy( arr, transform );
36+
var keys = objectKeys( out );
37+
38+
var i;
4339
for ( i = 0; i < keys.length; i++ ) {
4440
if ( out[ i ] ) {
4541
out[ i ] = out[ i ].length;

0 commit comments

Comments
 (0)