Skip to content

Commit 92edacc

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 7a3079f commit 92edacc

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/types/nodePackageJson.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,35 @@ export interface NodePackageJson {
5252
}
5353

5454
/**
55-
*
5655
*
5756
* Not implemented, yet.
58-
* TODO: write type assertion -- pullrequests welcome
57+
* TODO: write type guard -- pull-requests welcome
58+
*
59+
* @alpha
5960
*/
6061
export function isNodePackageJson (value: any): value is NodePackageJson {
61-
throw new Error("Not implemented")
62+
throw new Error('Not implemented')
63+
/* possible implementation:
64+
try { assertNodePackageJson(value) }
65+
catch{ return false }
66+
return true
67+
*/
68+
}
69+
70+
/**
71+
*
72+
* Not implemented, yet.
73+
* TODO: write type assertion -- pull-requests welcome
74+
*
75+
* @throws {@link Error} on error with qualitative error message
76+
*
77+
* @alpha
78+
*/
79+
export function assertNodePackageJson (value: any): asserts value is NodePackageJson {
80+
throw new Error('Not implemented')
81+
/* possible implementation:
82+
if ( value === null || value === undefined ) { throw new Error('value not an object') }
83+
if ( !(typeof value.name in ['undefined', 'string']) ) { throw new Error('unexpected name') }
84+
etc...
85+
*/
6286
}

0 commit comments

Comments
 (0)