@build-tracker/build
Advanced tools
Comparing version
@@ -88,3 +88,2 @@ "use strict"; | ||
var _this = this; | ||
// @ts-ignore | ||
return artifactNames.reduce(function (sum, artifactName) { | ||
@@ -107,3 +106,2 @@ var artifact = _this._artifacts.get(artifactName); | ||
if (!this._totals) { | ||
// @ts-ignore we'll build this below | ||
this._totals = {}; | ||
@@ -110,0 +108,0 @@ this._artifacts.forEach(function (artifact) { |
{ | ||
"name": "@build-tracker/build", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-beta.4", | ||
"description": "Build Tracker tools for interacting with individual Builds", | ||
@@ -17,5 +17,5 @@ "author": "Paul Armstrong <paul@spaceyak.com>", | ||
"devDependencies": { | ||
"@build-tracker/types": "^1.0.0-beta.3" | ||
"@build-tracker/types": "^1.0.0-beta.4" | ||
}, | ||
"gitHead": "b69557e466c754d9dc0252eca9e9f214b3f253ee", | ||
"gitHead": "0fb6ad7d925b92774cbedcd461d1030464d2d9c2", | ||
"publishConfig": { | ||
@@ -22,0 +22,0 @@ "access": "public" |
@@ -21,3 +21,3 @@ /** | ||
export interface Artifact<AS extends ArtifactSizes> { | ||
export interface Artifact { | ||
// Unique hash of the contents of this artifact. | ||
@@ -28,3 +28,3 @@ hash: string; | ||
// Computed sizes of the build artifact | ||
sizes: AS; | ||
sizes: ArtifactSizes; | ||
} | ||
@@ -38,9 +38,9 @@ | ||
export default class Build<M extends BuildMeta = BuildMeta, A extends ArtifactSizes = ArtifactSizes> { | ||
export default class Build<M extends BuildMeta = BuildMeta> { | ||
private _meta: M; | ||
private _artifacts: Map<string, Artifact<A>>; | ||
private _totals: A; | ||
private _artifacts: Map<string, Artifact>; | ||
private _totals: ArtifactSizes; | ||
private _sizeKeys: Set<string>; | ||
public constructor(meta: M, artifacts: Array<Artifact<A>>) { | ||
public constructor(meta: M, artifacts: Array<Artifact>) { | ||
this._meta = Object.freeze(meta); | ||
@@ -53,10 +53,7 @@ this._artifacts = new Map(); | ||
public static fromJSON<M extends BuildMeta = BuildMeta, A extends ArtifactSizes = ArtifactSizes>(build: { | ||
meta: M; | ||
artifacts: Array<Artifact<A>>; | ||
}): Build<M, A> { | ||
public static fromJSON<M extends BuildMeta = BuildMeta>(build: { meta: M; artifacts: Array<Artifact> }): Build<M> { | ||
return new Build(build.meta, build.artifacts); | ||
} | ||
public toJSON(): { meta: M; artifacts: Array<Artifact<A>> } { | ||
public toJSON(): { meta: M; artifacts: Array<Artifact> } { | ||
return { meta: this.meta, artifacts: Array.from(this._artifacts.values()) }; | ||
@@ -85,3 +82,3 @@ } | ||
public get artifacts(): Array<Artifact<A>> { | ||
public get artifacts(): Array<Artifact> { | ||
return Array.from(this._artifacts.values()); | ||
@@ -102,3 +99,3 @@ } | ||
public getArtifact(name: string): Artifact<A> { | ||
public getArtifact(name: string): Artifact { | ||
return this._artifacts.get(name); | ||
@@ -111,5 +108,4 @@ } | ||
public getSum(artifactNames: Array<string>): A { | ||
// @ts-ignore | ||
return artifactNames.reduce((sum: A, artifactName: string) => { | ||
public getSum(artifactNames: Array<string>): ArtifactSizes { | ||
return artifactNames.reduce((sum: ArtifactSizes, artifactName: string) => { | ||
const artifact = this._artifacts.get(artifactName); | ||
@@ -128,5 +124,4 @@ if (artifact) { | ||
public getTotals(artifactFilters?: ArtifactFilters): A { | ||
public getTotals(artifactFilters?: ArtifactFilters): ArtifactSizes { | ||
if (!this._totals) { | ||
// @ts-ignore we'll build this below | ||
this._totals = {}; | ||
@@ -133,0 +128,0 @@ this._artifacts.forEach(artifact => { |
Sorry, the diff of this file is not supported yet
19242
-1.2%402
-1.71%