Socket
Socket
Sign inDemoInstall

oloo-shim

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oloo-shim

This is a really simple shim for working with OLOO (Objects Linked to Other Objects) a Kyle Simpson's JS pattern for handling objects relations by delagating behaviors between objects. I've just created this shim because i think it helps dealing with some


Version published
Maintainers
1
Created
Source

oloo-shim

This is a really simple shim for working with OLOO (Objects Linked to Other Objects) a Kyle Simpson's JS pattern for handling objects relations by delegating behaviors between objects.
I've created this shim because i think it helps dealing with some problems about the JS language it self, not the pattern. This package provides access to the parent object, something that is not natively available and this way you can extend methods by accessing the parent method, at the same it also grants more readability of the code.

For a complete explanation of OLOO pattern you should really go here.
This is a very usefull pattern and i really advise you to take a look. Also try this shim, is this way i like to work with OLOO and maybe you will too.

Install

npm install oloo-shim --save

Complete example

require("oloo-shim").install();

var o1 = {
    firstname: null,
    init: function(firstname){
        this.setFirstname(firstname);
    },
    setFirstname: function(name){
        this.firstname = name;
    }
};

var o2 = Object.oloo( o1, {
    lastname: null,
    init: function(firstname, lastname){
        this.parent.init(firstname); // access parent function with same name
        this.lastname = lastname;
    },
    setLastname: function(name){
        this.lastname = name;
    }
});

var o3 = Object.oloo(o2, {
    getFullname: function(){
        return this.firstname+" "+this.lastname;
    }
});

var o4 = Object.oloo(o3);
o4.init("Daniel", "Meneses");
console.log( o4.getFullname() );

Keywords

FAQs

Package last updated on 28 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc