Skip to content

Commit

Permalink
Added the project how to use example
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kibet committed Mar 4, 2023
1 parent 918c6e3 commit d822efd
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 5 deletions.
Empty file modified .github/PULL_REQUEST.md
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - yyyy-mm-dd

Here we write upgrading notes for brands. It's a team effort to make them as
straightforward as possible.

## [1.0.0] - 2023-03-04

### Added
- Added the initial project structure
- Added the functionality to fetch the list of the counties
- Added the example on how to use

### Changed
Empty file modified README.md
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions example/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import processCounties from "../lib/index"

console.info("----", JSON.stringify(processCounties))
Empty file modified lib/constants.ts
100644 → 100755
Empty file.
13 changes: 10 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import constants from "./constants"

const queue = fastq.promise(worker, constants.WORKER_CONCURRENCY)

async function worker() {
async function processCounties() {
const targetUrl = constants.KENYA_COUNTIES_URL;
const pageResponse = await axios.get(targetUrl);
const $ = cheerio.load(pageResponse.data);
Expand All @@ -31,11 +31,18 @@ async function worker() {
return result
}

async function worker() {
let resultSet = await processCounties()
return resultSet
}

async function run() {
let result = await queue.push({})
console.info(JSON.stringify(result))
return result
}

run().catch(e => {
console.error(e)
})
})

export default { processCounties }
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "counties-kenya-lib",
"version": "1.0.0",
"scripts": {
"dev": "esr ./lib/index.ts"
"dev": "esr ./lib/index.ts",
"example": "esr ./example/example.ts"
},
"dependencies": {
"axios": "^1.3.4",
Expand All @@ -12,4 +15,4 @@
"esbuild-runner": "^2.2.2",
"typescript": "^4.9.5"
}
}
}

0 comments on commit d822efd

Please sign in to comment.