UNPKG

is-child-process

Version:

Checks whether a value is child process result, which in case is more specific Node.js EventEmitter. Browserify-ready.

25 lines (20 loc) 602 B
/*! * is-child-process <https://github.com/tunnckoCore/is-child-process> * * Copyright (c) 2015-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk) * Released under the MIT license. */ 'use strict' var isArray = require('isarray') var isEmitter = require('is-node-emitter') module.exports = function isChildProcess (val) { return isEmitter(val) && hasOwn(val, 'stdin') && hasOwn(val, 'stdout') && hasOwn(val, 'stdio') && isArray(val.stdio) && val.stdio.length > 0 } function hasOwn (obj, val) { return Object.prototype.hasOwnProperty.call(obj, val) }