CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js47 linesDownload Raw Back to pidtree
1'use strict';2 3function pify(fn, arg1, arg2) {4  return new Promise(function(resolve, reject) {5    fn(arg1, arg2, function(err, data) {6      if (err) return reject(err);7      resolve(data);8    });9  });10}11 12// The method startsWith is not defined on string objects in node 0.1013// eslint-disable-next-line no-extend-native14String.prototype.startsWith = function(suffix) {15  return this.substring(0, suffix.length) === suffix;16};17 18var pidtree = require('./lib/pidtree');19 20/**21 * Get the list of children pids of the given pid.22 * @public23 * @param  {Number|String} pid A PID. If -1 will return all the pids.24 * @param  {Object} [options] Optional options object.25 * @param  {Boolean} [options.root=false] Include the provided PID in the list.26 * @param  {Boolean} [options.advanced=false] Returns a list of objects in the27 * format {pid: X, ppid: Y}.28 * @param  {Function} [callback=undefined] Called when the list is ready. If not29 * provided a promise is returned instead.30 * @returns  {Promise.<Object[]>} Only when the callback is not provided.31 */32function list(pid, options, callback) {33  if (typeof options === 'function') {34    callback = options;35    options = undefined;36  }37 38  if (typeof callback === 'function') {39    pidtree(pid, options, callback);40    return;41  }42 43  return pify(pidtree, pid, options);44}45 46module.exports = list;47 
basant307/AI_Governance_Project · CoolFace