Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.mjs
More file actions
Latest commit
28 lines (26 loc) · 751 Bytes
/
Copy pathexample.mjs
File metadata and controls
28 lines (26 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import{ERR_INVALID_ARG_TYPE,isNodeError}from'@flex-development/errnode'
/**
* Ensure `value` is a string.
*
* @see {@linkcode ErrInvalidArgType}
*
* @param {unknown} value
* Value supplied by user
* @param {string} name
* Name of invalid argument or property
* @return {value is string}
* `true` if `value` is a string
* @throws {import('@flex-development/errnode').ErrInvalidArgType}
* If `value` is not a string
*/
functionvalidateString(value,name){
if(typeofvalue==='string')returntrue
thrownewERR_INVALID_ARG_TYPE(name,'string',value)
}
try{
validateString(null,'path')
}catch(e){
console.log('isNodeError:',isNodeError(e))
console.log('TypeError:',einstanceofTypeError,'\n')
throwe
}