소스 검색

Move DecimalPlaceIsNonZero into common file

ApisNecros 1 년 전
부모
커밋
df996a1e2f
2개의 변경된 파일21개의 추가작업 그리고 20개의 파일을 삭제
  1. 0 20
      IntComp/Computer.js
  2. 21 0
      IntComp/common.js

+ 0 - 20
IntComp/Computer.js

@@ -166,23 +166,3 @@ module.exports = class Computer {
         this.stack = new Stack(stack);
     }
 };
-
-/**
- * Check whether the value at a specific spot in a number is non-zero
- *
- * Similar to the bitwise & operator, checks a "place" in a decimal number
- * to see if it has a non-zero value.
- *
- * @example
- * const test = 107;
- * console.log(DecimalPlaceIsNonZero(test, 1)) // true
- * console.log(DecimalPlaceIsNonZero(test, 2)) // false
- * console.log(DecimalPlaceIsNonZero(test, 3)) // true
- *
- * @param {number} input The number to check
- * @param {number} place The power of 10 to check against
- * @returns {boolean} Whether the value in that number's place is non-zero
- */
-function DecimalPlaceIsNonZero(input, place) {
-    return !!Math.floor((input % (10 ** place)) / (10 ** (place - 1)));
-}

+ 21 - 0
IntComp/common.js

@@ -8,6 +8,27 @@ function DeepClone(toClone) {
     return JSON.parse(JSON.stringify(toClone));
 }
 
+/**
+ * Check whether the value at a specific spot in a number is non-zero
+ *
+ * Similar to the bitwise & operator, checks a "place" in a decimal number
+ * to see if it has a non-zero value.
+ *
+ * @example
+ * const test = 107;
+ * console.log(DecimalPlaceIsNonZero(test, 1)) // true
+ * console.log(DecimalPlaceIsNonZero(test, 2)) // false
+ * console.log(DecimalPlaceIsNonZero(test, 3)) // true
+ *
+ * @param {number} input The number to check
+ * @param {number} place The power of 10 to check against
+ * @returns {boolean} Whether the value in that number's place is non-zero
+ */
+function DecimalPlaceIsNonZero(input, place) {
+    return !!Math.floor((input % (10 ** place)) / (10 ** (place - 1)));
+}
+
 module.exports = {
     DeepClone: DeepClone,
+    DecimalPlaceIsNonZero: DecimalPlaceIsNonZero,
 };