isbn3 2.0.4 → 2.0.6

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/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # CHANGELOG
2
+ *versions follow [SemVer](http://semver.org)*
3
+
4
+ ## 2.0.0- 2025-11-04
5
+ **BREAKING CHANGES**:
6
+ * The [`audit`](https://github.com/inventaire/isbn3#audit) function output was changed to provide more details on the fixed ISBN candidate
7
+
8
+ ## 1.2.0- 2024-09-16
9
+ * [`audit`](https://github.com/inventaire/isbn3#audit): more possibly recoverable cases added
10
+
11
+ ## 1.1.0- 2020-04-24
12
+ * Add [`audit`](https://github.com/inventaire/isbn3#audit) function and corresponding [`isbn-audit`](https://github.com/inventaire/isbn3#isbn-audit) CLI command
13
+ * Add [`isbn-checksum`](https://github.com/inventaire/isbn3#isbn-checksum) CLI command
14
+ * Add dist files `./dist/isbn.js` and `./dist/isbn.min.js`, both being browserified ES5 versions of the module
15
+
16
+ ## 1.0.0 - 2019-10-07
17
+ Fork from [isbn2](https://www.npmjs.com/package/isbn2)
18
+
19
+ **BREAKING CHANGES**
20
+ * accept approximately formatted ISBNs such as '978-4873113364' that would previously have return a `null` result
21
+ * functions are now directly exposed on the module object:
22
+ ```js
23
+ require('isbn2').ISBN.parse('1933988037').codes.isbn13h // => '978-1-933988-03-0'
24
+ // becomes
25
+ require('isbn3').parse('1933988037').isbn13h // => '978-1-933988-03-0'
26
+ ```
27
+
28
+ ** Added features**
29
+ * added a [command-line interface](https://github.com/inventaire/isbn3#CLI)
30
+ * [expose groups data on the module object](https://github.com/inventaire/isbn3#groups)
31
+ * recover common hyphenization mistake `979-1091146135`
package/bin/isbn CHANGED
@@ -1,12 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  let [ isbn, format ] = process.argv.slice(2)
3
3
 
4
- const output = (message, code = 0) => {
4
+ const output = (message = '', code = 0) => {
5
5
  if (code === 0) process.stdout.write(message)
6
6
  else process.stderr.write(message)
7
7
  process.exit(code)
8
8
  }
9
9
 
10
+ function outputFormatIfExisting (data, format) {
11
+ if (data[format] != null) {
12
+ output(data[format])
13
+ } else {
14
+ console.error(`${format} not found`, data)
15
+ process.exit(1)
16
+ }
17
+ }
18
+
10
19
  if (!isbn || isbn.length === 0) {
11
20
  output(`isbn <isbn> <format>
12
21
 
@@ -36,17 +45,17 @@ const parse = require('../lib/parse')
36
45
  const audit = require('../lib/audit')
37
46
  const data = parse(isbn)
38
47
  if (data) {
39
- if (format === '13') output(data.isbn13)
40
- else if (format === '10') output(data.isbn10)
41
- else if (format === '13h') output(data.isbn13h)
42
- else if (format === '10h') output(data.isbn10h)
48
+ if (format === '13') outputFormatIfExisting(data, 'isbn13')
49
+ else if (format === '10') outputFormatIfExisting(data, 'isbn10')
50
+ else if (format === '13h') outputFormatIfExisting(data, 'isbn13h')
51
+ else if (format === '10h') outputFormatIfExisting(data, 'isbn10h')
43
52
  else if (data[format]) output(data[format])
44
53
  else if (format === 'h') {
45
- if (data.isIsbn13) output(data.isbn13h)
46
- else output(data.isbn10h)
54
+ if (data.isIsbn13) outputFormatIfExisting(data, 'isbn13h')
55
+ else outputFormatIfExisting(data, 'isbn10h')
47
56
  } else if (format === 'n') {
48
- if (data.isIsbn13) output(data.isbn13)
49
- else output(data.isbn10)
57
+ if (data.isIsbn13) outputFormatIfExisting(data, 'isbn13')
58
+ else outputFormatIfExisting(data, 'isbn10')
50
59
  } else if (format === 'data' || format === 'd') {
51
60
  data.source = source
52
61
  output(JSON.stringify(data, null, 2) + '\n')
package/isbn.d.ts CHANGED
@@ -17,26 +17,33 @@ interface ISBNBase {
17
17
  article: string;
18
18
  check: string;
19
19
  groupname: string;
20
- }
21
20
 
22
- interface ISBN10 extends ISBNBase {
23
- isIsbn10: true;
24
- isIsbn13: false;
25
- check10: string;
26
- isbn10: string;
27
- isbn10h: string;
28
- }
21
+ // input related fields
22
+ isIsbn10: boolean;
23
+ isIsbn13: boolean;
29
24
 
30
- interface ISBN13 extends ISBNBase {
31
- isIsbn10: false;
32
- isIsbn13: true;
25
+ // isbn13 related fields
33
26
  prefix: string;
34
27
  check13: string;
35
28
  isbn13: string;
36
29
  isbn13h: string;
37
30
  }
38
31
 
39
- type ISBN = ISBN10 | ISBN13;
32
+ // ISBN-13 only (no ISBN-10 equivalent)
33
+ interface ISBN13Only extends ISBNBase {
34
+ isbn10: undefined;
35
+ check10: undefined;
36
+ isbn10h: undefined;
37
+ }
38
+
39
+ // ISBN-10 specific fields
40
+ interface ISBN13WithISBN10 extends ISBNBase {
41
+ isbn10: string;
42
+ check10: string;
43
+ isbn10h: string;
44
+ }
45
+
46
+ type ISBN = ISBN13WithISBN10 | ISBN13Only;
40
47
 
41
48
  declare module "isbn3" {
42
49
  export function parse(isbn: string): ISBN | null;
package/lib/groups.js CHANGED
@@ -1173,6 +1173,18 @@ module.exports = {
1173
1173
  '1300',
1174
1174
  '1799'
1175
1175
  ],
1176
+ [
1177
+ '180',
1178
+ '181'
1179
+ ],
1180
+ [
1181
+ '1830',
1182
+ '1899'
1183
+ ],
1184
+ [
1185
+ '19500',
1186
+ '19999'
1187
+ ],
1176
1188
  [
1177
1189
  '200',
1178
1190
  '459'
@@ -2028,7 +2040,7 @@ module.exports = {
2028
2040
  '649'
2029
2041
  ],
2030
2042
  [
2031
- '7000',
2043
+ '6850',
2032
2044
  '8199'
2033
2045
  ],
2034
2046
  [
@@ -4364,7 +4376,7 @@ module.exports = {
4364
4376
  '799'
4365
4377
  ],
4366
4378
  [
4367
- '8050',
4379
+ '8000',
4368
4380
  '9999'
4369
4381
  ]
4370
4382
  ]
@@ -7551,7 +7563,7 @@ module.exports = {
7551
7563
  '69'
7552
7564
  ],
7553
7565
  [
7554
- '900',
7566
+ '850',
7555
7567
  '999'
7556
7568
  ]
7557
7569
  ]
@@ -7942,6 +7954,10 @@ module.exports = {
7942
7954
  '90000',
7943
7955
  '90999'
7944
7956
  ],
7957
+ [
7958
+ '950000',
7959
+ '969999'
7960
+ ],
7945
7961
  [
7946
7962
  '9850000',
7947
7963
  '9899999'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "isbn3",
3
3
  "description": "ISBN utils: parse, validate, format, audit",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "authors": [
6
6
  "Hetappi <hetappi.pm@gmail.com>",
7
7
  "Tadas S. <tadas@yoyo.lt>",
@@ -34,7 +34,8 @@
34
34
  "isbn.d.ts",
35
35
  "lib",
36
36
  "bin",
37
- "scripts"
37
+ "scripts",
38
+ "CHANGELOG.md"
38
39
  ],
39
40
  "types": "isbn.d.ts",
40
41
  "engines": {