Skip to content

Commit 6d490c0

Browse files
Remove array.prototype.flat() uses and fix package.json formatting
1 parent 9da7bb6 commit 6d490c0

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,16 @@
5858
"webpack-cli": "^5.1.4",
5959
"yargs": "3.10.0"
6060
},
61-
"homepage": "https://iiif-commons.github.io/manifesto-3d/",
6261
"dependencies": {
6362
"@edsilv/http-status-codes": "^1.0.3",
6463
"@iiif/vocabulary": "^1.0.26",
64+
"color-string": "1.9",
6565
"isomorphic-unfetch": "^3.0.0",
6666
"lodash": "^4.17.21",
6767
"node-fetch": "2",
68+
"threejs-math": "^0.147",
6869
"unfetch": "^4.2.0",
69-
"webpack": "^5.89.0",
70-
"color-string": "1.9",
71-
"threejs-math": "^0.147"
70+
"webpack": "^5.89.0"
7271
},
7372
"directories": {
7473
"test": "test"

src/Canvas.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,10 @@ export class Canvas extends Resource {
247247
.map(annotationPage => new AnnotationPage(annotationPage, this.options)) as AnnotationPage[];
248248
if (!annotationPages.length) return [];
249249

250-
const annotations = annotationPages
251-
.map(page => page.getItems())
252-
.flat()
253-
.map(annotation => new Annotation(annotation, this.options));
254-
255-
return annotations;
250+
const annotationsNested = annotationPages.map(page => page.getItems()) as Annotation[][];
251+
const annotationsFlat = flattenDeep(annotationsNested) as Annotation[];
252+
253+
return annotationsFlat.map(annotation => new Annotation(annotation, this.options));
256254
}
257255

258256
getOtherContent(): Promise<AnnotationList[]> {

src/Scene.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
ManifestResource,
77
Color
88
} from "./internal";
9+
// @ts-ignore
10+
import flattenDeep from "lodash/flattenDeep";
911

1012
export class Scene extends ManifestResource {
1113
constructor(jsonld: any, options: IManifestoOptions) {
@@ -77,11 +79,9 @@ export class Scene extends ManifestResource {
7779
.map(annotationPage => new AnnotationPage(annotationPage, this.options)) as AnnotationPage[];
7880
if (!annotationPages.length) return [];
7981

80-
const annotations = annotationPages
81-
.map(page => page.getItems())
82-
.flat()
83-
.map(annotation => new Annotation(annotation, this.options));
84-
85-
return annotations;
82+
const annotationsNested = annotationPages.map(page => page.getItems()) as Annotation[][];
83+
const annotationsFlat = flattenDeep(annotationsNested) as Annotation[];
84+
85+
return annotationsFlat.map(annotation => new Annotation(annotation, this.options));
8686
}
8787
}

0 commit comments

Comments
 (0)