Skip to content

Commit 5ee5779

Browse files
authored
Merge pull request #159 from neaps/ts
Convert to TypeScript
2 parents 13bea43 + b7ee983 commit 5ee5779

40 files changed

Lines changed: 632 additions & 7140 deletions

.eslintrc.cjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
module.exports = {
2-
env: {
3-
browser: true,
4-
es2021: true,
5-
node: true
6-
},
7-
extends: 'eslint:recommended',
2+
root: true,
3+
env: { es2023: true },
4+
parser: '@typescript-eslint/parser',
85
parserOptions: {
96
ecmaVersion: 'latest',
10-
sourceType: 'module'
7+
sourceType: 'module',
8+
project: ['./tsconfig.json']
119
},
10+
plugins: ['@typescript-eslint'],
11+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
1212
rules: {
13-
indent: ['error', 2],
14-
'linebreak-style': ['error', 'unix'],
15-
quotes: ['error', 'single'],
16-
semi: ['error', 'never']
17-
}
13+
'@typescript-eslint/no-explicit-any': 'off',
14+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
15+
'no-extra-semi': 'warn'
16+
},
17+
ignorePatterns: ['dist/', 'node_modules/']
1818
}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ coverage
44
junit.xml
55
.test-cache
66
.DS_Store
7-
.nyc_output
7+
.nyc_output
8+
dist
9+
*.tsbuildinfo
10+
package-lock.json

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Tide predictor
44

5-
A Javascript tide harmonic calculator.
5+
A tide harmonic calculator written in TypeScript.
66

77
<!-- START DOCS -->
88

@@ -25,17 +25,6 @@ yarn add @neaps/tide-predictor
2525
2626
```
2727

28-
## Importing
29-
30-
You can import the module using Ecmascript, or CommonJS. Note that the CommonJS export is transpiled, so deep debugging the module that way will be difficult.
31-
32-
```js
33-
import TidePredictor from '@neaps/tide-predictor'
34-
const TidePredictor = require('@neaps/tide-predictor')
35-
```
36-
37-
There are also packaged and minified versions for the browser in `dist/web`.
38-
3928
# Usage
4029

4130
Neaps requires that you [provide your own tidal harmonics information](#constituent-object) to generate a prediction.
@@ -44,7 +33,7 @@ Because many constituent datum come with multiple phases (in the case of NOAA's
4433

4534
Note that, for now, Neaps **will not** do any timezone corrections. This means you need to pass date objects that align with whatever timezone the constituents are in.
4635

47-
```javascript
36+
```typescript
4837
import TidePredictor from '@neaps/tide-predictor'
4938

5039
const constituents = [
@@ -83,7 +72,7 @@ The returned tide prediction object has various methods. All of these return reg
8372

8473
Returns the predicted high and low tides between a start and end date.
8574

86-
```javascript
75+
```typescript
8776
const startDate = new Date()
8877
const endDate = new Date(startDate + 3 * 24 * 60 * 60 * 1000)
8978
const tides = TidePredictor(constituents).getExtremesPrediction({
@@ -99,7 +88,7 @@ const tides = TidePredictor(constituents).getExtremesPrediction({
9988

10089
If you want predictions for a subservient station, first set the reference station in the prediction, and pass the [subservient station offests](#subservient-station) to the `getExtremesPrediction` method:
10190

102-
```javascript
91+
```typescript
10392
const tides = TidePredictor(constituents).getExtremesPrediction({
10493
start: startDate,
10594
end: endDate,
@@ -142,7 +131,7 @@ High and low tides are returned as arrays of objects:
142131

143132
Gives you the predicted water level at a specific time.
144133

145-
```javascript
134+
```typescript
146135
const waterLevel = TidePredictor(constituents).getWaterLevelAtTime({
147136
time: new Date()
148137
})

0 commit comments

Comments
 (0)