kontonummer 1.4.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -278
- package/dist/cjs/banks.js +270 -0
- package/dist/cjs/banks.js.map +1 -0
- package/dist/cjs/errors.js +11 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/format.js +84 -0
- package/dist/cjs/format.js.map +1 -0
- package/dist/cjs/index.js +150 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/validate.js +46 -0
- package/dist/cjs/validate.js.map +1 -0
- package/dist/esm/banks.js +267 -0
- package/dist/esm/banks.js.map +1 -0
- package/dist/esm/errors.js +7 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/format.js +80 -0
- package/dist/esm/format.js.map +1 -0
- package/dist/esm/index.js +120 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/validate.js +41 -0
- package/dist/esm/validate.js.map +1 -0
- package/{dist-types → dist/types}/banks.d.ts +3 -3
- package/{dist-types → dist/types}/errors.d.ts +0 -0
- package/{dist-types → dist/types}/format.d.ts +0 -0
- package/{dist-types → dist/types}/index.d.ts +0 -0
- package/dist/types/validate.d.ts +6 -0
- package/package.json +35 -53
- package/CHANGELOG.md +0 -35
- package/dist-node/index.js +0 -924
- package/dist-node/index.js.map +0 -1
- package/dist-src/banks.js +0 -247
- package/dist-src/errors.js +0 -49
- package/dist-src/format.js +0 -102
- package/dist-src/index.js +0 -207
- package/dist-src/validate.js +0 -41
- package/dist-types/validate.d.ts +0 -5
- package/dist-web/index.bundled.js +0 -2
- package/dist-web/index.bundled.js.map +0 -1
- package/dist-web/index.js +0 -647
- package/dist-web/index.js.map +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Kontonummer_bankName, _Kontonummer_sortingCode, _Kontonummer_accountNumber, _Kontonummer_type, _Kontonummer_comment, _Kontonummer_valid;
|
|
13
|
+
import getSortingCodeInfo from './banks';
|
|
14
|
+
import { KontonummerError } from './errors';
|
|
15
|
+
import validateCheckDigit, { mod10 } from './validate';
|
|
16
|
+
import formatter from './format';
|
|
17
|
+
export default class Kontonummer {
|
|
18
|
+
constructor(sortingCodeWithOrWithoutAccountNumber, accountOrOptions, optionsArg) {
|
|
19
|
+
_Kontonummer_bankName.set(this, void 0);
|
|
20
|
+
_Kontonummer_sortingCode.set(this, void 0);
|
|
21
|
+
_Kontonummer_accountNumber.set(this, void 0);
|
|
22
|
+
_Kontonummer_type.set(this, void 0);
|
|
23
|
+
_Kontonummer_comment.set(this, void 0);
|
|
24
|
+
_Kontonummer_valid.set(this, void 0); // only relevant in `lax` mode
|
|
25
|
+
let accountNumber;
|
|
26
|
+
let options = {
|
|
27
|
+
mode: 'strict'
|
|
28
|
+
};
|
|
29
|
+
// parse params
|
|
30
|
+
// sortingCode
|
|
31
|
+
sortingCodeWithOrWithoutAccountNumber = `${sortingCodeWithOrWithoutAccountNumber}`.replace(/[^\d]/g, '');
|
|
32
|
+
// Swedbank 8xxx-x have 5 digits
|
|
33
|
+
const sortingCode = sortingCodeWithOrWithoutAccountNumber.substring(0, sortingCodeWithOrWithoutAccountNumber.startsWith('8') ? 5 : 4);
|
|
34
|
+
// accountNumber
|
|
35
|
+
if (typeof accountOrOptions === 'object') {
|
|
36
|
+
options = accountOrOptions;
|
|
37
|
+
accountNumber = sortingCodeWithOrWithoutAccountNumber.substring(sortingCodeWithOrWithoutAccountNumber.startsWith('8') ? 5 : 4);
|
|
38
|
+
}
|
|
39
|
+
else if (typeof accountOrOptions === 'string' || typeof accountOrOptions === 'number') {
|
|
40
|
+
accountNumber = `${accountOrOptions}`.replace(/[^\d]/g, '');
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
accountNumber = sortingCodeWithOrWithoutAccountNumber.substring(sortingCodeWithOrWithoutAccountNumber.startsWith('8') ? 5 : 4);
|
|
44
|
+
}
|
|
45
|
+
// optionsArg
|
|
46
|
+
if (typeof optionsArg === 'object') {
|
|
47
|
+
options = optionsArg;
|
|
48
|
+
}
|
|
49
|
+
// validate arguments
|
|
50
|
+
if (sortingCode.length < 4 || (sortingCode.length > 4 ? !mod10(sortingCode) : false)) {
|
|
51
|
+
throw new KontonummerError('Invalid sorting code');
|
|
52
|
+
}
|
|
53
|
+
if (accountNumber.length < 2) {
|
|
54
|
+
throw new KontonummerError('Invalid account number');
|
|
55
|
+
}
|
|
56
|
+
const bank = Kontonummer.getSortingCodeInfo(sortingCode);
|
|
57
|
+
const valid = validateCheckDigit(bank.type, bank.comment, sortingCode, accountNumber);
|
|
58
|
+
if (!valid && options.mode === 'strict')
|
|
59
|
+
throw new KontonummerError('Invalid account number');
|
|
60
|
+
if (!valid && bank.type === 1 && options.mode === 'semi')
|
|
61
|
+
throw new KontonummerError('Invalid account number');
|
|
62
|
+
__classPrivateFieldSet(this, _Kontonummer_bankName, bank.bankName, "f");
|
|
63
|
+
__classPrivateFieldSet(this, _Kontonummer_type, bank.type, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _Kontonummer_comment, bank.comment, "f");
|
|
65
|
+
__classPrivateFieldSet(this, _Kontonummer_sortingCode, sortingCode, "f");
|
|
66
|
+
__classPrivateFieldSet(this, _Kontonummer_accountNumber, accountNumber, "f");
|
|
67
|
+
__classPrivateFieldSet(this, _Kontonummer_valid, valid, "f");
|
|
68
|
+
}
|
|
69
|
+
get bankName() { return __classPrivateFieldGet(this, _Kontonummer_bankName, "f"); }
|
|
70
|
+
get sortingCode() { return __classPrivateFieldGet(this, _Kontonummer_sortingCode, "f"); }
|
|
71
|
+
get accountNumber() { return __classPrivateFieldGet(this, _Kontonummer_accountNumber, "f"); }
|
|
72
|
+
get type() { return __classPrivateFieldGet(this, _Kontonummer_type, "f"); }
|
|
73
|
+
get comment() { return __classPrivateFieldGet(this, _Kontonummer_comment, "f"); }
|
|
74
|
+
get valid() { return __classPrivateFieldGet(this, _Kontonummer_valid, "f"); }
|
|
75
|
+
format(format) {
|
|
76
|
+
return formatter(this.sortingCode, this.accountNumber, Kontonummer.getSortingCodeInfo(this.sortingCode), format);
|
|
77
|
+
}
|
|
78
|
+
static parse(sortingCodeWithOrWithoutAccountNumber, accountOrOptions, options) {
|
|
79
|
+
if (typeof accountOrOptions === 'string' || typeof accountOrOptions === 'number')
|
|
80
|
+
return new Kontonummer(sortingCodeWithOrWithoutAccountNumber, accountOrOptions, options);
|
|
81
|
+
else
|
|
82
|
+
return new Kontonummer(sortingCodeWithOrWithoutAccountNumber, accountOrOptions);
|
|
83
|
+
}
|
|
84
|
+
static valid(sortingCodeWithOrWithoutAccountNumber, accountNumber) {
|
|
85
|
+
if (accountNumber && (typeof accountNumber !== 'string' || typeof accountNumber !== 'number'))
|
|
86
|
+
throw new KontonummerError('Kontonummer.valid() does not accept an options argument');
|
|
87
|
+
try {
|
|
88
|
+
if (accountNumber)
|
|
89
|
+
new Kontonummer(sortingCodeWithOrWithoutAccountNumber, accountNumber); // eslint-disable-line no-new
|
|
90
|
+
else
|
|
91
|
+
new Kontonummer(sortingCodeWithOrWithoutAccountNumber); // eslint-disable-line no-new
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
static getSortingCodeInfo(sortingCode) {
|
|
99
|
+
const bank = getSortingCodeInfo(sortingCode);
|
|
100
|
+
if (typeof bank === 'undefined')
|
|
101
|
+
throw new KontonummerError(`No Bank found with sorting code ${sortingCode}`);
|
|
102
|
+
return bank;
|
|
103
|
+
}
|
|
104
|
+
toJSON() {
|
|
105
|
+
return {
|
|
106
|
+
bankName: this.bankName,
|
|
107
|
+
sortingCode: this.sortingCode,
|
|
108
|
+
accountNumber: this.accountNumber,
|
|
109
|
+
type: this.type,
|
|
110
|
+
comment: this.comment,
|
|
111
|
+
valid: this.valid
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
[(_Kontonummer_bankName = new WeakMap(), _Kontonummer_sortingCode = new WeakMap(), _Kontonummer_accountNumber = new WeakMap(), _Kontonummer_type = new WeakMap(), _Kontonummer_comment = new WeakMap(), _Kontonummer_valid = new WeakMap(), Symbol.for('nodejs.util.inspect.custom'))]() {
|
|
115
|
+
return this.toJSON();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export const parse = Kontonummer.parse;
|
|
119
|
+
export const valid = Kontonummer.valid;
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,kBAAkB,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,SAAqB,MAAM,UAAU,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,WAAW;IAiB9B,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,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAA;QAC5C,IAAI,OAAO,IAAI,KAAK,WAAW;YAAE,MAAM,IAAI,gBAAgB,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAA;QAC7G,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAED,4OAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAC;QACxC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAA;IACtB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAA;AACtC,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const mod10 = (number) => {
|
|
2
|
+
number = `${number}`;
|
|
3
|
+
let len = number.length;
|
|
4
|
+
let bit = 1;
|
|
5
|
+
let sum = 0;
|
|
6
|
+
let val;
|
|
7
|
+
const arr = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];
|
|
8
|
+
while (len) {
|
|
9
|
+
val = parseInt(number.charAt(--len), 10);
|
|
10
|
+
bit ^= 1;
|
|
11
|
+
sum += bit ? arr[val] : val;
|
|
12
|
+
}
|
|
13
|
+
return !!sum && sum % 10 === 0;
|
|
14
|
+
};
|
|
15
|
+
export const mod11 = (number) => {
|
|
16
|
+
number = `${number}`;
|
|
17
|
+
let len = number.length;
|
|
18
|
+
let sum = 0;
|
|
19
|
+
let val;
|
|
20
|
+
const weights = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
|
|
21
|
+
const arr = weights.splice(weights.length - len, weights.length - (weights.length - len));
|
|
22
|
+
while (len) {
|
|
23
|
+
val = parseInt(number.charAt(--len), 10);
|
|
24
|
+
sum += arr[len] * val;
|
|
25
|
+
}
|
|
26
|
+
return !!sum && sum % 11 === 0;
|
|
27
|
+
};
|
|
28
|
+
export default (type, comment, sortingCode, accountNumber) => {
|
|
29
|
+
// 1:1 => mod11 on 3 last of clearing + whole account number
|
|
30
|
+
if (type === 1 && comment === 1)
|
|
31
|
+
return mod11(`${sortingCode.substring(1)}${accountNumber.padStart(7, '0')}`);
|
|
32
|
+
// 1:2 => mod 11 on whole clearing + whole account number
|
|
33
|
+
if (type === 1 && comment === 2)
|
|
34
|
+
return mod11(`${sortingCode}${accountNumber.padStart(7, '0')}`);
|
|
35
|
+
// 2:2 => mod11 on whole account number (SHB) 9 digits
|
|
36
|
+
if (type === 2 && comment === 2)
|
|
37
|
+
return mod11(`${accountNumber.padStart(9, '0')}`);
|
|
38
|
+
// 2:1 & 2:3 => mod10 on whole account number
|
|
39
|
+
return mod10(accountNumber.padStart(10, '0'));
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,KAAK,GAAgB,CAAC,MAAM,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IAEpB,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAA;IACvB,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,IAAI,GAAW,CAAA;IACf,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IA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E;IAChI,4DAA4D;IAC5D,IAAI,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IAC7G,yDAAyD;IACzD,IAAI,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IAEhG,sDAAsD;IACtD,IAAI,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IAClF,6CAA6C;IAC7C,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type
|
|
1
|
+
export declare type BankName = 'Avanza Bank' | 'BlueStep Finans' | 'BNP Paribas SA.' | 'Citibank' | 'Danske Bank' | 'DNB Bank' | 'Ekobanken' | 'Erik Penser' | 'Ferratum Bank plc' | 'Handelsbanken' | 'ICA Banken' | 'IKANO Bank' | 'JAK Medlemsbank' | 'Klarna Bank' | 'Lån & Spar Bank Sverige' | 'Landshypotek' | 'Länsförsäkringar Bank' | 'Marginalen Bank' | 'MedMera Bank' | 'Nordax Bank' | 'Nordea' | 'Nordea Plusgirot' | 'Nordnet Bank' | 'Northmill Bank' | 'Resurs Bank' | 'Riksgälden' | 'Santander Consumer Bank' | 'SBAB' | 'SEB' | 'Skandiabanken' | 'Sparbanken Syd' | 'Svea Bank' | 'Swedbank' | 'Ålandsbanken';
|
|
2
2
|
interface SortingCodeBase {
|
|
3
3
|
bankName: BankName;
|
|
4
4
|
ranges: Array<[number, number]>;
|
|
@@ -13,7 +13,7 @@ export interface Type2Account extends SortingCodeBase {
|
|
|
13
13
|
accountMinLength?: number;
|
|
14
14
|
accountMaxLength?: number;
|
|
15
15
|
}
|
|
16
|
-
export declare type
|
|
16
|
+
export declare type SortingCodeInfo = Type1Account | Type2Account;
|
|
17
17
|
export declare const banks: SortingCodeInfo[];
|
|
18
|
-
declare const _default: (sortingCode: string | number) =>
|
|
18
|
+
declare const _default: (sortingCode: string | number) => SortingCodeInfo | undefined;
|
|
19
19
|
export default _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SortingCodeInfo } from './banks';
|
|
2
|
+
declare type modFunction = (number: string | number) => boolean;
|
|
3
|
+
export declare const mod10: modFunction;
|
|
4
|
+
export declare const mod11: modFunction;
|
|
5
|
+
declare const _default: (type: SortingCodeInfo['type'], comment: SortingCodeInfo['comment'], sortingCode: string, accountNumber: string) => boolean;
|
|
6
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kontonummer",
|
|
3
|
+
"version": "3.0.0",
|
|
3
4
|
"description": "A validator for swedish banking numbers",
|
|
4
|
-
"
|
|
5
|
+
"author": "Svante Bengtson <svante@swantzter.se> (https://swantzter.se)",
|
|
5
6
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
"homepage": "https://kontonummer.se",
|
|
8
|
+
"main": "dist/esm/index.js",
|
|
9
|
+
"types": "dist/types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/swantzter/kontonummer.git"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",
|
|
21
|
+
"build:watch": "tsc --watch -p tsconfig.production.json",
|
|
22
|
+
"test": "NODE_OPTIONS='--loader tsx' mocha test/**/*.test.ts",
|
|
23
|
+
"test:coverage": " c8 -r lcov -r text npm test",
|
|
24
|
+
"lint": "eslint . --ignore-path .gitignore",
|
|
25
|
+
"lint:fix": "npm run lint -- --fix",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"prepack": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/mocha": "^9.1.1",
|
|
31
|
+
"@types/node": "^16.11.57",
|
|
32
|
+
"c8": "^7.12.0",
|
|
33
|
+
"eslint": "^8.23.0",
|
|
34
|
+
"eslint-config-standard-with-typescript": "^22.0.0",
|
|
35
|
+
"mocha": "^10.0.0",
|
|
36
|
+
"tsx": "^3.9.0",
|
|
37
|
+
"typescript": "^4.2.4"
|
|
38
|
+
},
|
|
12
39
|
"keywords": [
|
|
13
40
|
"banking",
|
|
14
41
|
"bank account",
|
|
@@ -19,50 +46,5 @@
|
|
|
19
46
|
"bankkonto",
|
|
20
47
|
"format",
|
|
21
48
|
"verify"
|
|
22
|
-
]
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/svbeon/kontonummer.git"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@babel/core": "^7.9.0",
|
|
30
|
-
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
31
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
|
|
32
|
-
"@babel/preset-env": "^7.8.3",
|
|
33
|
-
"@babel/register": "^7.9.0",
|
|
34
|
-
"@pika/pack": "^0.5.0",
|
|
35
|
-
"@pika/plugin-build-node": "^0.9.2",
|
|
36
|
-
"@pika/plugin-build-types": "^0.9.2",
|
|
37
|
-
"@pika/plugin-build-web": "^0.9.2",
|
|
38
|
-
"@pika/plugin-bundle-web": "^0.9.2",
|
|
39
|
-
"@pika/plugin-standard-pkg": "^0.9.2",
|
|
40
|
-
"@semantic-release/changelog": "^5.0.1",
|
|
41
|
-
"@semantic-release/commit-analyzer": "^8.0.1",
|
|
42
|
-
"@semantic-release/git": "^9.0.0",
|
|
43
|
-
"@semantic-release/github": "^7.0.5",
|
|
44
|
-
"@semantic-release/npm": "^7.0.5",
|
|
45
|
-
"@semantic-release/release-notes-generator": "^9.0.1",
|
|
46
|
-
"@types/mocha": "^7.0.2",
|
|
47
|
-
"@types/node": "^13.11.1",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
|
49
|
-
"@typescript-eslint/parser": "^2.27.0",
|
|
50
|
-
"commitizen": "^4.0.4",
|
|
51
|
-
"cz-conventional-changelog": "^3.1.0",
|
|
52
|
-
"flowgen": "^1.10.0",
|
|
53
|
-
"husky": "^4.2.5",
|
|
54
|
-
"mocha": "^7.1.1",
|
|
55
|
-
"nyc": "^15.0.1",
|
|
56
|
-
"pika-plugin-typedefs-to-flow": "0.0.2",
|
|
57
|
-
"pika-plugin-unpkg-field": "^1.1.0",
|
|
58
|
-
"semantic-release": "^17.0.4",
|
|
59
|
-
"standardx": "^5.0.0",
|
|
60
|
-
"ts-node": "^8.8.2",
|
|
61
|
-
"typescript": "^3.8.3"
|
|
62
|
-
},
|
|
63
|
-
"esnext": "dist-src/index.js",
|
|
64
|
-
"main": "dist-node/index.js",
|
|
65
|
-
"types": "dist-types/index.d.ts",
|
|
66
|
-
"module": "dist-web/index.js",
|
|
67
|
-
"browser": "dist-web/index.bundled.js"
|
|
49
|
+
]
|
|
68
50
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# [1.4.0](https://github.com/svbeon/kontonummer/compare/v1.3.0...v1.4.0) (2020-04-28)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* **banks:** add newly confirmed account number min length to SHB accounts ([98627a4](https://github.com/svbeon/kontonummer/commit/98627a4744ff366e4326c9cbe3ed2480dff498ba))
|
|
7
|
-
* **format:** add forgotten format for Nordea Personkonto ([d61bc92](https://github.com/svbeon/kontonummer/commit/d61bc92ec4bc364625b8f1e6bc0e16c3897e8a67))
|
|
8
|
-
|
|
9
|
-
# [1.3.0](https://github.com/svbeon/kontonummer/compare/v1.2.0...v1.3.0) (2020-04-16)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
|
|
14
|
-
* **banks:** always use 4 digit sortingCode for bank lookup ([1ceb351](https://github.com/svbeon/kontonummer/commit/1ceb35110926bd82572ba42610db409cc019bc6c))
|
|
15
|
-
|
|
16
|
-
# [1.2.0](https://github.com/svbeon/kontonummer/compare/v1.1.0...v1.2.0) (2020-04-12)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Features
|
|
20
|
-
|
|
21
|
-
* **format:** implement the format method ([ca57a4a](https://github.com/svbeon/kontonummer/commit/ca57a4ab6e1423b1c8f7509394337bc19c982b96))
|
|
22
|
-
|
|
23
|
-
# [1.1.0](https://github.com/svbeon/kontonummer/compare/v1.0.0...v1.1.0) (2020-04-12)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* **kontonummer:** console.log returns the value of the getters ([974086d](https://github.com/svbeon/kontonummer/commit/974086d4f14813288a8e7d40fd5791cefaa56216))
|
|
29
|
-
|
|
30
|
-
# 1.0.0 (2020-04-10)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Features
|
|
34
|
-
|
|
35
|
-
* **validate:** validates account numbers and sorting codes ([b191ac8](https://github.com/svbeon/kontonummer/commit/b191ac8cf8beb01c4336b2104a243c3b18f0f26d))
|