lolite.identity 1.1.8 → 1.1.9

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 CHANGED
@@ -1,9 +1,7 @@
1
- # lolite.identity
2
-
3
- ### identity(value)
1
+ ## identity(value)
4
2
  Returns the value passed into the identity function.
5
3
  ```javascript
6
- const identity = require("lolite.identity")
4
+ const lolite = require("lolite.identity")
7
5
  const assert = require("node:assert")
8
6
 
9
7
  console.log(identity(2)) // 2
@@ -11,6 +9,117 @@ console.log(identity()) // undefined
11
9
  console.log(identity(true)) // true
12
10
  console.log(identity(null)) // null
13
11
  console.log(identity("enterprise")) // "enterprise"
14
- ```
15
-
16
- This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
12
+ ```
13
+
14
+ ### constant(value)
15
+ Returns a function that returns a value.
16
+ ```javascript
17
+ const lolite = require("lolite.identity")
18
+ const assert = require("node:assert")
19
+
20
+ console.log(lolite.constant(2)()) // 2
21
+ const returnEnterprise = lolite.constant("enterprise")
22
+ console.log(returnEnterprise()) // "enterprise"
23
+ ```
24
+
25
+ ### stubUndefined()
26
+ Returns the primitive value undefined.
27
+ ```javascript
28
+ const lolite = require("lolite.identity")
29
+ console.log(lolite.stubUndefined()) // undefined
30
+ ```
31
+
32
+ ### stubTrue()
33
+ Returns the primitive boolean value true.
34
+ ```javascript
35
+ const lolite = require("lolite.identity")
36
+ console.log(lolite.stubTrue()) // true
37
+ ```
38
+
39
+ ### stubFalse()
40
+ Returns the primitive boolean value false.
41
+ ```javascript
42
+ const lolite = require("lolite.identity")
43
+ console.log(lolite.stubFalse()) // false
44
+ ```
45
+
46
+ ### stubNaN()
47
+ Returns the primitive value NaN.
48
+ ```javascript
49
+ const lolite = require("lolite.identity")
50
+ console.log(lolite.stubNaN()) // NaN
51
+ ```
52
+
53
+ ### stubNull()
54
+ Returns the primitive value null.
55
+ ```javascript
56
+ const lolite = require("lolite.identity")
57
+ console.log(lolite.stubNull()) // null
58
+ ```
59
+
60
+ # EXTENDED DOCUMENTATION
61
+ LoLite contains some private utilities in its code that it uses internally. These are exported under the `__private` key in the default export. You probably don't want to use these, unless you have a really good reason to.
62
+
63
+ ### `arrayOfAllBooleans.js`
64
+ This is a file that exports an array that contains true and false.
65
+ ```javascript
66
+ const lolite = require("lolite.identity")
67
+
68
+ console.log(lolite.__private.arrayOfAllBooleans) // [true, false]
69
+ ```
70
+
71
+ ### `crash.js`
72
+ An internal function that crashes the program. This is used internally in code for cases that should never happen. If LoLite crashes, it is a serious bug and your Node.js could be broken, or the world could be ending.
73
+ ```javascript
74
+ const crash_program = require("lolite.identity").__private.crash
75
+ crash_program()
76
+ /* The above code will output something like this:
77
+
78
+ [lolite] SOMETHING WENT WRONG, PORGAM IS ABOUT TO CRASH, A CRASH DUMP FILE WILL PROBABLY BE GENERATED
79
+ ~ PLEASE FILE ISSUE ON GITHUB REPO:
80
+ https://github.com/enterprise-npm-ai/lolite.
81
+ Porgam crahed.
82
+ */
83
+ ```
84
+ It will also create a crash dump file with a filename like `crash_3989.bin` in your root project directory, with some stack dump information.
85
+ Note: you can also require `lolite/test/crash` and it will immediately crash the program, like this:
86
+ ```javascript
87
+ require("lolite/test/crash") // crashes program
88
+ ```
89
+
90
+ ### `date.js`
91
+ A file that just exports the `Date` constructor.
92
+ ```javascript
93
+ const $Date = require("lolite.identity").__private.date
94
+ const assert = require("node:assert")
95
+ assert.ok($Date === Date)
96
+ ```
97
+
98
+ ### `invertFallback.js`
99
+ A fallback implementation of `lolite.invert` to avoid circular dependencies. No non-finite-to-zero coercion is in this implementation.
100
+ ```javascript
101
+ const invert = require("lolite.identity").__private.invertFallback
102
+ console.log(invert(1)) // -1
103
+ console.log(invert(-1)) // 1
104
+ console.log(invert("hi")) // "hi" (normal lolite.invert would return -0)
105
+ ```
106
+
107
+ ### `isNotInteger.js`
108
+ An internal function that checks if a value is not an integer. This is used to avoid a crash-on-zero bug in the `is-not-integer` NPM package.
109
+ ```javascript
110
+ const isNotInteger = require("lolite.identity").__private.isNotInteger
111
+ console.log(isNotInteger(39)) // false
112
+ console.log(isNotInteger(3.2)) // true
113
+ console.log(isNotInteger("test")) // true
114
+ ```
115
+
116
+ ### `multiplyFallback.js`
117
+ A fallback implementation of `lolite.multiply` to avoid circular dependencies. No non-finite-to-zero coercion is in this implementation.
118
+ ```javascript
119
+ const lolite = require("lolite.identity")
120
+ console.log(lolite.__private.multiplyFallback(2, 6)) // 12
121
+ ```
122
+
123
+
124
+ ### `__using_development__` in `isFunction`
125
+ This internal feature is not a private function, it's a hidden argument in the `isFunction` function. The parameter is called `__using_development__`, and if it's on, it defines a getter on the value passed in for `Symbol.toStringTag`. The reason for this is that LoLite internally has a file that requires some other file that ends up requiring the first file. You might think this crashes the program, but it doesn't, because when you do infinite require loop like that Node.js cuts off the loop and makes it so when you require it it just returns an empty object. LoLite checks if the required file is not a function using `isFunction`, and if it is not a function, reassigns it to a fallback. However, the empty object that Node.js returns is actually an object but without any of the Object.prototype properties, so it doesn't have `Symbol.toStringTag` as a property. When it uses `isFunction`, it checks the toStringTag of the value to check if it's a function. This triggers a Node.js warning for accessing non-existent property `Symbol.toStringTag` on object. This is where the `__using_development__` parameter comes in. It stops this Node.js internal warning.
package/package.json CHANGED
@@ -1,26 +1,18 @@
1
1
  {
2
2
  "name": "lolite.identity",
3
- "version": "1.1.8",
4
- "description": "Enterprise-grade identity utility from the LoLite suite",
5
- "main": "index.js",
6
- "author": "10x'ly Made Software Ventures AB",
3
+ "version": "1.1.9",
4
+ "main": "src/lib/identity.js",
7
5
  "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
6
  "dependencies": {
17
- "false-value": "^2.0.6",
18
- "true-value": "^2.0.5",
19
- "array-filter": "^1.0.0",
20
- "@10xly/strict-equals": "^1.0.0",
7
+ "twice-call-wrapper": "^1.2.0",
8
+ "yanoop": "^1.0.0",
21
9
  "@identity-js/identity": "^1.2.1",
22
10
  "literally": "^1.0.0",
23
- "twice-call-wrapper": "^1.2.0",
24
- "yanoop": "^1.0.0"
11
+ "@is-(unknown)/is-true": "^1.5.0",
12
+ "@is-(unknown)/is-false": "^1.5.0",
13
+ "array-filter": "^1.0.0",
14
+ "true-value": "^2.0.5",
15
+ "false-value": "^2.0.6",
16
+ "@10xly/strict-equals": "^1.0.0"
25
17
  }
26
18
  }
@@ -2,7 +2,7 @@ const isTrue = require("@is-(unknown)/is-true")
2
2
  const isFalse = require("@is-(unknown)/is-false")
3
3
  const arrayFilter = require("array-filter")
4
4
  const trueValue = require("true-value")
5
- const possibilities = require("./arrayOfAllBooleans")
5
+ const possibilities = require("../private/arrayOfAllBooleans")
6
6
 
7
7
  function not(value) {
8
8
  const result = arrayFilter(possibilities, (maybe) => {
File without changes