Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Creating new object without class and 'new' keyword.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages