lolite.compact 1.1.7 → 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,14 +1,70 @@
1
- # lolite.compact
2
-
3
- ### compact(array)
1
+ ## compact(array)
4
2
  Cleanses an array of all falsy values. Returns undefined for non-arrays.
5
3
 
6
4
  ```javascript
7
- const compact = require("lolite.compact")
5
+ const lolite = require("lolite.compact")
8
6
  const result = compact([1, 0, false, "hello"])
9
7
  // result: [1, "hello"]
10
8
  const undef = compact("Not an array")
11
9
  // undef: undefined
12
- ```
13
-
14
- This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
10
+ ```
11
+
12
+ ### flatten(array)
13
+ Flattens arrays. Returns undefined for non-arrays.
14
+
15
+ ```javascript
16
+ const lolite = require("lolite.compact")
17
+ const flat = lolite.flatten([1, [2, [3]]])
18
+ // flat: [1, 2, 3]
19
+ const undef = lolite.flatten("Not an array")
20
+ // undef: undefined
21
+ ```
22
+
23
+ ### first(array)
24
+ alias: head(array)
25
+
26
+ Get the first element of an array. Returns undefined for non-arrays.
27
+ ```javascript
28
+ const lolite = require("lolite.compact")
29
+ const testArray = [0, 1, 2]
30
+ console.log(lolite.first(testArray)) // 0
31
+ console.log(lolite.head(testArray)) // 0
32
+ ```
33
+
34
+ ### last(array)
35
+
36
+ Get the last element of an array. Returns undefined for non-arrays.
37
+ ```javascript
38
+ const lolite = require("lolite.compact")
39
+ const testArray = [0, 1, 2]
40
+ console.log(lolite.last(testArray)) // 2
41
+ ```
42
+
43
+ ### initial(array)
44
+ Returns all but the last element of an array. Returns undefined for non-arrays.
45
+ ```js
46
+ const lolite = require("lolite.compact")
47
+ const result = lolite.initial([1, 2, 3])
48
+ // result: [1, 2]
49
+
50
+ const single = lolite.initial([1])
51
+ // result: []
52
+
53
+ const undef = lolite.initial("Not an array")
54
+ // result: undefined
55
+ ```
56
+
57
+ ### tail(array)
58
+ Returns all but the first element of an array. Returns undefined for non-arrays.
59
+ ```js
60
+ const lolite = require("lolite.compact")
61
+ const result = lolite.tail([1, 2, 3])
62
+ // result: [2, 3]
63
+
64
+ const single = lolite.tail([1])
65
+ // result: []
66
+
67
+ const undef = lolite.tail(null)
68
+ // result: undefined
69
+ ```
70
+
package/package.json CHANGED
@@ -1,32 +1,22 @@
1
1
  {
2
2
  "name": "lolite.compact",
3
- "version": "1.1.7",
4
- "description": "Enterprise-grade compact 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/compact.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
- "@is-(unknown)/is-false": "^1.5.0",
7
+ "lodash.toarray": "^4.4.0",
8
+ "array.prototype.filter": "^1.0.4",
9
+ "twice-call-wrapper": "^1.2.0",
10
+ "yanoop": "^1.0.0",
11
+ "@identity-js/identity": "^1.2.1",
12
+ "literally": "^1.0.0",
20
13
  "@is-(unknown)/is-true": "^1.5.0",
14
+ "@is-(unknown)/is-false": "^1.5.0",
21
15
  "array-filter": "^1.0.0",
16
+ "true-value": "^2.0.5",
17
+ "false-value": "^2.0.6",
22
18
  "@10xly/strict-equals": "^1.0.0",
23
- "@identity-js/identity": "^1.2.1",
24
- "literally": "^1.0.0",
25
- "twice-call-wrapper": "^1.2.0",
26
- "yanoop": "^1.0.0",
27
19
  "@is-(unknown)/is-array": "^1.0.0",
28
- "array.prototype.filter": "^1.0.4",
29
- "lodash.toarray": "^4.4.0",
30
20
  "undefined-is-a-function": "^0.1.0"
31
21
  }
32
22
  }
@@ -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
File without changes
File without changes