@wizhut_tech/wizjs 0.2.0 → 0.2.1
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/package.json +2 -2
- package/readme.md +21 -17
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
},
|
|
6
6
|
"description": "Simple but useful hacks for everyday javascript programming",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"tap": "21.
|
|
8
|
+
"tap": "21.8.0"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=14.13.0"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"test": "tap run"
|
|
39
39
|
},
|
|
40
|
-
"version": "0.2.
|
|
40
|
+
"version": "0.2.1"
|
|
41
41
|
}
|
package/readme.md
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
A Javascript library that ports selected Python idioms and stdlib helpers (`itertools`, `functools`, `collections`) to everyday JS. A few selected dependencies only. No, this library will not become another `lodash` :).
|
|
4
4
|
|
|
5
|
-
Use by importing:
|
|
5
|
+
Use by importing the area you need:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```js
|
|
8
|
+
const { isNil } = require('@wizhut_tech/wizjs/lang/checks');
|
|
9
|
+
const { Counter } = require('@wizhut_tech/wizjs/lang/collections');
|
|
10
|
+
const { clamp } = require('@wizhut_tech/wizjs/math/numbers');
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Every area listed below is reachable as `@wizhut_tech/wizjs/<namespace>/<area>`.
|
|
14
|
+
The subpath form needs Node 14.13 or newer.
|
|
15
|
+
|
|
16
|
+
The whole library is also available from a single root import --
|
|
17
|
+
`const wizjs = require('@wizhut_tech/wizjs')` -- which returns an object
|
|
18
|
+
structured like:
|
|
8
19
|
|
|
9
20
|
```
|
|
10
21
|
{
|
|
@@ -23,28 +34,21 @@ Use by importing:
|
|
|
23
34
|
},
|
|
24
35
|
math: {
|
|
25
36
|
numbers: [functions]
|
|
37
|
+
},
|
|
38
|
+
exceptions: {
|
|
39
|
+
BadlyInitializedError
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
```
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
Individual functions can be destructured out of that as well, though it nests
|
|
45
|
+
three levels deep:
|
|
31
46
|
|
|
32
47
|
`const { lang: { checks : { isNil } } } = require('@wizhut_tech/wizjs');`
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
const { isNil } = require('@wizhut_tech/wizjs/lang/checks');
|
|
39
|
-
const { Counter } = require('@wizhut_tech/wizjs/lang/collections');
|
|
40
|
-
const { clamp } = require('@wizhut_tech/wizjs/math/numbers');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Every area listed below is reachable as `@wizhut_tech/wizjs/<namespace>/<area>`,
|
|
44
|
-
and resolves to the very same object the root import exposes, so the two styles
|
|
45
|
-
mix freely. The subpath form needs Node 14.13 or newer. Library internals (under
|
|
46
|
-
`src/internal/`) are deliberately not reachable this way — `BadlyInitializedError`
|
|
47
|
-
is re-exported from the root import instead.
|
|
49
|
+
Both forms hand back the same objects, so they mix freely. Library internals
|
|
50
|
+
(under `src/internal/`) are deliberately not reachable as subpaths --
|
|
51
|
+
`BadlyInitializedError` is re-exported from the root import instead.
|
|
48
52
|
|
|
49
53
|
### I/O
|
|
50
54
|
|