Merge pull request #795 from raunaqrox/master

Array.isArray instead of instanceof for consistent checking
This commit is contained in:
Michael Lumish 2019-03-22 12:03:28 -07:00 committed by GitHub
commit a3b4c2f8a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,7 +269,7 @@ export function load(filename: string, options?: Options): Promise<PackageDefini
const root: Protobuf.Root = new Protobuf.Root();
options = options || {};
if (!!options.includeDirs) {
if (!(options.includeDirs instanceof Array)) {
if (!(Array.isArray(options.includeDirs))) {
return Promise.reject(new Error('The includeDirs option must be an array'));
}
addIncludePathResolver(root, options.includeDirs as string[]);
@ -284,8 +284,8 @@ export function loadSync(filename: string, options?: Options): PackageDefinition
const root: Protobuf.Root = new Protobuf.Root();
options = options || {};
if (!!options.includeDirs) {
if (!(options.includeDirs instanceof Array)) {
throw new Error('The include option must be an array');
if (!(Array.isArray(options.includeDirs))) {
throw new Error('The includeDirs option must be an array');
}
addIncludePathResolver(root, options.includeDirs as string[]);
}