}
}
+type Instrumentations = Record<string | symbol, Function | number>
+
function createInstrumentations() {
- const mutableInstrumentations: Record<string, Function | number> = {
+ const mutableInstrumentations: Instrumentations = {
get(this: MapTypes, key: unknown) {
return get(this, key)
},
forEach: createForEach(false, false),
}
- const shallowInstrumentations: Record<string, Function | number> = {
+ const shallowInstrumentations: Instrumentations = {
get(this: MapTypes, key: unknown) {
return get(this, key, false, true)
},
forEach: createForEach(false, true),
}
- const readonlyInstrumentations: Record<string, Function | number> = {
+ const readonlyInstrumentations: Instrumentations = {
get(this: MapTypes, key: unknown) {
return get(this, key, true)
},
forEach: createForEach(true, false),
}
- const shallowReadonlyInstrumentations: Record<string, Function | number> = {
+ const shallowReadonlyInstrumentations: Instrumentations = {
get(this: MapTypes, key: unknown) {
return get(this, key, true, true)
},
forEach: createForEach(true, true),
}
- const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]
+ const iteratorMethods = [
+ 'keys',
+ 'values',
+ 'entries',
+ Symbol.iterator,
+ ] as const
+
iteratorMethods.forEach(method => {
- mutableInstrumentations[method as string] = createIterableMethod(
- method,
- false,
- false,
- )
- readonlyInstrumentations[method as string] = createIterableMethod(
- method,
- true,
- false,
- )
- shallowInstrumentations[method as string] = createIterableMethod(
- method,
- false,
- true,
- )
- shallowReadonlyInstrumentations[method as string] = createIterableMethod(
+ mutableInstrumentations[method] = createIterableMethod(method, false, false)
+ readonlyInstrumentations[method] = createIterableMethod(method, true, false)
+ shallowInstrumentations[method] = createIterableMethod(method, false, true)
+ shallowReadonlyInstrumentations[method] = createIterableMethod(
method,
true,
true,