How do I rewrite a function that calls with .call() method to simpler function

Hi Guys,
I’m working on a node.js project. The code below I take from someone’s library which I don’t understand its meaning.

[code]function Receiver () {}

Receiver.prototype.passData = function (data) {, data);

var extract = {
start: function(data) {
var self = this;
var firstLength = data[1] & 0x7f;, firstLength);
getData: function(length) {
var self = this;
self.Header(4, function(data) {
var mask = data;
self.Data(length, function(data) {, mask, data);
finish: function(mask, data) {
// data extracted
I’m trying to extract data passed from another sever. The code above works as expected.
My problem is that I do not understand how that works. I want to rewrite it to simpler version of mine so I can understand the process and able to split data from a header by myself.

I want to rewrite it to something like this:

[code]function extactData (data) {
var firstLength = data[1] & 0x7f;

function getData(length) {
// split header and data
finish(mask, data);
Is it possible and how?
I don’t want it works perfectly. My purpose for this question is I just want to know how to do it and I would dig deep into this.

The reason I want to do this is the library is huge and it doesn’t serve my purpose well and that’s is the only part of the entire library I really needed. The rest is useless.

Thank you,

One reason for object oritented programming is that you can use objects (such as Receiver in this case) without needing to know how it works. You just need to know how to call it.

That looks to be as simple an object as any so anything you do to it will just make it more complicated.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.