Skip to content

Commit c3b4a2e

Browse files
committed
fix typo, docs for utility types
1 parent dc1d05b commit c3b4a2e

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/sustainable-web-design.js

-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ class SustainableWebDesign {
176176
segmentResults = false,
177177
options = undefined
178178
) {
179-
// TODO (simon) figure out if this method call is correct
180179
const energyBycomponent = this.energyPerVisitByComponent(bytes, options);
181180

182181
if (typeof carbonIntensity !== "boolean") {

src/types.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,49 @@
140140
*/
141141

142142
/**
143+
* Utility type to create "- first" and "- subsequent" variants of each key in the incoming type.
144+
*
145+
* Ex. for this input type:
146+
*
147+
* {
148+
* keyOne: number,
149+
* keyTwo: number
150+
* }
151+
*
152+
* The output type will be:
153+
*
154+
* {
155+
* "keyOne - first": number,
156+
* "keyOne - subsequent": number,
157+
* "keyTwo - first": number,
158+
* "keyTwo - subsequent": number,
159+
* }
160+
*
143161
* @template {Record<string, unknown>} Object
144162
* @typedef {{
145163
* [K in Exclude<keyof Object, symbol> as `${K} - first`]: Object[K]
146164
* } & {
147-
* [K in Exclude<keyof Object, symbol> as `${K} - subsequest`]: Object[K]
165+
* [K in Exclude<keyof Object, symbol> as `${K} - subsequent`]: Object[K]
148166
* }} SegmentedByVisit
149167
*/
150168

151169
/**
170+
* Utility type to convert keys from representations of energy to representations of CO2.
171+
*
172+
* Ex. for this input type:
173+
*
174+
* {
175+
* keyOneEnergy: number,
176+
* keyTwoEnergy: number
177+
* }
178+
*
179+
* The output type will be:
180+
*
181+
* {
182+
* keyOneCO2: number,
183+
* keyTwoCO2: number
184+
* }
185+
*
152186
* @template {Record<string, unknown>} Object
153187
* @typedef {{
154188
* [K in Extract<keyof Object, string> as import('type-fest').Replace<K, 'Energy', 'CO2'>]: Object[K]

0 commit comments

Comments
 (0)