d3-x3d icon indicating copy to clipboard operation
d3-x3d copied to clipboard

Convert three variable assignments to the usage of compound operators

Open elfring opened this issue 2 years ago • 2 comments

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of compound operators accordingly.

diff --git a/dist/d3-x3d.js b/dist/d3-x3d.js
index aae2875..f52dfb6 100644
--- a/dist/d3-x3d.js
+++ b/dist/d3-x3d.js
@@ -9,7 +9,7 @@
 (function (global, factory) {
   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('d3'), require('d3-shape'), require('d3-array'), require('d3-interpolate')) :
   typeof define === 'function' && define.amd ? define(['d3', 'd3-shape', 'd3-array', 'd3-interpolate'], factory) :
-  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.d3 = global.d3 || {}, global.d3.x3d = factory(global.d3, global.d3, global.d3, global.d3)));
+  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.d3 ||= {}, global.d3.x3d = factory(global.d3, global.d3, global.d3, global.d3)));
 }(this, (function (d3, d3Shape, d3Array, d3Interpolate) { 'use strict';
 
   function _interopNamespace(e) {
@@ -115,7 +115,7 @@
 
   function svgPathInterpolator(path, epsilon, samples) {
     // Create detached SVG path
-    path = path || "M0,0L1,1";
+    path ||= "M0,0L1,1";
     var area = document.createElementNS("http://www.w3.org/2000/svg", "svg");
     area.innerHTML = "<path></path>";
     var svgpath = area.querySelector("path");
@@ -4798,7 +4798,7 @@
    **/
 
   function setAxisAngle(out, axis, rad) {
-    rad = rad * 0.5;
+    rad *= 0.5;
     var s = Math.sin(rad);
     out[0] = s * axis[0];
     out[1] = s * axis[1];

elfring avatar Dec 18 '21 14:12 elfring

Hi @elfring thanks for your suggestions! These are great! You are more than welcome to raise these as a Pull Request - I would love to have people like you contributing :-) (If you would rather not I am happy to apply your suggestions myself) Thanks again, Jim

jamesleesaunders avatar Dec 18 '21 15:12 jamesleesaunders

:thought_balloon: It would be nice if you can integrate such small source code adjustments also directly (if you find them acceptable). Should any implementation details be reconsidered once more?

elfring avatar Dec 18 '21 16:12 elfring

Thanks for the suggestions. The changes you suggest are not directly in d3-x3d but rather in included files from other projects.

jamesleesaunders avatar Nov 24 '22 15:11 jamesleesaunders