Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ci/scripts/run-all-examples.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
set -e

echo "running all examples"
echo "running all JS examples"
echo "--------------------"

for example in examples/*; do
for example in examples/js/*; do
echo "running $(basename $example .js)"
node $example
echo "--------------------"
done

echo "running all TS examples"
echo "--------------------"

for example in examples/ts/*; do
echo "running $(basename $example .ts)"
npx ts-node $example
echo "--------------------"
done
4 changes: 2 additions & 2 deletions examples/availability.js → examples/js/availability.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const result = await UKPD.availability()
Expand Down
4 changes: 2 additions & 2 deletions examples/categories.js → examples/js/categories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const result = await UKPD.categories()
Expand Down
4 changes: 2 additions & 2 deletions examples/forces.js → examples/js/forces.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const result = await UKPD.forces()
Expand Down
4 changes: 2 additions & 2 deletions examples/last-updated.js → examples/js/last-updated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const result = await UKPD.lastUpdated()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const results = await UKPD.stopAndSearch('cheshire')
Expand Down
4 changes: 2 additions & 2 deletions examples/street-level.js → examples/js/street-level.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// const traffic = require('ukpd')
const UKPD = require('../build')
// const UKPD = require('ukpd')
const UKPD = require('../../build')

async function main () {
const results = await UKPD.streetLevel(52.629729, -1.131592)
Expand Down
14 changes: 14 additions & 0 deletions examples/ts/availability.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const result = await UKPD.availability()

const dates = result.map((item) => item.date)

console.log('data is available for', dates.join(', '))
}

main()
14 changes: 14 additions & 0 deletions examples/ts/categories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const result = await UKPD.categories()

const categories = result.map((category) => category.name)

console.log('the following categories are available:', categories.join(', '))
}

main()
15 changes: 15 additions & 0 deletions examples/ts/forces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const result = await UKPD.forces()

const forcesArray = Array.isArray(result) ? result : [result]
const forces = forcesArray.map((force) => force.name)

console.log('data for the following police forces are available:', forces.join(', '))
}

main()
12 changes: 12 additions & 0 deletions examples/ts/last-updated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const result = await UKPD.lastUpdated()

console.log('data was last updated on', result.date)
}

main()
12 changes: 12 additions & 0 deletions examples/ts/stop-and-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const results = await UKPD.stopAndSearch('cheshire')

console.log('there were', results.length, 'stop and searches')
}

main()
12 changes: 12 additions & 0 deletions examples/ts/street-level.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// obtain a reference to the module
// when using the module in your project, this line would be
// import * as UKPD from 'ukpd'
import * as UKPD from '../../build'

async function main () {
const results = await UKPD.streetLevel(52.629729, -1.131592)

console.log('there were', results.length, 'crimes')
}

main()
Loading