neft
Version:
Universal Platform
58 lines (42 loc) • 2.54 kB
Markdown
> [Wiki](Home) ▸ [[API Reference|API-Reference]] ▸ [[Utils|Utils-API]] ▸ **Properties extraction**
# Properties extraction
> [`Source`](/Neft-io/neft/blob/00d48f19a9b22932ace5d660101e9fa2b6991fb9/src/utils/namespace.litcoffee)
## Table of contents
* [Properties extraction](#properties-extraction)
* [get](#get)
* [**Class** utils.get.OptionsArray](#class-utilsgetoptionsarray)
* [isStringArray](#isstringarray)
##get
<dl><dt>Syntax</dt><dd><code>*Any* get(*Object* object, *String* path, [*OptionsArray* target])</code></dd><dt>Parameters</dt><dd><ul><li>object — <a href="/Neft-io/neft/wiki/Utils-API#isobject">Object</a></li><li>path — <i>String</i></li><li>target — <i>OptionsArray</i> — <i>optional</i></li></ul></dd><dt>Returns</dt><dd><i>Any</i></dd></dl>
Extracts property, deep property or an array of possible properties from the given object.
```javascript
var obj = {prop: 1};
console.log(utils.get(obj, 'prop'));
// 1
var obj = {prop: {deep: 1}};
console.log(utils.get(obj, 'prop.deep'));
// 1
var obj = {prop: [{deep: 1}, {deep: 2}]};
console.log(utils.get(obj, 'prop[].deep'));
// [1, 2]
// 'utils.get.OptionsArray' instance ...
var obj = {prop: [{deep: 1}, {deep: 2}]};
console.log(utils.get(obj, 'prop[]'));
// [{deep: 1}, {deep: 2}]
// 'utils.get.OptionsArray' instance ...
var obj = {prop: [{deep: {}}, {deep: {result: 1}}]};
console.log(utils.get(obj, 'prop[].deep.result'));
// [1]
// 'utils.get.OptionsArray' instance ...
```
> [`Source`](/Neft-io/neft/blob/00d48f19a9b22932ace5d660101e9fa2b6991fb9/src/utils/namespace.litcoffee#any-getobject-object-string-path-optionsarray-target)
##**Class** utils.get.OptionsArray
<dl><dt>Syntax</dt><dd><code>**Class** utils.get.OptionsArray()</code></dd></dl>
Special version of an Array, returned if the result of the utils.get()
function is a list of the possible values.
> [`Source`](/Neft-io/neft/blob/00d48f19a9b22932ace5d660101e9fa2b6991fb9/src/utils/namespace.litcoffee#class-utilsgetoptionsarray)
##isStringArray
<dl><dt>Syntax</dt><dd><code>*Boolean* isStringArray(*String* value)</code></dd><dt>Parameters</dt><dd><ul><li>value — <i>String</i></li></ul></dd><dt>Returns</dt><dd><i>Boolean</i></dd></dl>
Checks whether the given string references into an array according
to the notation in the utils.get() function.
> [`Source`](/Neft-io/neft/blob/00d48f19a9b22932ace5d660101e9fa2b6991fb9/src/utils/namespace.litcoffee#boolean-isstringarraystring-value)