Giter VIP home page Giter VIP logo

Comments (5)

NghiaTranUIT avatar NghiaTranUIT commented on June 9, 2024 1

Thanks for your input. I guess I can support a simple version of isFileExist() and readFile() for you πŸ‘

from proxyman.

andforce avatar andforce commented on June 9, 2024

Thanks for your input. I guess I can support a simple version of isFileExist() and readFile() for you πŸ‘

I'm very much looking forward to your new version. I wonder if it will support using JSON parsing to read the contents of files. This way, I can compare file contents more conveniently and specifically.

async function onResponse(context, url, request, response) {

  const filename = request.queries.page;

  const path_to_local_file = "~/Desktop/" + filename + ".json"
  if ("path_to_local_file not exists or path_to_local_file content is empty") {
     writeToFile(response.body, path_to_local_file);
  } else {
       var local_file_json = JSON.parse(path_to_local_file's content)
       if (local_file_json.some_value != response.body.some_value) {
           // to update local file
           writeToFile(response.body, path_to_local_file);
       } else {
           // no nothing or just print some log
       }
  }

  return response;
}

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 9, 2024

@andforce you can try this Beta build: https://download.proxyman.io/beta/Proxyman_5.3.0_New_file_common_func.dmg

async function onResponse(context, url, request, response) {

  const textFilePath = "~/Desktop/myfile.json";
  
  // check exist
  if (isFileExists(filePath)) {
  
    // read from file
    const text = readFromFile(textFilePath);
    
    // pares string to JSON Object
    const obj = JSON.parse(text);
  }
  
  // Read binary file
  const binaryFilePath = "~/Desktop/screenshot.png";
  const binaryFile = readFromFile(binaryFilePath); // Uint8Array
  
  // Done
  return response;
}

from proxyman.

andforce avatar andforce commented on June 9, 2024

@NghiaTranUIT Thank you very much; I am amazed by your efficiency. I tried the new beta version you provided, it works fine~

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 9, 2024

Awesome, glad it helps you πŸ‘

from proxyman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.