code: async function(directory, params) {
    const {
      source,
      options = {},
      cacheIdentifier,
      cacheDirectory,
      cacheCompression,
    } = params;
  
    const file = path.join(directory, filename(source, cacheIdentifier, options));
  
    try {
      // No errors mean that the file was previously cached
      // we just need to return it
      return await read(file, cacheCompression);
    } catch (err) {}
  
    const fallback =
      typeof cacheDirectory !== "string" && directory !== os.tmpdir();
  
    // Make sure the directory exists.
    try {
      await mkdirp(directory);
    } catch (err) {
      if (fallback) {
        return handleCache(os.tmpdir(), params);
      }
  
      throw err;
    }
  
    // Otherwise just transform the file
    // return it to the user asap and write it in cache
    const result = await transform(source, options);
  
    try {
      await write(file, cacheCompression, result);
    } catch (err) {
      if (fallback) {
        // Fallback to tmpdir if node_modules folder not writable
        return handleCache(os.tmpdir(), params);
      }
  
      throw err;
    }
  
    return result;
  }
docs: Handle the cache
  
  @params {String} directory
  @params {Object} params