Skip to content

Commit 8cfd178

Browse files
committed
Add comments and missing private annotations
1 parent eedade7 commit 8cfd178

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

lib/node_modules/@stdlib/cli/lib/is_integer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/**
2424
* Tests if a finite double-precision floating-point number is an integer.
2525
*
26+
* @private
2627
* @param {number} x - value to test
2728
* @returns {boolean} boolean indicating whether the value is an integer
2829
*
@@ -35,6 +36,7 @@
3536
* // returns false
3637
*/
3738
function isInteger( x ) {
39+
// NOTE: we explicitly avoid using `@stdlib/math/base/special` here in order to avoid circular dependencies.
3840
return ( Math.floor( x ) === x ); // eslint-disable-line stdlib/no-builtin-math
3941
}
4042

lib/node_modules/@stdlib/utils/library-manifest/bin/cli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// MODULES //
2424

2525
var resolve = require( 'path' ).resolve;
26+
27+
// NOTE: we explicitly avoid using `@stdlib/fs/read-file` in this particular package in order to avoid circular dependencies. This should not be problematic as this command-line utility will be executed via Node.js.
2628
var readFileSync = require( 'fs' ).readFileSync; // eslint-disable-line no-sync
2729
var CLI = require( '@stdlib/cli' );
2830
var manifest = require( './../lib' );

lib/node_modules/@stdlib/utils/library-manifest/lib/is_object.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/**
2424
* Tests if a value is an object; e.g., `{}`.
2525
*
26+
* @private
2627
* @param {*} value - value to test
2728
* @returns {boolean} boolean indicating whether value is an object
2829
*
@@ -38,7 +39,7 @@ function isObject( value ) {
3839
return (
3940
typeof value === 'object' &&
4041
value !== null &&
41-
!Array.isArray( value )
42+
!Array.isArray( value ) // NOTE: we inline the `isObject` function from `@stdlib/assert/is-object` and use the built-in `isArray` method in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.
4243
);
4344
}
4445

lib/node_modules/@stdlib/utils/library-manifest/lib/manifest.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var path = require( 'path' );
2424
var cwd = require( 'process' ).cwd;
2525
var logger = require( 'debug' );
2626
var resolve = require( 'resolve' ).sync;
27-
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2827
var parentPath = require( '@stdlib/fs/resolve-parent-path' ).sync;
2928
var convertPath = require( '@stdlib/utils/convert-path' );
3029
var isObject = require( './is_object.js' );
@@ -37,6 +36,10 @@ var DEFAULTS = require( './defaults.json' );
3736

3837
var debug = logger( 'library-manifest:main' );
3938

39+
// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.
40+
var hasOwnProp = Object.prototype.hasOwnProperty;
41+
var objectKeys = Object.keys;
42+
4043

4144
// MAIN //
4245

@@ -95,6 +98,8 @@ function manifest( fpath, conditions, options ) {
9598
debug( 'Manifest file path: %s', fpath );
9699

97100
conf = require( fpath ); // eslint-disable-line stdlib/no-dynamic-require
101+
102+
// NOTE: Instead of using `@stdlib/utils/copy`, we stringify and then parse the configuration object to create a deep copy in an ES5 environment while avoiding circular dependencies. This assumes that the configuration object is valid JSON.
98103
conf = JSON.parse( JSON.stringify( conf ) );
99104
debug( 'Manifest: %s', JSON.stringify( conf ) );
100105

@@ -105,10 +110,10 @@ function manifest( fpath, conditions, options ) {
105110
throw new TypeError( 'invalid argument. Second argument must be an object. Value: `' + conditions + '`.' );
106111
}
107112
debug( 'Provided conditions: %s', JSON.stringify( conditions ) );
108-
coptnames = Object.keys( conf.options );
113+
coptnames = objectKeys( conf.options );
109114
for ( i = 0; i < coptnames.length; i++ ) {
110115
key = coptnames[ i ];
111-
if ( hasOwnProp( conditions, key ) ) {
116+
if ( hasOwnProp.call( conditions, key ) ) {
112117
conf.options[ key ] = conditions[ key ];
113118
}
114119
}
@@ -123,14 +128,15 @@ function manifest( fpath, conditions, options ) {
123128
for ( j = 0; j < coptnames.length; j++ ) {
124129
key = coptnames[ j ];
125130
if (
126-
!hasOwnProp( o, key ) ||
131+
!hasOwnProp.call( o, key ) ||
127132
o[ key ] !== conf.options[ key ]
128133
) {
129134
break;
130135
}
131136
}
132137
// If we exhausted all the options, then we found a match...
133138
if ( j === coptnames.length ) {
139+
// NOTE: Instead of using `@stdlib/utils/copy`, we stringify and then parse the object to create a deep copy in an ES5 environment while avoiding circular dependencies. This assumes that the object is valid JSON.
134140
obj = JSON.parse( JSON.stringify( o ) );
135141
debug( 'Matching configuration: %s', JSON.stringify( obj ) );
136142
break;
@@ -143,7 +149,7 @@ function manifest( fpath, conditions, options ) {
143149
// Resolve manifest file paths...
144150
for ( i = 0; i < conf.fields.length; i++ ) {
145151
key = conf.fields[ i ].field;
146-
if ( hasOwnProp( obj, key ) ) {
152+
if ( hasOwnProp.call( obj, key ) ) {
147153
o = obj[ key ];
148154
if ( conf.fields[ i ].resolve ) {
149155
for ( j = 0; j < o.length; j++ ) {
@@ -184,7 +190,7 @@ function manifest( fpath, conditions, options ) {
184190
debug( 'Merging dependency manifest.' );
185191
for ( j = 0; j < conf.fields.length; j++ ) {
186192
key = conf.fields[ j ].field;
187-
if ( hasOwnProp( o, key ) ) {
193+
if ( hasOwnProp.call( o, key ) ) {
188194
tmp = o[ key ];
189195
if ( conf.fields[ j ].resolve ) {
190196
for ( k = 0; k < tmp.length; k++ ) {
@@ -200,7 +206,7 @@ function manifest( fpath, conditions, options ) {
200206
debug( 'Removing duplicate entries.' );
201207
for ( i = 0; i < conf.fields.length; i++ ) {
202208
key = conf.fields[ i ].field;
203-
if ( hasOwnProp( obj, key ) ) {
209+
if ( hasOwnProp.call( obj, key ) ) {
204210
obj[ key ] = unique( obj[ key ] );
205211
}
206212
}
@@ -209,7 +215,7 @@ function manifest( fpath, conditions, options ) {
209215
for ( i = 0; i < conf.fields.length; i++ ) {
210216
key = conf.fields[ i ].field;
211217
if (
212-
hasOwnProp( obj, key ) &&
218+
hasOwnProp.call( obj, key ) &&
213219
conf.fields[ i ].resolve &&
214220
conf.fields[ i ].relative
215221
) {
@@ -224,7 +230,7 @@ function manifest( fpath, conditions, options ) {
224230
debug( 'Converting paths to specified convention.' );
225231
for ( i = 0; i < conf.fields.length; i++ ) {
226232
key = conf.fields[ i ].field;
227-
if ( hasOwnProp( obj, key ) ) {
233+
if ( hasOwnProp.call( obj, key ) ) {
228234
tmp = obj[ key ];
229235
for ( j = 0; j < tmp.length; j++ ) {
230236
tmp[ j ] = convertPath( tmp[ j ], opts.paths );

lib/node_modules/@stdlib/utils/library-manifest/lib/unique.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
'use strict';
2020

21+
// VARIABLES //
22+
23+
// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.
24+
var objectKeys = Object.keys;
25+
26+
2127
// MAIN //
2228

2329
/**
@@ -34,7 +40,7 @@ function unique( arr ) {
3440
for ( i = 0; i < arr.length; i++ ) {
3541
obj[ arr[i] ] = true;
3642
}
37-
return Object.keys( obj );
43+
return objectKeys( obj );
3844
}
3945

4046

lib/node_modules/@stdlib/utils/library-manifest/lib/validate.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020

2121
// MODULES //
2222

23-
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
23+
// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.
2424
var isObject = require( './is_object.js' );
2525

2626

27+
// VARIABLES //
28+
29+
var hasOwnProp = Object.prototype.hasOwnProperty;
30+
31+
2732
// MAIN //
2833

2934
/**
@@ -51,13 +56,13 @@ function validate( opts, options ) {
5156
if ( !isObject( options ) ) {
5257
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
5358
}
54-
if ( hasOwnProp( options, 'basedir' ) ) {
59+
if ( hasOwnProp.call( options, 'basedir' ) ) {
5560
opts.basedir = options.basedir;
5661
if ( typeof opts.basedir !== 'string' ) {
5762
return new TypeError( 'invalid option. `basedir` option must be a primitive string. Option: `' + opts.basedir + '`.' );
5863
}
5964
}
60-
if ( hasOwnProp( options, 'paths' ) ) {
65+
if ( hasOwnProp.call( options, 'paths' ) ) {
6166
opts.paths = options.paths;
6267
if ( typeof opts.paths !== 'string' ) {
6368
return new TypeError( 'invalid option. `paths` option must be a primitive string. Option: `' + opts.paths + '`.' );

0 commit comments

Comments
 (0)