open-index/open-npm huggingface dataset:
npm package: @mbonner4th/loop-async-function
Description: Waits for the wait duration and then calls the callback.
Author: Miles Bonner
Latest version: 1.0.1

# @mbonner4th/loop-async-function
![npm (scoped)](https://img.shields.io/npm/v/@mbonner4th/loop-async-function)
[![GitHub stars](https://img.shields.io/github/stars/mbonner4th/loop-async-function)](https://github.com/mbonner4th/loop-async-function/stargazers)
![GitHub](https://img.shields.io/github/license/mbonner4th/loop-async-function)

Waits for the wait duration and then calls the callback. If a call logs is not returned the function is repeated until the loop count is exhausted. If the loop count is exhausted, any error returned by the query is thrown.

> NOTE: The wait time is per function call. A function with a wait duration of 5000 and a loop count of 6 has the potential to wait 1 minute if the maxAwait is not triggered

## Install

```
npm install @mbonner4th/loop-async-function -s
```

## Usage

This function is useful for automating getting log data when the data is not immediately available.

```js
const rp = require('request-promise-native');
const loopAsyncFunction = require('./loop-async-function');

function viewVoxologyCallLog(callId) {
  const options = {
    method: 'GET',
    uri: `https://api.voxolo.gy/v1/History/Logs/Calls/${callId}`,
    headers: {
      'X-Api-Key': SOME_API_KEY,
      'Content-Type': 'application/json',
    },
    json: true,
    resolveWithFullResponse: true,
  };
  return rp(options)
  .then((data) => data)
  .catch((error) => { throw error; });
}

loopAsyncFunction(
  () => viewVoxologyCallLog('123@456'),
  3,
  500
  )
  .then(data => {console.log(data)})
  .catch(error => {console.log(error)})

/**
 * => output
 {
  "id": "4469ea1f-abe3-4a30-97e1-45f871f61d65",
  "app_id": "ba012968-7deb-4e9a-841d-93ea35af764d",
  "subaccount_id": 0,
  "call_id": "10605776@17155753",
  "caller_no": "+15551231234",
  "api_no": "+5559871234",
  "start_time": "2019-03-19T22:46:51.462Z",
  "end_time": "2019-03-19T22:46:54.001Z",
  "type": "voice",
  "direction": "outbound",
  "hangup_end": "caller",
  "duration": 2540,
  "status": "completed",
  "detection": "unknown",
  "error": null,
  "connect_time_billed": 0.1,
  "connect_time_sec": 1,
  "origin_api": "CallFlows",
  "charge": {
      "total": 0.0015
  },
  "service": "programmable_voice"
}
 * /
```
npm package: @mborecki/cra-template
Description: create-react-app template for prototypes
Author: Marek Borecki
Latest version: 5.0.0

# @mborecki/cra-template

My take on [create-react-app](https://github.com/facebook/create-react-app) for prototypes and private projects.

Includes template for PHP backend server.

## Intalation

```
npx create-react-app my-app --template @mborecki
```

## Dependencies

### Frontend

* [Typescript](https://www.typescriptlang.org/)
* [react-router](https://reacttraining.com/react-router/web/guides/quick-start)
* [axios](https://github.com/axios/axios)
* [react-query](https://github.com/tannerlinsley/react-query)
* [styled-components](https://styled-components.com/) (for custom dynamic styles)
* [node-sass](https://github.com/sass/node-sass) (for static styles)

### PHP

* [Slim 4](https://www.slimframework.com/)
npm package: @mborecki/react-geo
Description: Package to use [Geolocation API](https://developer.mozilla.org/pl/docs/Web/API/Geolocation_API) in React application. It is using Context API to minimalize event listeners when you need use geolocation data in many conponents.
Author: Marek Borecki
Latest version: 1.0.1

# @mborecki/react-geo

Package to use [Geolocation API](https://developer.mozilla.org/pl/docs/Web/API/Geolocation_API) in React application.
It is using Context API to minimalize event listeners when you need use geolocation data in many conponents.

# Instalation

```
yarn add @mborecki/react-geo
```

# How to use

### Higher order component

```javascript

import {GeoModuleProvider} from '@mborecki/react-geo';

const App = () => {
    return <GeoModuleProvider>
        <MyComponent />
    </GeoModuleProvider>
}

```

### Consumer componenet

```javascript

import {useGeo} from '@mborecki/react-geo';

const MyComponent = () => {
    const {position, accuracy, error} = useGeo();

    return <div>{JSON.stringify(position)}</div>
}

```

# API

## GeoModuleProvider

Provider for context module uses to store data.

### Props

All properties equals properties from [PositionOptions](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions)

* **maximumAge** - [PositionOptions.enableHighAccuracy](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/enableHighAccuracy) - *default: 500*
* **enableHighAccuracy** - [PositionOptions.timeout](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/timeout) - *default: true*
* **timeout** - [PositionOptions.maximumAge](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/maximumAge) - *default: Infinity*

## useGeo()

Hook for getting geolocation data.

* **position** - object with position data - *undefined* if position is not available
* **position.lat** - position's latitude in decimal degrees.
* **position.lng** - position's longitude in decimal degrees.
* **accuracy** - accuracy of the latitude and longitude properties in meters  - *undefined* if position is not available
* **error** - object with module error
* **error.type** - *GEO_MODULE_ERROR*
* **error.originalError** - oryginal error from browser (if exists). [GeolocationPositionError](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError)


## GEO_MODULE_ERROR

* **GEO_MODULE_ERROR.UNKNOWN** - something went wrong
* **GEO_MODULE_ERROR.NO_GEOLOCATION_API** - there is no Geolocation API
* **GEO_MODULE_ERROR.PERMISSION_DENIED** - The acquisition of the geolocation information failed because the page didn't have the permission to do it.
* **GEO_MODULE_ERROR.POSITION_UNAVAILABLE** - The acquisition of the geolocation failed because at least one internal source of position returned an internal error.
* **GEO_MODULE_ERROR.TIMEOUT** - The time allowed to acquire the geolocation, defined by PositionOptions.timeout information was reached before the information was obtained.
npm package: @mborne/dl
Description: Helper based on wget to download files
Author: Mickaël Borne
Latest version: 0.4.0

# node-dl

[![Node.js CI](https://github.com/mborne/node-dl/actions/workflows/node.js.yml/badge.svg)](https://github.com/mborne/node-dl/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/mborne/node-dl/badge.svg?branch=master)](https://coveralls.io/github/mborne/node-dl?branch=master)

Download file from a given `sourceUrl` to a `targetPath` with `wget`.

## Usage

```js
const download = require('@mborne/dl');

/*
 * Note that a temp file `{targetPath}.part` is created while downloading to handle download interuptions
 */
const targetPath = await download({
    sourceUrl: 'https://github.com/mborne.keys',
    targetPath: '/tmp/mborne.keys'
});
```

## Options

| Name               | Required? | Description                         | Default |
| ------------------ | :-------: | ----------------------------------- | :-----: |
| `sourceUrl`        |    YES    | Source URL (http, https, ftp)       |   NA    |
| `targetPath`       |    YES    | Input encoding (UTF-8, LATIN1,...)  |   NA    |
| `downloadIfExists` |    NO     | Download file if targetPath exists? | `true`  |
| `unsafeSsl`        |    NO     | Disable certificate checking        | `false` |

## License

[MIT](LICENSE)
npm package: @mborne/extract
Description: Extract archives (7z, zip, bz2, gz,...) using system executables
Author: Mickaël Borne
Latest version: 0.2.0

# node-extract

[![Node.js CI](https://github.com/mborne/node-extract/actions/workflows/node.js.yml/badge.svg)](https://github.com/mborne/node-extract/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/mborne/node-extract/badge.svg?branch=master)](https://coveralls.io/github/mborne/node-extract?branch=master)

## Description

Extract archives (7z, zip, bz2, gz,...) using system executables

## Usage

```js
const extract = require('@mborne/extract');

await extract({
    archivePath: '/path/to/archive.zip'
});
```

## Options

| Name          | Required? | Description                     |     Default      |
| ------------- | :-------: | ------------------------------- | :--------------: |
| `archivePath` |    YES    | Archive path                    |        NA        |
| `targetDir`   |    NO     | Target directory for extraction | Parent directory |

## License

[MIT](LICENSE)
npm package: @mborne/ogr2pg
Description: Helper to load spatial files with multiple formats into postgis
Author: Mickaël Borne
Latest version: 0.3.2

# node-ogr2pg

## Description

Provides an helper to invoke [ogr2ogr](https://www.gdal.org/ogr2ogr.html) and [psql](https://www.postgresql.org/docs/current/static/app-psql.html) to import spatial file into [PostGIS](https://postgis.net/).

## Usage

```js
const ogr2pg = require('@mborne/ogr2pg');

const result = await ogr2pg({
    'inputPath': 'place.shp',
    'tableName': 'place'
});

console.log(result.status);
console.log(result.message);
console.log(result.command);
```

## Options

| Name             | Required? | Description                                                      | Default  |
| ---------------- | :-------: | ---------------------------------------------------------------- | -------- |
| `inputPath`      |    YES    | Input file path (.shp, .geojson, etc.)                           |          |
| `encoding`       |    NO     | Input encoding (UTF-8, LATIN1,...)                               | `UTF-8`  |
| `tableName`      |    YES    | Output table name                                                |          |
| `createTable`    |    NO     | Automatically create table (drop table if exists)                | `false`  |
| `schemaName`     |    NO     | Output schema name                                               | `public` |
| `createSchema`   |    NO     | Automatically create schema if not exists                        | `false`  |
| `promoteToMulti` |    NO     | Promote geometry to multi (ex : MultiPolygon instead of Polygon) | `false`  |
| `skipFailures`   |    NO     | skip failures when importing data                                | `false`  |

## License

[MIT](LICENSE)
npm package: @mborne/postgis-helper
Description: Helpers for PostgreSQL/PostGIS (schema discovery, psql, pg_dump,...)
Author: Mickaël Borne
Latest version: 0.3.2

# node-postgis-helper

## Description

Helpers for PostgreSQL/PostGIS (schema discovery, psql, pg_dump,...)

## Parameters

Connection to the database relies on PostgreSQL environment variables (PGHOST, PGDATABASE, etc.)

## Concepts

| Concept       | Description                                                                  |
| ------------- | ---------------------------------------------------------------------------- |
| Database      | Database connexion wrapper (`Client` from `pg`)                              |
| Catalog       | Database schema explorer (schemas, tables, columns, constraints)             |
| SourceManager | Manage a per-schema `source` table to track source when loading foreign data |
| Table         | JS model describing an SQL table                                             |
| Column        | JS model describing an SQL column                                            |

## Features

`Client` wrapper for `pg` module providing helpers.

### Create and release connections

```js
let database = await Database.createDatabase();
let activites = await database.query('SELECT * FROM pg_stat_activity');
await database.close();
```

### List schemas

```js
let schemaNames = await database.getSchemaNames();
await database.hasSchema('public');
```

### List tables

```js
let tableNames = await database.getTableNames('public');
```

### Get tables with primaryKey, columns and constraints

```js
let tables = await database.getTables('public');
```



### Backup a given schema

```js
const {backup} = require('@mborne/postgis-helper');

/*
 * Rely on pg_dump to backup 'cadastre' schema as :
 * - /mnt/postgis-backup/cadastre.schema.sql
 * - /mnt/postgis-backup/cadastre.data.sql
 */
await backup({
    schemaName: 'cadastre',
    targetDir: '/mnt/postgis-backup'
});
```

## Testing

```bash
createdb test
PGDATABASE=test npm run test
```

## Changelog and roadmap

See [CHANGELOG.md](CHANGELOG.md)