.join item_delimiter
- fromKVPairs : (qs, item_delimiter='&', kv_delimiter='=') ->
+ fromKVPairs: (qs, item_delimiter='&', kv_delimiter='=') ->
_.reduce do
qs.split item_delimiter
(acc, pair) ->
acc[ decodeURIComponent k ] = decodeURIComponent v if k
acc
{}
+
/**
* Searches a heirarchical object for a given subkey specified in dotted-property syntax.
* @param {Array|String} chain The property-chain to lookup.
* @retruns {null|Object} If found, the object is of the form `{ key: Qualified key name, obj: Parent object of key, val: Value at obj[key] }`. Otherwise `null`.
*/
- getNestedMeta = (obj, chain) ->
+ getNestedMeta : (obj, chain) ->
chain = chain.split('.') if typeof chain is 'string'
return _.reduce do
chain
* @param {Any} def Value to return if lookup fails.
* @retruns {null|Object} If found, returns the value, and otherwise `default`.
*/
- getNested = (obj, chain, def=null) ->
+ getNested : (obj, chain, def=null) ->
meta = _obj.getNestedMeta obj, chain
if meta
meta.val
* @param {Any} value The value to set.
* @retruns {null|Object} If found, returns the old value, and otherwise `null`.
*/
- setNested = (obj, chain, value) ->
+ setNested : (obj, chain, value) ->
meta = _obj.getNestedMeta obj, chain
if meta
meta.obj[meta.key] = value