> For the complete documentation index, see [llms.txt](https://docs.medable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.medable.com/cortex-api/scripting/modules-1/util.paths-module.md).

# Util.paths Module

\
&#x20;Import

```
import { paths } from 'util';
```

### Methods

[to(object, path, value, returnSourceObject)](https://docs.medable.com/reference#section-to-object-path-value-returnsourceobject-)

### to(object, path, value, returnSourceObject)

Search `object` for a path using a dot syntax and returns a value. If the `value` argument is present, the function writes the path to the object and returns the inner most object match, creating objects when none are present.

**Arguments**

* `object` (Object) The object to search or update.
* `path` (String) The path to search or update. Sub-properties can be found/updated using a `.` as a separator.
* `value` (\*) If present, writes to the innermost path. If any of the properties are missing from the path, they are created as plain javascript objects.
* `returnSourceObject` (Boolean) If true, returns `object` instead of the innermost property.

**Returns**

*

JavaScript

```
import { paths } from 'util';

const object = {
  foo: [
    0,
    1,
    {two: 'two'}
  ]
};

paths.to(object, 'not.a.property'); // undefined
paths.to(object, 'foo.2.two'); // 'two'
paths.to({}, 'a.b.c', 'd'); // {c: 'd'}
paths.to({}, 'a.b.c', 'd', true); // {a: {b: {c: 'd'}}}
```
