Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function unBSON(value: any): any {
if (shape === 'array') {
return value.map(unBSON);
} else if (shape === 'object') {
const mapped: Record<string, any> = {};
const mapped: Record<string, any> = Object.create(null);
for (const [k, v] of Object.entries(value)) {
mapped[k] = unBSON(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class DocumentTableView extends React.Component<DocumentTableViewProps> {
onColumnResized(event: ColumnResizedEvent) {
if (event.finished) {
const columnState = this.columnApi?.getColumnState() || [];
const currentColumnWidths: Record<string, number> = {};
const currentColumnWidths: Record<string, number> = Object.create(null);
for (const column of columnState) {
if (column.width) currentColumnWidths[column.colId] = column.width;
}
Expand Down Expand Up @@ -888,8 +888,11 @@ export class DocumentTableView extends React.Component<DocumentTableViewProps> {
path: (string | number)[],
types: TableHeaderType[]
): ColDef[] => {
const headers: Record<string, ColDef> = {};
const headerTypes: Record<string, Record<string, TableHeaderType>> = {};
const headers: Record<string, ColDef> = Object.create(null);
const headerTypes: Record<
string,
Record<string, TableHeaderType>
> = Object.create(null);
const isEditable = this.props.isEditable;
const parentType = types.length ? types[types.length - 1] : 'Object';

Expand Down Expand Up @@ -944,7 +947,7 @@ export class DocumentTableView extends React.Component<DocumentTableViewProps> {
the grid. This is handled here for the initial header values, and then
in the GridStore for any subsequent updates. */
const columnHeaders = Object.values(headers);
const showing: Record<string, TableHeaderType> = {};
const showing: Record<string, TableHeaderType> = Object.create(null);

map(headerTypes, function (oids, key) {
const colTypes = Object.values(oids);
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-crud/src/stores/crud-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,7 @@ describe('store', function () {
let fakeSetItem: (key: string, value: string) => void;

beforeEach(function () {
const localStorageValues: Record<string, string> = {};
const localStorageValues: Record<string, string> = Object.create(null);
fakeGetItem = sinon.fake((key: string) => {
return localStorageValues[key];
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-crud/src/stores/grid-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class GridStoreImpl
* @param {Boolean} isArray - If the parent of the element is an array.
*/
elementRemoved(key: string, oid: string, isArray: boolean) {
const params: Record<string, unknown> = {};
const params: Record<string, unknown> = Object.create(null);
const newShowing: typeof this.showing = {};

/* If it's an array element, need to move subsequent elements up */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('application-menu / useApplicationMenu', function () {

const handlerUndoA = () => {};
const handlerRedoA = () => {};
let roles: Record<string, () => void> = {
let roles: Readonly<Record<string, () => void>> = {
undo: handlerUndoA,
redo: handlerRedoA,
};
Expand Down
2 changes: 2 additions & 0 deletions packages/data-service/src/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ class DataServiceImpl extends WithLogContext implements DataService {

// Build the aggregation pipeline dynamically based on collection type
const groupStage: Record<string, unknown> = {
__proto__: null,
_id: null,
capped: { $first: '$storageStats.capped' },
count: { $sum: '$storageStats.count' },
Expand Down Expand Up @@ -1230,6 +1231,7 @@ class DataServiceImpl extends WithLogContext implements DataService {

const addFieldsStage: Record<string, unknown> = {
// `avgObjSize` is the average of per-shard `avgObjSize` weighted by `count`
__proto__: null,
avgObjSize: {
$cond: {
if: { $ne: ['$count', 0] },
Expand Down
4 changes: 2 additions & 2 deletions packages/hadron-document/src/object-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class ObjectGenerator {
options: ObjectGeneratorOptions = {}
): Record<string, unknown> {
if (elements) {
const object: Record<string, unknown> = {};
const object: Record<string, unknown> = Object.create(null);
for (const element of elements) {
if (options.excludeInternalFields && element.isInternalField()) {
continue;
Expand Down Expand Up @@ -118,7 +118,7 @@ export class ObjectGenerator {
options: ObjectGeneratorOptions = {}
): Record<string, unknown> {
if (elements) {
const object: Record<string, unknown> = {};
const object: Record<string, unknown> = Object.create(null);
for (const element of elements) {
if (options.excludeInternalFields && element.isInternalField()) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion packages/mongodb-query-util/src/in-value-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const inValueRange = (
field: any,
d: { value: any; dx?: number; bson?: any }
) => {
const compOperators: Record<string, (a: number, b: number) => boolean> = {
const compOperators: Readonly<
Record<string, (a: number, b: number) => boolean>
> = {
$gte: function (a: number, b: number) {
return a >= b;
},
Expand Down
Loading