enclose-io/compiler

View on GitHub
lts/lib/internal/modules/package_json_reader.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

const { SafeMap } = primordials;
const { internalModuleReadJSON } = internalBinding('fs');

const cache = new SafeMap();

/**
 *
 * @param {string} path
 */
function read(path) {
  if (cache.has(path)) {
    return cache.get(path);
  }

  const [string, containsKeys] = internalModuleReadJSON(path);
  const result = { string, containsKeys };
  cache.set(path, result);
  return result;
}

module.exports = { read };