index.js
function getHeapSpaceStatistics(unitInfo) {
  const arr = v8.getHeapSpaceStatistics();
  const result = {};
  arr.forEach((item) => {
    const data = {};
    const keys = Object.keys(item);
    keys.forEach((key) => {
      if (key === 'space_name') {
        return;
      }
      // replace the space_ key prefix
      data[key.replace('space_', '')] = format(item[key], unitInfo);
    });
    result[item.space_name] = data;
  });
  return result;
}
function getHeapSpaceStatistics(unitInfo) {
  const arr = v8.getHeapSpaceStatistics();
  const result = {};
  arr.forEach((item) => {
    const data = {};
    const keys = Object.keys(item);
    keys.forEach((key) => {
      if (key === 'space_name') {
        return;
      }
      // replace the space_ key prefix
      data[key.replace('space_', '')] = format(item[key], unitInfo);
    });
    result[item.space_name] = data;
  });
  return result;
}
function getHeapSpaceStatistics ( unitInfo ) { const arr = v8 . getHeapSpaceStatistics ( ) ; const result = { } ; arr . forEach ( ( item ) => { const data = { } ; const keys = Object . keys ( item ) ; keys . forEach ( ( key ) => { if ( key === 'space_name' ) { return ; } // replace the space_ key prefix data [ key . replace ( 'space_' , '' ) ] = format ( item [ key ] , unitInfo ) ; } ) ; result [ item . space_name ] = data ; } ) ; return result ; }
Get the heap space statistics
@param {Object} unitInfo The unit format setting
@returns {Object} The heap space statistics
Get the heap space statistics