Merge pull request #15637 from Snuffleupagus/Array-from-map
Combine `Array.from` and `Array.prototype.map` calls
This commit is contained in:
		
						commit
						a7232339d8
					
				@ -1771,13 +1771,13 @@ class WidgetAnnotation extends Annotation {
 | 
				
			|||||||
    if (this.borderColor) {
 | 
					    if (this.borderColor) {
 | 
				
			||||||
      mk.set(
 | 
					      mk.set(
 | 
				
			||||||
        "BC",
 | 
					        "BC",
 | 
				
			||||||
        Array.from(this.borderColor).map(c => c / 255)
 | 
					        Array.from(this.borderColor, c => c / 255)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (this.backgroundColor) {
 | 
					    if (this.backgroundColor) {
 | 
				
			||||||
      mk.set(
 | 
					      mk.set(
 | 
				
			||||||
        "BG",
 | 
					        "BG",
 | 
				
			||||||
        Array.from(this.backgroundColor).map(c => c / 255)
 | 
					        Array.from(this.backgroundColor, c => c / 255)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return mk.size > 0 ? mk : null;
 | 
					    return mk.size > 0 ? mk : null;
 | 
				
			||||||
@ -3462,7 +3462,7 @@ class LineAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
    if (!this.appearance) {
 | 
					    if (!this.appearance) {
 | 
				
			||||||
      // The default stroke color is black.
 | 
					      // The default stroke color is black.
 | 
				
			||||||
      const strokeColor = this.color
 | 
					      const strokeColor = this.color
 | 
				
			||||||
        ? Array.from(this.color).map(c => c / 255)
 | 
					        ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
        : [0, 0, 0];
 | 
					        : [0, 0, 0];
 | 
				
			||||||
      const strokeAlpha = dict.get("CA");
 | 
					      const strokeAlpha = dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3473,7 +3473,7 @@ class LineAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (interiorColor) {
 | 
					      if (interiorColor) {
 | 
				
			||||||
        interiorColor = getRgbColor(interiorColor, null);
 | 
					        interiorColor = getRgbColor(interiorColor, null);
 | 
				
			||||||
        fillColor = interiorColor
 | 
					        fillColor = interiorColor
 | 
				
			||||||
          ? Array.from(interiorColor).map(c => c / 255)
 | 
					          ? Array.from(interiorColor, c => c / 255)
 | 
				
			||||||
          : null;
 | 
					          : null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
					      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
				
			||||||
@ -3527,7 +3527,7 @@ class SquareAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
    if (!this.appearance) {
 | 
					    if (!this.appearance) {
 | 
				
			||||||
      // The default stroke color is black.
 | 
					      // The default stroke color is black.
 | 
				
			||||||
      const strokeColor = this.color
 | 
					      const strokeColor = this.color
 | 
				
			||||||
        ? Array.from(this.color).map(c => c / 255)
 | 
					        ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
        : [0, 0, 0];
 | 
					        : [0, 0, 0];
 | 
				
			||||||
      const strokeAlpha = parameters.dict.get("CA");
 | 
					      const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3537,7 +3537,7 @@ class SquareAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (interiorColor) {
 | 
					      if (interiorColor) {
 | 
				
			||||||
        interiorColor = getRgbColor(interiorColor, null);
 | 
					        interiorColor = getRgbColor(interiorColor, null);
 | 
				
			||||||
        fillColor = interiorColor
 | 
					        fillColor = interiorColor
 | 
				
			||||||
          ? Array.from(interiorColor).map(c => c / 255)
 | 
					          ? Array.from(interiorColor, c => c / 255)
 | 
				
			||||||
          : null;
 | 
					          : null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
					      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
				
			||||||
@ -3581,7 +3581,7 @@ class CircleAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
    if (!this.appearance) {
 | 
					    if (!this.appearance) {
 | 
				
			||||||
      // The default stroke color is black.
 | 
					      // The default stroke color is black.
 | 
				
			||||||
      const strokeColor = this.color
 | 
					      const strokeColor = this.color
 | 
				
			||||||
        ? Array.from(this.color).map(c => c / 255)
 | 
					        ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
        : [0, 0, 0];
 | 
					        : [0, 0, 0];
 | 
				
			||||||
      const strokeAlpha = parameters.dict.get("CA");
 | 
					      const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3591,7 +3591,7 @@ class CircleAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (interiorColor) {
 | 
					      if (interiorColor) {
 | 
				
			||||||
        interiorColor = getRgbColor(interiorColor, null);
 | 
					        interiorColor = getRgbColor(interiorColor, null);
 | 
				
			||||||
        fillColor = interiorColor
 | 
					        fillColor = interiorColor
 | 
				
			||||||
          ? Array.from(interiorColor).map(c => c / 255)
 | 
					          ? Array.from(interiorColor, c => c / 255)
 | 
				
			||||||
          : null;
 | 
					          : null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
					      const fillAlpha = fillColor ? strokeAlpha : null;
 | 
				
			||||||
@ -3674,7 +3674,7 @@ class PolylineAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
    if (!this.appearance) {
 | 
					    if (!this.appearance) {
 | 
				
			||||||
      // The default stroke color is black.
 | 
					      // The default stroke color is black.
 | 
				
			||||||
      const strokeColor = this.color
 | 
					      const strokeColor = this.color
 | 
				
			||||||
        ? Array.from(this.color).map(c => c / 255)
 | 
					        ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
        : [0, 0, 0];
 | 
					        : [0, 0, 0];
 | 
				
			||||||
      const strokeAlpha = dict.get("CA");
 | 
					      const strokeAlpha = dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3760,7 +3760,7 @@ class InkAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
    if (!this.appearance) {
 | 
					    if (!this.appearance) {
 | 
				
			||||||
      // The default stroke color is black.
 | 
					      // The default stroke color is black.
 | 
				
			||||||
      const strokeColor = this.color
 | 
					      const strokeColor = this.color
 | 
				
			||||||
        ? Array.from(this.color).map(c => c / 255)
 | 
					        ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
        : [0, 0, 0];
 | 
					        : [0, 0, 0];
 | 
				
			||||||
      const strokeAlpha = parameters.dict.get("CA");
 | 
					      const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3923,7 +3923,7 @@ class HighlightAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        // Default color is yellow in Acrobat Reader
 | 
					        // Default color is yellow in Acrobat Reader
 | 
				
			||||||
        const fillColor = this.color
 | 
					        const fillColor = this.color
 | 
				
			||||||
          ? Array.from(this.color).map(c => c / 255)
 | 
					          ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
          : [1, 1, 0];
 | 
					          : [1, 1, 0];
 | 
				
			||||||
        const fillAlpha = parameters.dict.get("CA");
 | 
					        const fillAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3963,7 +3963,7 @@ class UnderlineAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (!this.appearance) {
 | 
					      if (!this.appearance) {
 | 
				
			||||||
        // Default color is black
 | 
					        // Default color is black
 | 
				
			||||||
        const strokeColor = this.color
 | 
					        const strokeColor = this.color
 | 
				
			||||||
          ? Array.from(this.color).map(c => c / 255)
 | 
					          ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
          : [0, 0, 0];
 | 
					          : [0, 0, 0];
 | 
				
			||||||
        const strokeAlpha = parameters.dict.get("CA");
 | 
					        const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4002,7 +4002,7 @@ class SquigglyAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (!this.appearance) {
 | 
					      if (!this.appearance) {
 | 
				
			||||||
        // Default color is black
 | 
					        // Default color is black
 | 
				
			||||||
        const strokeColor = this.color
 | 
					        const strokeColor = this.color
 | 
				
			||||||
          ? Array.from(this.color).map(c => c / 255)
 | 
					          ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
          : [0, 0, 0];
 | 
					          : [0, 0, 0];
 | 
				
			||||||
        const strokeAlpha = parameters.dict.get("CA");
 | 
					        const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4048,7 +4048,7 @@ class StrikeOutAnnotation extends MarkupAnnotation {
 | 
				
			|||||||
      if (!this.appearance) {
 | 
					      if (!this.appearance) {
 | 
				
			||||||
        // Default color is black
 | 
					        // Default color is black
 | 
				
			||||||
        const strokeColor = this.color
 | 
					        const strokeColor = this.color
 | 
				
			||||||
          ? Array.from(this.color).map(c => c / 255)
 | 
					          ? Array.from(this.color, c => c / 255)
 | 
				
			||||||
          : [0, 0, 0];
 | 
					          : [0, 0, 0];
 | 
				
			||||||
        const strokeAlpha = parameters.dict.get("CA");
 | 
					        const strokeAlpha = parameters.dict.get("CA");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -88,9 +88,8 @@ function getPdfColor(color, isFill) {
 | 
				
			|||||||
    return `${numberToString(gray)} ${isFill ? "g" : "G"}`;
 | 
					    return `${numberToString(gray)} ${isFill ? "g" : "G"}`;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    Array.from(color)
 | 
					    Array.from(color, c => numberToString(c / 255)).join(" ") +
 | 
				
			||||||
      .map(c => numberToString(c / 255))
 | 
					    ` ${isFill ? "rg" : "RG"}`
 | 
				
			||||||
      .join(" ") + ` ${isFill ? "rg" : "RG"}`
 | 
					 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user