nationwide
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./numbers"), exports); | ||
tslib_1.__exportStar(require("./Transaction"), exports); | ||
export * from "./numbers"; | ||
export * from "./Transaction"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,11 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pounds = exports.round = void 0; | ||
var round = function (n, places) { | ||
export var round = function (n, places) { | ||
if (places === void 0) { places = 2; } | ||
return Math.round((n + Number.EPSILON) * Math.pow(10, places)) / Math.pow(10, places); | ||
}; | ||
exports.round = round; | ||
var pounds = function (str) { return parseFloat(str.replace("£", "")); }; | ||
exports.pounds = pounds; | ||
export var pounds = function (str) { return parseFloat(str.replace("£", "")); }; | ||
//# sourceMappingURL=numbers.js.map |
@@ -1,15 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Transaction = void 0; | ||
var tslib_1 = require("tslib"); | ||
var node_html_parser_1 = require("node-html-parser"); | ||
var ramda_1 = require("ramda"); | ||
var superstruct_1 = require("superstruct"); | ||
var luxon_1 = require("luxon"); | ||
var dedent_1 = tslib_1.__importDefault(require("dedent")); | ||
var numbers_1 = require("./numbers"); | ||
import { __read } from "tslib"; | ||
import { parse } from "node-html-parser"; | ||
import { groupBy, prop, sortBy, sum } from "ramda"; | ||
import { number, object, string, validate } from "superstruct"; | ||
import { DateTime } from "luxon"; | ||
import { pounds } from "./numbers"; | ||
import dedent from "dedent"; | ||
var Transaction = (function () { | ||
function Transaction(row) { | ||
var columns = row.childNodes; | ||
var _a = tslib_1.__read(columns | ||
var _a = __read(columns | ||
.filter(function (_a) { | ||
@@ -28,18 +25,18 @@ var rawTagName = _a.rawTagName; | ||
var iso = function (date) { | ||
return luxon_1.DateTime.fromFormat(date, "dd MMM yyyy").toISODate(); | ||
return DateTime.fromFormat(date, "dd MMM yyyy").toISODate(); | ||
}; | ||
var _b = tslib_1.__read((0, superstruct_1.validate)({ | ||
var _b = __read(validate({ | ||
date: iso((date !== null && date !== void 0 ? date : "").slice(0, 11)), | ||
type: type, | ||
account: account, | ||
sent: sent ? (0, numbers_1.pounds)(sent) : 0, | ||
received: received ? (0, numbers_1.pounds)(received) : 0, | ||
balance: (0, numbers_1.pounds)(balance !== null && balance !== void 0 ? balance : ""), | ||
}, (0, superstruct_1.object)({ | ||
date: (0, superstruct_1.string)(), | ||
type: (0, superstruct_1.string)(), | ||
account: (0, superstruct_1.string)(), | ||
sent: (0, superstruct_1.number)(), | ||
received: (0, superstruct_1.number)(), | ||
balance: (0, superstruct_1.number)(), | ||
sent: sent ? pounds(sent) : 0, | ||
received: received ? pounds(received) : 0, | ||
balance: pounds(balance !== null && balance !== void 0 ? balance : ""), | ||
}, object({ | ||
date: string(), | ||
type: string(), | ||
account: string(), | ||
sent: number(), | ||
received: number(), | ||
balance: number(), | ||
})), 2), error = _b[0], validated = _b[1]; | ||
@@ -56,3 +53,3 @@ if (error) { | ||
Transaction.table = function (str) { | ||
return (0, node_html_parser_1.parse)((0, dedent_1.default)(str)) | ||
return parse(dedent(str)) | ||
.querySelectorAll("table > tbody > tr") | ||
@@ -62,10 +59,10 @@ .map(function (i) { return new Transaction(i); }); | ||
Transaction.collate = function (transactions) { | ||
return Object.fromEntries((0, ramda_1.sortBy)(function (_a) { | ||
var _b = tslib_1.__read(_a, 2), _ = _b[0], v = _b[1]; | ||
return Object.fromEntries(sortBy(function (_a) { | ||
var _b = __read(_a, 2), _ = _b[0], v = _b[1]; | ||
return v; | ||
}, Object.entries((0, ramda_1.groupBy)((0, ramda_1.prop)("account"), transactions)).map(function (_a) { | ||
var _b = tslib_1.__read(_a, 2), k = _b[0], v = _b[1]; | ||
}, Object.entries(groupBy(prop("account"), transactions)).map(function (_a) { | ||
var _b = __read(_a, 2), k = _b[0], v = _b[1]; | ||
return [ | ||
k, | ||
(0, ramda_1.sum)(v.map((0, ramda_1.prop)("change"))), | ||
sum((v !== null && v !== void 0 ? v : []).map(prop("change"))), | ||
]; | ||
@@ -76,3 +73,3 @@ }))); | ||
}()); | ||
exports.Transaction = Transaction; | ||
export { Transaction }; | ||
//# sourceMappingURL=Transaction.js.map |
# MIT License | ||
Copyright (c) 2023 Joel Lefkowitz | ||
Copyright (c) 2024 Joel Lefkowitz | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
{ | ||
"name": "nationwide", | ||
"description": "A Nationwide transactions table parser.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"private": false, | ||
"license": "MIT", | ||
"author": "Joel Lefkowitz", | ||
"repository": "https://github.com/joellefkowitz/nationwide", | ||
"homepage": "https://nationwide.readthedocs.io", | ||
"author": "Joel Lefkowitz", | ||
"license": "MIT", | ||
"homepage": "https://joellefkowitz.github.io/nationwide", | ||
"main": "dist/index.js", | ||
@@ -13,38 +14,8 @@ "files": [ | ||
], | ||
"scripts": { | ||
"prepare": "husky install" | ||
}, | ||
"dependencies": { | ||
"dedent": "^0.7.0", | ||
"luxon": "^3.3.0", | ||
"node-html-parser": "^4.1.3", | ||
"ramda": "^0.28.0", | ||
"superstruct": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/dedent": "^0.7.0", | ||
"@types/jest": "28.1.1", | ||
"@types/luxon": "^3.2.0", | ||
"@types/node": "^18.11.18", | ||
"@types/ramda": "^0.28.23", | ||
"@types/superstruct": "^0.8.2", | ||
"@typescript-eslint/eslint-plugin": "^5.52.0", | ||
"@typescript-eslint/parser": "^5.36.1", | ||
"cspell": "^6.26.3", | ||
"eslint": "~8.34.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"husky": "^8.0.3", | ||
"jest": "28.1.1", | ||
"nps": "^5.10.0", | ||
"nps-utils": "^1.7.0", | ||
"prettier": "^2.6.2", | ||
"ts-jest": "28.0.5", | ||
"ts-node": "10.9.1", | ||
"tslib": "^2.3.0", | ||
"typescript": "^4.8.4" | ||
}, | ||
"keywords": [ | ||
"nationwide", | ||
"parser" | ||
], | ||
"metadata": { | ||
"documentation": "https://nationwide.readthedocs.io", | ||
"packages": "https://npmjs.com/package/nationwide", | ||
"publisher": "npm", | ||
"languages": [ | ||
@@ -57,5 +28,39 @@ "TypeScript" | ||
], | ||
"lifecycle": "Beta", | ||
"publisher": "npm" | ||
"lifecycle": "Alpha" | ||
}, | ||
"scripts": { | ||
"prepare": "husky", | ||
"lint": "cspell . --dot && eslint . --fix && tsc --noEmit", | ||
"format": "prettier . --write", | ||
"build": "tsc", | ||
"test": "jest", | ||
"docs": "typedoc" | ||
}, | ||
"dependencies": { | ||
"luxon": "^3.4.4", | ||
"node-html-parser": "^6.1.12", | ||
"ramda": "^0.29.1", | ||
"superstruct": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "29.0.0", | ||
"@types/luxon": "^3.4.2", | ||
"@types/node": "^18.11.0", | ||
"@types/ramda": "^0.29.10", | ||
"@typescript-eslint/eslint-plugin": "^6.20.0", | ||
"@typescript-eslint/parser": "^6.20.0", | ||
"cspell": "^8.0.0", | ||
"eslint": "^8.34.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0", | ||
"husky": "^9.0.0", | ||
"jest": "^29.0.0", | ||
"prettier": "^3.0.0", | ||
"ts-jest": "^29.0.0", | ||
"ts-node": "^10.9.2", | ||
"tslib": "^2.3.0", | ||
"typedoc": "^0.25.7", | ||
"typedoc-material-theme": "^1.0.2", | ||
"typescript": "^5.3.0" | ||
} | ||
} |
@@ -5,21 +5,21 @@ # Nationwide | ||
## Status | ||
![Review](https://img.shields.io/github/actions/workflow/status/JoelLefkowitz/nationwide/review.yml) | ||
![Version](https://img.shields.io/npm/v/nationwide) | ||
![Downloads](https://img.shields.io/npm/dw/nationwide) | ||
![Quality](https://img.shields.io/codacy/grade/8fb4d0f0694748c188e083f00ae4ff9f) | ||
![Coverage](https://img.shields.io/codacy/coverage/8fb4d0f0694748c188e083f00ae4ff9f) | ||
| Source | Shields | | ||
| ---------- | ---------------------------------------------------------------------- | | ||
| Project | ![latest_release] ![license] ![line_count] ![language_count] | | ||
| Health | ![documentation] ![review_action] ![codacy_quality] ![codacy_coverage] | | ||
| Publishers | ![npm_version] ![npm_downloads] | | ||
| Repository | ![open_issues] ![closed_issues] ![open_pulls] ![closed_pulls] | | ||
| Activity | ![contributors] ![monthly_commits] ![last_commit] | | ||
## Installing | ||
## Installation | ||
```bash | ||
npm i nationwide | ||
npm install nationwide | ||
``` | ||
## Documentation | ||
Documentation and more detailed examples are hosted on [Github Pages](https://joellefkowitz.github.io/nationwide). | ||
## Usage | ||
Copy the Nationwide statement table from the browser: | ||
Copy the Nationwide statement table from the browser: | ||
@@ -33,3 +33,3 @@ `nationwide.html` | ||
<td> | ||
01 May 2021 | ||
01 May 2023 | ||
<div style="display: none">- 1</div> | ||
@@ -45,3 +45,3 @@ </td> | ||
<td> | ||
02 May 2021 | ||
02 May 2023 | ||
<div style="display: none">- 2</div> | ||
@@ -57,3 +57,3 @@ </td> | ||
<td> | ||
03 May 2021 | ||
03 May 2023 | ||
<div style="display: none">- 3</div> | ||
@@ -79,3 +79,3 @@ </td> | ||
const transactions = Transaction.table( | ||
fs.readFileSync(path.resolve(__dirname, "nationwide.html"), "utf8") | ||
fs.readFileSync(path.join(__dirname, "nationwide.html"), "utf8"), | ||
); | ||
@@ -123,21 +123,21 @@ ``` | ||
## Tests | ||
## Tooling | ||
### Tests | ||
To run tests: | ||
```bash | ||
nps test | ||
npm run test | ||
``` | ||
## Documentation | ||
### Documentation | ||
This repository's documentation is hosted on [Read the Docs](https://nationwide.readthedocs.io/en/latest). | ||
To generate the documentation locally: | ||
```bash | ||
quickdocs | ||
npm run docs | ||
``` | ||
## Linters | ||
### Linters | ||
@@ -147,6 +147,6 @@ To run linters: | ||
```bash | ||
nps lint | ||
npm run lint | ||
``` | ||
## Formatters | ||
### Formatters | ||
@@ -156,13 +156,11 @@ To run formatters: | ||
```bash | ||
nps format | ||
npm run format | ||
``` | ||
## Continuous integration | ||
## Contributing | ||
This repository uses GitHub Actions to lint and test each commit. Each commit should be formatted and its corresponding documentation should be updated. | ||
Please read this repository's [Code of Conduct](CODE_OF_CONDUCT.md) which outlines our collaboration standards and the [Changelog](CHANGELOG.md) for details on breaking changes that have been made. | ||
## Versioning | ||
This repository adheres to semantic versioning standards. For more information on semantic versioning visit [SemVer](https://semver.org). | ||
This repository adheres to semantic versioning standards. For more information on semantic versioning visit [semver](https://semver.org). | ||
Bump2version is used to version and tag changes. For example: | ||
@@ -174,12 +172,4 @@ | ||
## Changelog | ||
### Contributors | ||
Please read this repository's [changelog](CHANGELOG.md) for details on changes that have been made. | ||
## Contributing | ||
Please read this repository's guidelines on [contributing](CONTRIBUTING.md) for details on the process for submitting pull requests. Moreover, our [code of conduct](CODE_OF_CONDUCT.md) declares our collaboration standards. | ||
## Contributors | ||
- [Joel Lefkowitz](https://github.com/joellefkowitz) - Initial work | ||
@@ -196,19 +186,1 @@ | ||
</p> | ||
[latest_release]: https://img.shields.io/github/v/tag/joellefkowitz/nationwide "Latest release" | ||
[license]: https://img.shields.io/github/license/joellefkowitz/nationwide "License" | ||
[line_count]: https://img.shields.io/tokei/lines/github/joellefkowitz/nationwide "Line count" | ||
[language_count]: https://img.shields.io/github/languages/count/joellefkowitz/nationwide "Language count" | ||
[documentation]: https://img.shields.io/readthedocs/nationwide "Documentation" | ||
[review_action]: https://img.shields.io/github/actions/workflow/status/JoelLefkowitz/nationwide/review.yml "Review action" | ||
[codacy_quality]: https://img.shields.io/codacy/grade/8fb4d0f0694748c188e083f00ae4ff9f "Codacy quality" | ||
[codacy_coverage]: https://img.shields.io/codacy/coverage/8fb4d0f0694748c188e083f00ae4ff9f "Codacy coverage" | ||
[npm_version]: https://img.shields.io/npm/v/nationwide "NPM Version" | ||
[npm_downloads]: https://img.shields.io/npm/dw/nationwide "NPM Downloads" | ||
[open_issues]: https://img.shields.io/github/issues/joellefkowitz/nationwide "Open issues" | ||
[closed_issues]: https://img.shields.io/github/issues-closed/joellefkowitz/nationwide "Closed issues" | ||
[open_pulls]: https://img.shields.io/github/issues-pr/joellefkowitz/nationwide "Open pull requests" | ||
[closed_pulls]: https://img.shields.io/github/issues-pr-closed/joellefkowitz/nationwide "Closed pull requests" | ||
[contributors]: https://img.shields.io/github/contributors/joellefkowitz/nationwide "Contributors" | ||
[monthly_commits]: https://img.shields.io/github/commit-activity/m/joellefkowitz/nationwide "Monthly commits" | ||
[last_commit]: https://img.shields.io/github/last-commit/joellefkowitz/nationwide "Last commit" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
4
19
1
0
13305
92
177
1
+ Addedcss-select@5.1.0(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.1.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addednode-html-parser@6.1.13(transitive)
+ Addedramda@0.29.1(transitive)
- Removeddedent@^0.7.0
- Removedcss-select@4.3.0(transitive)
- Removeddedent@0.7.0(transitive)
- Removeddom-serializer@1.4.1(transitive)
- Removeddomhandler@4.3.1(transitive)
- Removeddomutils@2.8.0(transitive)
- Removedentities@2.2.0(transitive)
- Removednode-html-parser@4.1.5(transitive)
- Removedramda@0.28.0(transitive)
Updatedluxon@^3.4.4
Updatednode-html-parser@^6.1.12
Updatedramda@^0.29.1