multimix v6.0.0
MultiMix
Table of Contents generated with DocToc

MultiMix
Objects with auto-generated property chains
class
Hedgepurpose: enable turning property access to function calls
- propoerties may be predefined
- or auto-generated, either
- as plain objects
- or by calling a custom factory function
example:
handler = ( hedges, a, b, c ) -> log hedges, [ a, b, c, ] return null h = new Hedge { handler, } h.foo # [ 'foo', ]
since hubs and properties are proxies, can do things on property access, no call needed, so both
d.fooandd.foo 42can potentially do things
cfg:cfg.handler: mandatory property; function to be called on prop access, call, or bothd = new Multimix { handler, }returns the handler wrapped into a proxy- the
Multimixinstance is accessible asd[Multimix.symbol].Multimix.symbolis a private symbol and thus guaranteed not to overwrite or shadow an existing property - existing properties of
handlerwill be returned - non-existant properties of
handlerwill be auto-generated on first access; these will be functions that, when called with any number of argumentsf P..., will in turn callhandler props, P... handlerwill be called in the context ofhubwhere given; otherwise, its context will be theMultimixinstance.
hub: optional reference / base object (re 'hub': as if props were spokes)cfg.create:true(default): missing props will be auto-generated as functions that callhandlerin the context ofcfg.hubwhere given (or else theMultimixinstance)false: no missing props will be generated- a function: to be called as
create key, targetwhen a new property is first accessed; this function may or may not create a new property as seen fit. The MultiMix proxy will, at any rate, returntarget[ key ]which may or may not beundefined.
cfg.strict: (defaultfalse) if set totrue, trying to access an unset property will cause an error. This setting is only valid when used in conjunction withcreate: false.cfg.oneshot: (defaultfalse) if set totrue, trying to re-assign any value to an existing property will cause an errorcfg.deletion: (defaulttrue) if set tofalse, trying to delete any property will cause an errorcfg.hide: (defaulttrue) if set totrue, will make auto-generated properties non-enumerable so they don't show up in console output
To Do
- – documentation
Is Done
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
9 years ago
9 years ago
9 years ago
9 years ago