1
1
2
2
import Reservoir from 'reservoir' ;
3
- import type {
3
+ import {
4
4
Document ,
5
5
ObjectId ,
6
6
MinKey ,
@@ -310,7 +310,7 @@ function simplifiedSchema(fields: SchemaAnalysisFieldsMap): SimplifiedSchema {
310
310
}
311
311
312
312
function finalizeDocumentFieldSchema ( fieldMap : SchemaAnalysisFieldsMap ) : SimplifiedSchema {
313
- const fieldSchema : SimplifiedSchema = { } ;
313
+ const fieldSchema : SimplifiedSchema = Object . create ( null ) ;
314
314
Object . values ( fieldMap ) . forEach ( ( field : SchemaAnalysisField ) => {
315
315
const fieldTypes = finalizeSchemaFieldTypes ( field . types ) ;
316
316
@@ -437,7 +437,7 @@ export class SchemaAnalyzer {
437
437
options : SchemaParseOptions ;
438
438
documentsAnalyzed = 0 ;
439
439
schemaAnalysisRoot : SchemaAnalysisRoot = {
440
- fields : { } ,
440
+ fields : Object . create ( null ) ,
441
441
count : 0
442
442
} ;
443
443
@@ -464,7 +464,7 @@ export class SchemaAnalyzer {
464
464
this . semanticTypes = {
465
465
...Object . entries ( this . semanticTypes )
466
466
. filter ( ( [ k ] ) => enabledTypes . includes ( k . toLowerCase ( ) ) )
467
- . reduce ( ( p , [ k , v ] ) => ( { ...p , [ k ] : v } ) , { } )
467
+ . reduce ( ( p , [ k , v ] ) => ( { ...p , [ k ] : v } ) , Object . create ( null ) )
468
468
} ;
469
469
470
470
Object . entries ( this . options . semanticTypes )
@@ -512,13 +512,13 @@ export class SchemaAnalyzer {
512
512
513
513
if ( isArrayType ( type ) ) {
514
514
// Recurse into arrays by calling `addToType` for each element.
515
- type . types = type . types ?? { } ;
515
+ type . types = type . types ?? Object . create ( null ) ;
516
516
type . lengths = type . lengths ?? [ ] ;
517
517
type . lengths . push ( ( value as BSONValue [ ] ) . length ) ;
518
518
( value as BSONValue [ ] ) . forEach ( ( v : BSONValue ) => addToType ( path , v , type . types ) ) ;
519
519
} else if ( isDocumentType ( type ) ) {
520
520
// Recurse into nested documents by calling `addToField` for all sub-fields.
521
- type . fields = type . fields ?? { } ;
521
+ type . fields = type . fields ?? Object . create ( null ) ;
522
522
Object . entries ( value as Document ) . forEach (
523
523
( [ fieldName , v ] ) => addToField ( fieldName , [ ...path , fieldName ] , v , type . fields )
524
524
) ;
@@ -545,7 +545,7 @@ export class SchemaAnalyzer {
545
545
name : fieldName ,
546
546
path : path ,
547
547
count : 0 ,
548
- types : { }
548
+ types : Object . create ( null )
549
549
} ;
550
550
}
551
551
const field = schema [ fieldName ] ;
0 commit comments