11
22import Reservoir from 'reservoir' ;
3- import type {
3+ import {
44 Document ,
55 ObjectId ,
66 MinKey ,
@@ -310,7 +310,7 @@ function simplifiedSchema(fields: SchemaAnalysisFieldsMap): SimplifiedSchema {
310310 }
311311
312312 function finalizeDocumentFieldSchema ( fieldMap : SchemaAnalysisFieldsMap ) : SimplifiedSchema {
313- const fieldSchema : SimplifiedSchema = { } ;
313+ const fieldSchema : SimplifiedSchema = Object . create ( null ) ;
314314 Object . values ( fieldMap ) . forEach ( ( field : SchemaAnalysisField ) => {
315315 const fieldTypes = finalizeSchemaFieldTypes ( field . types ) ;
316316
@@ -437,7 +437,7 @@ export class SchemaAnalyzer {
437437 options : SchemaParseOptions ;
438438 documentsAnalyzed = 0 ;
439439 schemaAnalysisRoot : SchemaAnalysisRoot = {
440- fields : { } ,
440+ fields : Object . create ( null ) ,
441441 count : 0
442442 } ;
443443
@@ -464,7 +464,7 @@ export class SchemaAnalyzer {
464464 this . semanticTypes = {
465465 ...Object . entries ( this . semanticTypes )
466466 . 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 ) )
468468 } ;
469469
470470 Object . entries ( this . options . semanticTypes )
@@ -512,13 +512,13 @@ export class SchemaAnalyzer {
512512
513513 if ( isArrayType ( type ) ) {
514514 // Recurse into arrays by calling `addToType` for each element.
515- type . types = type . types ?? { } ;
515+ type . types = type . types ?? Object . create ( null ) ;
516516 type . lengths = type . lengths ?? [ ] ;
517517 type . lengths . push ( ( value as BSONValue [ ] ) . length ) ;
518518 ( value as BSONValue [ ] ) . forEach ( ( v : BSONValue ) => addToType ( path , v , type . types ) ) ;
519519 } else if ( isDocumentType ( type ) ) {
520520 // Recurse into nested documents by calling `addToField` for all sub-fields.
521- type . fields = type . fields ?? { } ;
521+ type . fields = type . fields ?? Object . create ( null ) ;
522522 Object . entries ( value as Document ) . forEach (
523523 ( [ fieldName , v ] ) => addToField ( fieldName , [ ...path , fieldName ] , v , type . fields )
524524 ) ;
@@ -545,7 +545,7 @@ export class SchemaAnalyzer {
545545 name : fieldName ,
546546 path : path ,
547547 count : 0 ,
548- types : { }
548+ types : Object . create ( null )
549549 } ;
550550 }
551551 const field = schema [ fieldName ] ;
0 commit comments