___ _ _ _ _
/ _ \| |__ (_) ___ ___| |_ (_)___
| | | | '_ \| |/ _ \/ __| __| | / __|
| |_| | |_) | | __/ (__| |_ _ | \__ \
\___/|_.__// |\___|\___|\__(_)/ |___/
|__/ |__/
This library provides functionality to support the composition of objects in a javascript-idiosyncratic style, giving us the conveniences that a class system provides while not trying to approximate a class system.
Object.js encourages composition over inheritance.
- Mixins
- Override functions of an existing object
- Easily specify defaults for an options argument
- Iterate over object key-value pairs
- Slice an objects members
- Copy objects
- Wrap and delegate to another object
- Extensible:
object(obj).yourFunctionHere()
Object.js has zero dependencies.
object(obj).mixin({ ... });
object(obj).qmixin({ ... });
object(obj).defaults({ ... });
object(obj).overwrite({ ... });
object(obj).override({ ... });
object(obj).copy();
object(obj).deepCopy();
object(obj).each(function (value, key) { ... });
object(obj).map(function (value, key) { ... });
object(obj).delegateTo(otherObj, 'this', 'that', 'theOther');
object(obj).toArray()
// use plugins to have ...
object(obj).yourFunctionHere();
object
is not likely to be a javascript reserve word in the future
Works in
- Chrome 17+
- Firefox 7+
- Safari 5.13+
Has not been tested in other browsers
- Figlet was used for the ASCII art
- I haven't tested it in many browsers
- I learnt a lot about javascript by reading The Little Book on CoffeeScript
- Install node
- Install cup and read the docs
- Write some code or docs
- Make a pull request
- Live happily ever after