@zgeoff/std 0.1.0 → 0.2.0
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 +14 -2
- package/dist/index.d.ts +1 -0
- package/dist/is-record.d.ts +1 -0
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/is-record.ts +3 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @zgeoff/std
|
|
2
2
|
|
|
3
3
|
Small, dependency-free TypeScript helpers that more than one zgeoff repo needs. Each helper is one
|
|
4
|
-
file with its test beside it, exported from the package root, and named by the shared
|
|
5
|
-
rules.
|
|
4
|
+
file with its test beside it, exported from the package root, and named by the shared
|
|
5
|
+
function-naming rules.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -36,3 +36,15 @@ const options: Options = toExactOptional({ label, retries: 3 });
|
|
|
36
36
|
Own enumerable keys are copied, symbols included, as an object spread would. `null` values stay,
|
|
37
37
|
falsy values such as `0` and `''` stay, and the input object is left untouched. A union input maps
|
|
38
38
|
member by member, so each member keeps its own keys.
|
|
39
|
+
|
|
40
|
+
### `isRecord`
|
|
41
|
+
|
|
42
|
+
Tells whether a value is a plain keyed object, and narrows it to `Record<string, unknown>`, so code
|
|
43
|
+
that reads parsed JSON can index it. An array or `null` is not a record.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { isRecord } from '@zgeoff/std';
|
|
47
|
+
|
|
48
|
+
const parsed: unknown = JSON.parse(text);
|
|
49
|
+
const name = isRecord(parsed) ? parsed['name'] : undefined;
|
|
50
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgeoff/std",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Small, dependency-free TypeScript helpers shared across the zgeoff repos",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"typecheck": "tsc"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/bun": "1.
|
|
33
|
-
"typescript": "7.0.
|
|
32
|
+
"@types/bun": "1.4.2",
|
|
33
|
+
"typescript": "7.0.2"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"bun": ">=1.3"
|
package/src/index.ts
CHANGED
package/src/is-record.ts
ADDED