jamesleesaunders / d3-x3d

3D Data Driven Charting Library with D3 and X3D
https://jamesleesaunders.github.io/d3-x3d/
GNU General Public License v2.0
110 stars 22 forks source link

Convert three variable assignments to the usage of compound operators #209

Closed elfring closed 1 year ago

elfring commented 2 years ago

: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];
jamesleesaunders commented 2 years ago

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

elfring commented 2 years ago

: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?

jamesleesaunders commented 1 year ago

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