Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Prototype.js style context wrapping it in another function in NodeJS.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 README.md
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Octocat-spinner-32 test.js
README.md

Wrap

Wrap is Prototype.js style context wrapping it in another function in NodeJS.

  • Tiny!
  • Fast!
  • Easy!
  • Useful!

Installing

GIT

$ git clone git://github.com/firejune/wrap.git

NPM

$ npm install wrap

Code

var wrap = require('wrap');

function MyClass() {
  this.value = "Hello World!";
  this.doSomething();
}

MyClass.prototype.doSomething = function() {
  //self = this;
  setTimeout(function() {
    //console.log(self.value);
    console.log(this.value);
  }.wrap(this), 100);
};

new MyClass();
//=> "Hello World!"

Have fun!

License

MIT <3

Something went wrong with that request. Please try again.