Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:01:46+00:00 2026-05-24T02:01:46+00:00

I want to create an object that can parse a certain filetype. I’ve looked

  • 0

I want to create an object that can parse a certain filetype. I’ve looked at some of the files in the File API and I want my object to work about the same. So basically, what I want is this:

A function, called CustomFileParser. I want to be able to use it as the following:

var customFileParser = new CustomFileParser();
customFileParser.parsed = paresed;
customFileParser.progress = progress;

customFileParser.parse(file);

function parsed(event){
 //The file is loaded, you can do stuff with it here.
}

function progess(event){
 //The file load has progressed, you can do stuff with it here.
}

So I was thinking on how to define this object, but I’m not sure how to define these events and how I should do this.

function customFileParser(){
 this.parse = function(){
  //Do stuff here and trigger event when it's done... 
 }
}

However, I’m not sure how to define these events, and how I can do this. Anyone can give me a hand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:01:47+00:00Added an answer on May 24, 2026 at 2:01 am

    Javscript is prototype-based OOP language, not class-based like most other popular languages. Therefore, the OOP constructs are a bit different from what you might be used to. You should ignore most websites that try to implement class-based inheritance in JS, since that’s not how the language is meant to be used.

    The reason people are doing it because they are used to the class-based system and are usually not even aware that are alternatives to that, so instead of trying to learn the correct way, they try to implement the way that they are more familiar with, which usually results in loads and loads of hacks or external libraries that are essentially unnecessary.

    Just use the prototype.

    function CustomFileParser(onParsed, onProgress) {
        // constructor
        this.onParsed = onParsed;
        this.onProgress = onProgress;
    };
    
    CustomFileParser.prototype.parse = function(file) {
        // parse the file here
        var event = { foo: 'bar' };
        this.onProgress(event);
        // finish parsing
        this.onParsed(event);
    };
    

    And you can use it like so

    function parsed(event) {
        alert(event);
    }
    
    function progress(event) {
        alert(event);
    }
    
    var customFileParser = new CustomFileParser(parsed, progress);
    
    var file = ''; // pseudo-file
    customFileParser.parse(file);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Map object that can lose value only if we
My User object that I want to create and store in the datastore has
I want to create an object in python that is a collection of around
I want to create an object with a non-enumerable property(a property that does not
In Delphi, I want to be able to create an private object that's associated
I want to create a background thread that's owned by an object. When that
I'm currently developing an application that needs to parse some (a big file of)
I want to create a custom set that will automatically convert objects into a
I want to create object on the client side of aspx page. And i
I want to create light object data-package to pass between client and server applications.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.