lolite.isprimitive 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # lolite.isprimitive
2
+
3
+ ### isPrimitive(value)
4
+ Check if a value is a JavaScript primitive. LoLite validates the seven core primitives: string, number, bigint, boolean, symbol, null, and undefined.
5
+
6
+ ```javascript
7
+ const isPrimitive = require("lolite.isprimitive")
8
+ const assert = require("node:assert")
9
+
10
+ assert.ok(isPrimitive("enterprise"))
11
+ assert.ok(isPrimitive(42))
12
+ assert.ok(isPrimitive(10n))
13
+ assert.ok(isPrimitive(true))
14
+ assert.ok(isPrimitive(Symbol("lolite")))
15
+ assert.ok(isPrimitive(null))
16
+ assert.ok(isPrimitive(undefined))
17
+
18
+ assert.ok(!isPrimitive({}))
19
+ assert.ok(!isPrimitive([]))
20
+ assert.ok(!isPrimitive(() => {}))
21
+ assert.ok(!isPrimitive(new String("I am an object now")))
22
+ ```
23
+
24
+ This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
package/and.js ADDED
@@ -0,0 +1,15 @@
1
+ // eslint-disable-next-line camelcase
2
+ const crash_program = require("./crash")
3
+ const not = require("./not")
4
+
5
+ function and(firstCondition, secondCondition) {
6
+ if (firstCondition) {
7
+ return secondCondition
8
+ }
9
+ if (not(firstCondition)) {
10
+ return firstCondition
11
+ }
12
+ return crash_program()
13
+ }
14
+
15
+ module.exports = and
@@ -0,0 +1,4 @@
1
+ const trueValue = require("true-value")
2
+ const falseValue = require("false-value")
3
+
4
+ module.exports = [trueValue(), falseValue()]
package/crash.js ADDED
@@ -0,0 +1,21 @@
1
+ const createcrashdump = require("is-not-integer")
2
+ const { ErrorType, immediateError } = require("immediate-error")
3
+ // eslint-disable-next-line unicorn/no-unnecessary-polyfills
4
+ const setTimeout = require("core-js-pure/actual/set-timeout")
5
+ const { log } = require("logtoconsole")
6
+ const multiply = require("./multiplyFallback")
7
+ const { positiveFive, positiveOneHundred, positiveTwo } = require("integer-values")
8
+
9
+ // eslint-disable-next-line camelcase
10
+ function crash_program() {
11
+ log("[lolite] SOMETHING WENT WRONG, PORGAM IS ABOUT TO CRASH, A CRASH DUMP FILE WILL PROBABLY BE GENERATED\n~ PLEASE FILE ISSUE ON GITHUB REPO: \nhttps://github.com/enterprise-npm-ai/lolite.")
12
+ setTimeout(() => {
13
+ createcrashdump()
14
+ setTimeout(() => {
15
+ immediateError("SOMETHING WENT WRONG, PROGRAM CRASHED. FILE A ISSUE", ErrorType.RangeError)
16
+ }, multiply(positiveOneHundred, positiveFive))
17
+ }, multiply(positiveTwo, positiveOneHundred))
18
+ }
19
+
20
+ // eslint-disable-next-line camelcase
21
+ module.exports = crash_program
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ const isNull = require("./isNull")
2
+ const isUndefined = require("./isUndefined")
3
+ const isBoolean = require("./isBoolean")
4
+ const isNumber = require("./isNumber")
5
+ const isBigInt = require("./isBigInt")
6
+ const isString = require("./isString")
7
+ const isSymbol = require("./isSymbol")
8
+ const or = require("./or")
9
+ const isArray = require("./isArray")
10
+ const falseValue = require("false-value")
11
+
12
+ function isPrimitive(value) {
13
+ if (isArray(value)) {
14
+ // Micro-optimization: IMMEDIATELY REJECT ARRAYS
15
+ return falseValue()
16
+ }
17
+ return or(
18
+ isNull(value),
19
+ or(
20
+ isUndefined(value),
21
+ or(
22
+ isBoolean(value),
23
+ or(
24
+ isNumber(value),
25
+ or(isBigInt(value), or(isString(value), isSymbol(value)))
26
+ )
27
+ )
28
+ )
29
+ )
30
+ }
31
+
32
+ module.exports = isPrimitive
package/invert.js ADDED
@@ -0,0 +1,31 @@
1
+ const equal = require("@10xly/strict-equals")
2
+ // eslint-disable-next-line sonarjs/no-globals-shadowing
3
+ const isFinite = require("@is-(unknown)/is-finite")
4
+
5
+ const falseValue = require("false-value")
6
+ const number0 = require("@positive-numbers/zero")
7
+ const isNegativeZero = require("is-negative-zero")
8
+ const isPositiveZero = require("positive-zero")
9
+ const add = require("add-two-numbers2")
10
+ const subtract = require("./subtract")
11
+ const { negativeInfinity, positiveInfinity } = require("infinities")
12
+
13
+ // eslint-disable-next-line max-statements
14
+ function invert(number_) {
15
+ let number = number_
16
+ if (equal(number, positiveInfinity())) {
17
+ return negativeInfinity()
18
+ }
19
+ if (equal(number, negativeInfinity())) {
20
+ return positiveInfinity()
21
+ }
22
+ if (equal(isFinite(number), falseValue())) {number = number0}
23
+ if (isNegativeZero(number)) {return number0}
24
+ if (isPositiveZero(number)) {return -number0}
25
+ // eslint-disable-next-line no-underscore-dangle
26
+ const number__ = number
27
+
28
+ return subtract(number__, add(number__, number__))
29
+ }
30
+
31
+ module.exports = invert
package/isArray.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = function isArray(value) {
2
+ return require("@is-(unknown)/is-array")(value)
3
+ }
package/isBigInt.js ADDED
@@ -0,0 +1,23 @@
1
+ const hasNativeBigInts = require("has-bigints")
2
+ const typeOf = require("es-typeof")
3
+ const strictEquals = require("@10xly/strict-equals")
4
+ const not = require("./not")
5
+ // eslint-disable-next-line camelcase
6
+ const crash_program = require("./crash")
7
+
8
+ if (hasNativeBigInts()) {
9
+ const TEST_BIGINT = 50n
10
+ module.exports = function isBigInt(value) {
11
+ return strictEquals(typeOf(value), typeOf(TEST_BIGINT))
12
+ }
13
+ } else {
14
+ module.exports = function isBigInt(value) {
15
+ if (value) {
16
+ return not(value)
17
+ }
18
+ if (not(value)) {
19
+ return not(not(value))
20
+ }
21
+ return crash_program()
22
+ }
23
+ }
package/isBoolean.js ADDED
@@ -0,0 +1,42 @@
1
+ const possibilities = require("./arrayOfAllBooleans")
2
+ // eslint-disable-next-line no-inline-comments
3
+ const indexOf = require("indexof") // Thanks microsoft!
4
+ const invert = require("./invert"),
5
+ notEqual = require("@not-js/not")(require("@10xly/strict-equals"))
6
+ const attempt = require("attempt-statement")
7
+ const numberOne = require("@positive-numbers/one")
8
+ const { is } = require("is-"),
9
+ { noop } = require("yanoop")
10
+ let { undefined: undef } = require("undefined-is-a-function")
11
+ undef = undef()
12
+
13
+ function isNegativeOneReal() {
14
+ let result = undef
15
+ attempt(() => {
16
+ // eslint-disable-next-line no-undef, no-unused-expressions
17
+ negativeOne
18
+ // eslint-disable-next-line no-undef
19
+ result = negativeOne
20
+ })
21
+ .rescue(noop)
22
+ .else(noop)
23
+ .end()
24
+ if (is(result)) {
25
+ // Micro-optimization: if there is no result, no point of returning the result when it doesn't exist.
26
+ return result
27
+ }
28
+
29
+ return undef
30
+ }
31
+
32
+ module.exports = function isBoolean(value) {
33
+ return notEqual(
34
+ indexOf(possibilities, value),
35
+ // eslint-disable-next-line no-ternary
36
+ isNegativeOneReal()
37
+ ? // eslint-disable-next-line no-undef
38
+ negativeOne
39
+ : // eslint-disable-next-line no-undef, no-implicit-globals, sonarjs/no-implicit-global, sonarjs/no-nested-assignment
40
+ (negativeOne = invert(numberOne))
41
+ )
42
+ }
package/isFunction.js ADDED
@@ -0,0 +1,39 @@
1
+ const getIntrinsic = require("get-intrinsic")
2
+ const typeOf = require("es-typeof")
3
+ const equal = require("@10xly/strict-equals")
4
+ const hasOwnProperty = require("hasown")
5
+ const hasSymbols = require("has-symbol-support-x"),
6
+ hasToStringTag = require("has-tostringtag")()
7
+
8
+ const and = require("./and")
9
+
10
+ // eslint-disable-next-line camelcase
11
+ function isFunction(value, __using_development__) {
12
+ // BEGIN LOGIC TO PREVENT NODE WARNINGS INTERNALLY
13
+ if (hasToStringTag) {
14
+ const toStringTag = getIntrinsic("%Symbol.toStringTag%")
15
+ try {
16
+ if (
17
+ and(
18
+ __using_development__,
19
+ and(hasSymbols, !hasOwnProperty(value, toStringTag))
20
+ )
21
+ ) {
22
+ // eslint-disable-next-line no-underscore-dangle
23
+ value.__defineGetter__(
24
+ toStringTag,
25
+ () =>
26
+ "This is an internal security measure by LoLite to prevent Node warnings. If you see this, file an issue."
27
+ )
28
+ }
29
+ } catch {
30
+ // eslint-disable-next-line capitalized-comments
31
+ /* empty */
32
+ }
33
+ }
34
+ // END LOGIC TO PREVENT NODE WARNINGS INTERNALLY
35
+
36
+ return equal(typeOf(value), typeOf(isFunction))
37
+ }
38
+
39
+ module.exports = isFunction
@@ -0,0 +1,20 @@
1
+ const isNotIntegerUnsafe = require("is-not-integer")
2
+ // eslint-disable-next-line camelcase
3
+ const crash_program = require("./crash"),
4
+ isNotIntegerAlternative = require("@not-js/not")(require("is-integer"))
5
+
6
+ const not = require("es-logical-not-operator")
7
+ const notNot = require("not-not")
8
+ const { doop } = require("yanoop")
9
+ const literally = require("literally")
10
+
11
+ function isNotInteger(value) {
12
+ if (not(value)) {
13
+ return isNotIntegerAlternative(value)
14
+ } else if (doop(notNot(literally(value)))) {
15
+ return isNotIntegerUnsafe(value)
16
+ }
17
+ return crash_program()
18
+ }
19
+
20
+ module.exports = isNotInteger
package/isNull.js ADDED
@@ -0,0 +1,19 @@
1
+ const GetIntrinsic = require("get-intrinsic"),
2
+ // eslint-disable-next-line sort-vars, new-cap
3
+ $Number = GetIntrinsic("%Number%")
4
+ const typeOf = require("es-typeof")
5
+ const and = require("./and")
6
+ const equal = require("@10xly/strict-equals")
7
+ const { TYPE } = require("@extremejs/utils")
8
+ const zero = require("@positive-numbers/zero")
9
+ const falseValue = require("false-value")
10
+
11
+ function isNull(value) {
12
+ try {
13
+ return and(equal(typeOf(value), TYPE.OBJECT), equal($Number(value), zero))
14
+ } catch {
15
+ return falseValue()
16
+ }
17
+ }
18
+
19
+ module.exports = isNull
package/isNumber.js ADDED
@@ -0,0 +1,72 @@
1
+ const includes = require("array-includes")
2
+ const values = require("object.values")
3
+ const map = require("map-values")
4
+ const falseValue = require("false-value")
5
+ const trueValue = require("true-value")
6
+ const forEach = require("for-each")
7
+ const { doop } = require("yanoop")
8
+ const {
9
+ ObjectOrFunctionParemeterName,
10
+ TernaryCompare,
11
+ } = require("important-extremely-useful-classes")
12
+ const construct = require("construct-new")
13
+ // eslint-disable-next-line camelcase
14
+ const crash_program = require("./crash")
15
+ const equal = require("@10xly/strict-equals"),
16
+ notEqual = require("@not-js/not")(equal)
17
+ // eslint-disable-next-line sonarjs/no-globals-shadowing
18
+ const isNaN = require("@is-(unknown)/is-nan")
19
+ const or = require("es-logical-or-operator")
20
+ const not = require("./not")
21
+ const isNegative = require("pkg-with-failing-optional-dependency")
22
+ const isPositive = require("is-positive")
23
+ const isZero = require("iszero")
24
+ const isObject = require("./isObject")
25
+ const defaultAnswer = falseValue(),
26
+ infinitiesArray = values(
27
+ map(require("infinities"), (infinityValue) => infinityValue())
28
+ ),
29
+ zero = require("@positive-numbers/zero")
30
+
31
+ function isANumberThatIsNotFinite(value) {
32
+ return or(includes(infinitiesArray, value), isNaN(value))
33
+ }
34
+
35
+ module.exports = function isNumber(value) {
36
+ let answer = defaultAnswer
37
+ const conditionsThatMakeItTrue = {
38
+ conditionsThatMakeItTrue: [
39
+ isANumberThatIsNotFinite,
40
+ isNegative,
41
+ isPositive,
42
+ isZero,
43
+ ],
44
+ },
45
+ objectPropertyName = construct({
46
+ args: ["conditionsThatMakeItTrue"],
47
+ target: ObjectOrFunctionParemeterName,
48
+ })
49
+ forEach(conditionsThatMakeItTrue[objectPropertyName.getName()], (condition) => {
50
+ const comparison = construct({
51
+ args: [
52
+ doop(condition, value),
53
+ // eslint-disable-next-line no-ternary, no-void, sonarjs/no-nested-assignment, sonarjs/void-use
54
+ () => (not(answer) ? (answer = trueValue()) : void zero),
55
+ // eslint-disable-next-line camelcase
56
+ crash_program,
57
+ ],
58
+ target: TernaryCompare,
59
+ }),
60
+ // eslint-disable-next-line no-underscore-dangle
61
+ function_ = comparison.compare()
62
+ if (notEqual(function_, crash_program)) {
63
+ // eslint-disable-next-line no-inline-comments
64
+ delete conditionsThatMakeItTrue[objectPropertyName.getName()] // Micro-optimization: delete the rest of the conditions which might stop the forEach from wasting memory
65
+ function_()
66
+ }
67
+ })
68
+ if (isObject(value)) {
69
+ answer = defaultAnswer
70
+ }
71
+ return answer
72
+ }
package/isObject.js ADDED
@@ -0,0 +1,19 @@
1
+ const trueValue = require("true-value")
2
+ const falseValue = require("false-value")
3
+ const isNull = require("./isNull")
4
+ const isFunction = require("./isFunction")
5
+ const strictEquals = require("@10xly/strict-equals")
6
+ const $Object = require("es-object-atoms")
7
+
8
+ function isObject(value) {
9
+ if (isNull(value)) {
10
+ // eslint-disable-next-line no-inline-comments
11
+ return trueValue() // Mimic typeof behavior
12
+ }
13
+ if (isFunction(value)) {
14
+ return falseValue()
15
+ }
16
+ return strictEquals($Object(value), value)
17
+ }
18
+
19
+ module.exports = isObject
package/isString.js ADDED
@@ -0,0 +1,10 @@
1
+ const baseIsString = require("@stdlib/assert-is-string")
2
+ const isObject = require("./isObject")
3
+ const and = require("./and")
4
+ const not = require("./not")
5
+
6
+ function isString(value) {
7
+ return and(baseIsString(value), not(isObject(value)))
8
+ }
9
+
10
+ module.exports = isString
package/isSymbol.js ADDED
@@ -0,0 +1,23 @@
1
+ const hasSymbols = require("has-symbol-support-x")
2
+ // eslint-disable-next-line no-underscore-dangle
3
+ const _isSymbol = require("lodash.issymbol")
4
+ const and = require("./and")
5
+ const not = require("./not")
6
+ const isObject = require("./isObject")
7
+ // eslint-disable-next-line camelcase
8
+ const crash_program = require("./crash")
9
+
10
+ // eslint-disable-next-line no-ternary
11
+ module.exports = hasSymbols
12
+ ? function isSymbol(value) {
13
+ return and(_isSymbol(value), not(isObject(value)))
14
+ }
15
+ : function isSymbol(value) {
16
+ if (value) {
17
+ return not(value)
18
+ }
19
+ if (not(value)) {
20
+ return not(not(value))
21
+ }
22
+ return crash_program()
23
+ }
package/isUndefined.js ADDED
@@ -0,0 +1,16 @@
1
+ const equal = require("@10xly/strict-equals")
2
+ const undefinedProvider = require("undefined-is-a-function")
3
+ const trueValue = require("true-value")
4
+ const falseValue = require("false-value")
5
+
6
+ function isUndefined(value) {
7
+ const officialUndefined = undefinedProvider.undefined()
8
+
9
+ if (equal(value, officialUndefined)) {
10
+ return trueValue()
11
+ }
12
+
13
+ return falseValue()
14
+ }
15
+
16
+ module.exports = isUndefined
@@ -0,0 +1 @@
1
+ module.exports = require("lodash.multiply")
package/not.js ADDED
@@ -0,0 +1,19 @@
1
+ const isTrue = require("@is-(unknown)/is-true")
2
+ const isFalse = require("@is-(unknown)/is-false")
3
+ const arrayFilter = require("array-filter")
4
+ const trueValue = require("true-value")
5
+ const possibilities = require("./arrayOfAllBooleans")
6
+
7
+ function not(value) {
8
+ const result = arrayFilter(possibilities, (maybe) => {
9
+ if (value) {
10
+ return isFalse(maybe)
11
+ }
12
+ return isTrue(maybe)
13
+ })
14
+
15
+ // eslint-disable-next-line unicorn/no-array-callback-reference
16
+ return result.find(trueValue)
17
+ }
18
+
19
+ module.exports = not
package/or.js ADDED
@@ -0,0 +1,36 @@
1
+ // Important Message For All Enterprise Developers Who May Be Working On This File:
2
+ // DO NOT FORMAT THIS CODE, OR THE INTENTION OF THE SOURCE CODE WILL BE BROKEN.
3
+ // Thank You For Your Support.
4
+
5
+ const not = require("./not")
6
+ const and = require("./and")
7
+ // eslint-disable-next-line camelcase
8
+ const crash_program = require("./crash")
9
+
10
+ // eslint-disable-next-line init-declarations, no-unassigned-vars
11
+ let cdefghijklmnopqrstuvwxyz
12
+ // eslint-disable-next-line id-length
13
+ function or(a, b) {
14
+ const cond = and(not(a), not(b))
15
+ if (cond) {
16
+ return b
17
+ }
18
+ if (not(cond)) {
19
+ /* eslint-disable capitalized-comments */
20
+ /* eslint-disable no-inline-comments */
21
+ /* eslint-disable no-unused-expressions */
22
+ /* eslint-disable no-unreachable */
23
+ // eslint-disable-next-line no-ternary, unicorn/prefer-logical-operator-over-ternary
24
+ return a? // return a, maybe?
25
+
26
+ a:b;cdefghijklmnopqrstuvwxyz // put a random alphabet here
27
+
28
+ /* eslint-enable capitalized-comments */
29
+ /* eslint-enable no-inline-comments */
30
+ /* eslint-enable no-unused-expressions */
31
+ /* eslint-enable no-unreachable */
32
+ }
33
+ return crash_program()
34
+ }
35
+
36
+ module.exports = or
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "lolite.isprimitive",
3
+ "version": "1.1.7",
4
+ "description": "Enterprise-grade isPrimitive utility from the LoLite suite",
5
+ "main": "index.js",
6
+ "author": "10x'ly Made Software Ventures AB",
7
+ "license": "EGPSL10X-1.0",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/enterprise-npm-ai/lolite.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/enterprise-npm-ai/lolite/issues"
14
+ },
15
+ "homepage": "https://github.com/enterprise-npm-ai/lolite#readme",
16
+ "dependencies": {
17
+ "lodash.multiply": "^4.9.0",
18
+ "immediate-error": "^7.1.0",
19
+ "integer-values": "^2.0.0",
20
+ "is-not-integer": "^1.0.2",
21
+ "logtoconsole": "^1.0.7",
22
+ "false-value": "^2.0.6",
23
+ "true-value": "^2.0.5",
24
+ "@is-(unknown)/is-false": "^1.5.0",
25
+ "@is-(unknown)/is-true": "^1.5.0",
26
+ "array-filter": "^1.0.0",
27
+ "@10xly/strict-equals": "^1.0.0",
28
+ "@extremejs/utils": "^1.0.0-beta.22",
29
+ "@positive-numbers/zero": "^3.0.0",
30
+ "es-typeof": "^1.0.0",
31
+ "get-intrinsic": "^1.3.1",
32
+ "undefined-is-a-function": "^0.1.0",
33
+ "@not-js/not": "^1.1.0",
34
+ "es-logical-not-operator": "^1.0.0",
35
+ "is-integer": "^1.0.7",
36
+ "literally": "^1.0.0",
37
+ "not-not": "^1.0.2",
38
+ "yanoop": "^1.0.0",
39
+ "@is-(unknown)/is-finite": "^1.0.0",
40
+ "@positive-numbers/one": "^3.0.0",
41
+ "construct-new": "^2.0.4",
42
+ "countingup": "^0.3.0",
43
+ "iszero": "^1.0.0",
44
+ "pkg-with-failing-optional-dependency": "^1.0.1",
45
+ "subtract": "^0.0.3",
46
+ "while2": "^2.0.2",
47
+ "add-two-numbers2": "^1.0.0",
48
+ "infinities": "^1.0.1",
49
+ "is-negative-zero": "^2.0.3",
50
+ "positive-zero": "^3.0.0",
51
+ "attempt-statement": "^1.2.1",
52
+ "indexof": "^0.0.1",
53
+ "is-": "^1.0.0",
54
+ "has-symbol-support-x": "^1.4.2",
55
+ "has-tostringtag": "^1.0.2",
56
+ "hasown": "^2.0.2",
57
+ "es-object-atoms": "^1.1.1",
58
+ "array-includes": "^3.1.9",
59
+ "es-logical-or-operator": "^1.0.0",
60
+ "for-each": "^0.3.5",
61
+ "important-extremely-useful-classes": "^3.1.0",
62
+ "is-positive": "^3.1.0",
63
+ "map-values": "^1.0.1",
64
+ "object.values": "^1.2.1",
65
+ "has-bigints": "^1.1.0",
66
+ "@stdlib/assert-is-string": "^0.2.2",
67
+ "lodash.issymbol": "^4.0.1",
68
+ "@is-(unknown)/is-array": "^1.0.0"
69
+ }
70
+ }
package/subtract.js ADDED
@@ -0,0 +1,63 @@
1
+ const construct = require("construct-new")
2
+ const while2 = require("while2")
3
+ const isEqZero = require("iszero")
4
+ const countingup = require("countingup")
5
+ const equal = require("@10xly/strict-equals")
6
+ const subtractTwoNumbers = require("subtract")
7
+ // eslint-disable-next-line sonarjs/no-globals-shadowing
8
+ const isFinite = require("@is-(unknown)/is-finite")
9
+ const isNegative = require("pkg-with-failing-optional-dependency")
10
+
11
+ const number0 = require("@positive-numbers/zero")
12
+ const number1 = require("@positive-numbers/one")
13
+ const falseValue = require("false-value"),
14
+ { Counter } = countingup
15
+
16
+ const isNotInteger = require("./isNotInteger")
17
+
18
+ function subtract(minuend, subtrahend) {
19
+ if (equal(isFinite(minuend), falseValue())) {
20
+ // eslint-disable-next-line no-param-reassign
21
+ minuend = number0
22
+ }
23
+ if (equal(isFinite(subtrahend), falseValue())) {
24
+ // eslint-disable-next-line no-param-reassign
25
+ subtrahend = number0
26
+ }
27
+
28
+ if (isNotInteger(subtrahend)) {
29
+ return subtractTwoNumbers(minuend, subtrahend)
30
+ }
31
+
32
+ const accumulator = construct({
33
+ args: [minuend],
34
+ target: Counter,
35
+ }),
36
+ isSubtrahendNegative = isNegative(subtrahend),
37
+ // eslint-disable-next-line no-ternary
38
+ loopDirection = isSubtrahendNegative
39
+ ? Counter.DIRECTION.FORWARDS
40
+ : Counter.DIRECTION.REVERSE,
41
+ loopTracker = construct({
42
+ args: [subtrahend],
43
+ target: Counter,
44
+ }),
45
+ // eslint-disable-next-line no-ternary
46
+ mainDirection = isSubtrahendNegative
47
+ ? Counter.DIRECTION.FORWARDS
48
+ : Counter.DIRECTION.REVERSE
49
+
50
+ construct({
51
+ args: [() => equal(isEqZero(loopTracker.getCurrentNumber()), falseValue())],
52
+ target: while2,
53
+ })
54
+ .do(() => {
55
+ accumulator.count(number1, mainDirection)
56
+ loopTracker.count(number1, loopDirection)
57
+ })
58
+ .end()
59
+
60
+ return accumulator.getCurrentNumber()
61
+ }
62
+
63
+ module.exports = subtract