link-objects

0.0.2 • Public • Published

link-objects

As Javascript developer you should now that 'class' keyword is just code sugar for linking objects together. Prototypal inheritance is powerful and it's pity to waste it potential. Instead of reusing OO patterns, better use OLOO!

Pure prototypal inheritance

No 'new', no 'class', link your objects freely.

api

- link

link(sourceObject)(extendingValues);
const test = {
    value1: 'test',
    value2: 'test2',
    tester1() { return this.value1 },
    tester2() { return this.value2 },
}
const linked = link(test)({
    beyond: true,
    value2: 'new value',
})
linked.beyond // true
linked.tester1() // test
linked.tester2() // new value

- linker

const test = linker(sourceObject);
test.extend(extendingValues);
const test = linker({
    value1: 'test',
    value2: 'test2',
    tester1() { return this.value1 },
    tester2() { return this.value2 },
});
const linked = test.extend({
    beyond: true,
    value2: 'new value',
})
linked.beyond // true
linked.tester1() // test
linked.tester2() // new value

Readme

Keywords

Package Sidebar

Install

npm i link-objects

Weekly Downloads

1

Version

0.0.2

License

ISC

Unpacked Size

4.41 kB

Total Files

11

Last publish

Collaborators

  • mishaszu