lolite.or 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,17 @@
1
+ # lolite.or
2
+
3
+ ### or(a,b)
4
+ Returns `a` if `a` is truthy, else returns `b`.
5
+ ```javascript
6
+ const or = require("lolite.or")
7
+
8
+ console.log(or(true, false)) // true
9
+ console.log(or(false, true)) // true
10
+ console.log(or(true, true)) // true
11
+ console.log(or(false, false)) // false
12
+ console.log(or(0, true)) // true
13
+ console.log(or(0, "truthy value")) // "truthy value"
14
+ console.log(or("truthy value", false)) // "truthy value"
15
+ ```
16
+
17
+ 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,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
@@ -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/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "lolite.or",
3
+ "version": "1.1.7",
4
+ "description": "Enterprise-grade or 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
+ "false-value": "^2.0.6",
18
+ "true-value": "^2.0.5",
19
+ "@is-(unknown)/is-false": "^1.5.0",
20
+ "@is-(unknown)/is-true": "^1.5.0",
21
+ "array-filter": "^1.0.0",
22
+ "lodash.multiply": "^4.9.0",
23
+ "immediate-error": "^7.1.0",
24
+ "integer-values": "^2.0.0",
25
+ "is-not-integer": "^1.0.2",
26
+ "logtoconsole": "^1.0.7"
27
+ }
28
+ }