File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff 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 */
6061export 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}
You can’t perform that action at this time.
0 commit comments