unpack
Reasoning
to receive inline or dict based args - because inline is nice but unwieldy, as such - also allow dicts.
This allows for more complex options; later. Also then we can process inline args with a dict. And rearrange them later.
Meta Data
| filepath_exists | True |
| path | unpack |
| filepath | unpack.js |
| clean_files | () |
-
VariableDeclarationReasoning to receive inline or dict based args - because inline is nice but unwieldy, as such - also allow dicts. This allows for more complex options; later. Also then we can process inline args with a dict. And rearrange them later.read the args object into a dictionary (if required) use the `defaults` as as the defaults return an object. If args match an object, return with updates. one arg may be just a context. or an object of properties two args may be context and object. or context and prop let data = unpack(arguments, { otherPoint: undefined , color: undefined , width: undefined }) Note, proxies are slower than objects https://www.measurethat.net/Benchmarks/Show/6274/4/access-to-proxy-vs-object
-
VariableDeclarationread the args object into a dictionary (if required) use the `defaults` as as the defaults return an object. If args match an object, return with updates. one arg may be just a context. or an object of properties two args may be context and object. or context and prop let data = unpack(arguments, { otherPoint: undefined , color: undefined , width: undefined }) Note, proxies are slower than objects https://www.measurethat.net/Benchmarks/Show/6274/4/access-to-proxy-vs-object
-
VariableDeclaration
-
VariableDeclaration
-
VariableDeclaration
-
VariableDeclaration
-
VariableDeclaration
-
VariableDeclarationUnpack with defaults from the args. But the args is still applied. return defaults (otherPoint, color, width) d = runUnpackArgsDefault(stage.ctx); apply/override a config d = runUnpackArgsDefault(stage.ctx, { color: 'green' }); extend defaults d = runUnpackArgsDefault(stage.ctx, { up: true }); Be careful of the above (for this args defaults), as `otherPoint` is recast as the given object, therefore the `{ otherPoint }` default return, will return the config object, not the first default property: # bad: const runUnpackArgsDefault = function(ctx, otherPoint={}, color='red', width=1) { let data = unpack(arguments, { otherPoint , color , width }) } # good: const runUnpackArgsDefault = function(ctx, otherPoint={}, color='red', width=1) { let data = unpack(arguments, { otherPoint: {} // altDefault , color , width }) }