> For the complete documentation index, see [llms.txt](https://krypt0nn.gitbook.io/empathize/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krypt0nn.gitbook.io/empathize/api/async-api/promisify.md).

# promisify

## PromiseOptions

| Name               | Type                          | Description                                |
| ------------------ | ----------------------------- | ------------------------------------------ |
| callbacks          | (() => void)\[] \| Promise\[] | List of callbacks                          |
| callAtOnce = false | boolean                       | *Picture below*                            |
| interval = 100     | number                        | \[callAtOnce: true] updates interval in ms |

![App without promisify, with promisify() and with promisify({ callAtOnce: true })](/files/ovs5qbl6IqXTrFWcPLga)

## promisify function

### promise(options)

```typescript
import { fs, promisify } from '@empathize/framework';

// Call one function async
promisify(async () => {
    const files = await fs.files('my_folder');
    
    console.log(files);
});

// Wait for promise result
promisify(new Promise((resolve) => {
    setTimeout(() => {
        resolve('Hello, World!');
    }, 3000);
})).then(console.log);

// Call several functions async
promisify({
    callbacks: [
        () => console.log(1),
        () => console.log(2),
        () => console.log(3)
    ]
});

// Call several functions async together
promisify({
    callbacks: [
        () => console.log(1),
        () => console.log(2),
        () => console.log(3)
    ],
    callAtOnce: true
});

// Sum several callbacks results
promisify({
    callbacks: [
        () => 1,
        () => 2,
        () => 3
    ]
}).then((results) => {
    // 1 + 2 + 3 = 6
    console.log(results[0] + results[1] + results[2]);
});
```
