isbn3 1.2.1 → 1.2.2
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/bin/isbn-checksum +6 -1
- package/package.json +1 -1
package/bin/isbn-checksum
CHANGED
|
@@ -8,7 +8,12 @@ else if (normalized.length === 13) normalized = normalized.substring(0, 12)
|
|
|
8
8
|
const calculateCheckDigit = require('../lib/calculate_check_digit')
|
|
9
9
|
const parse = require('../lib/parse')
|
|
10
10
|
const checksum = calculateCheckDigit(normalized)
|
|
11
|
-
const
|
|
11
|
+
const isbnData = parse(`${normalized}${checksum}`)
|
|
12
|
+
if (isbnData == null) {
|
|
13
|
+
process.stderr.write('invalid ISBN despite recalculated checksum\n')
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
const { isbn13h } = isbnData
|
|
12
17
|
|
|
13
18
|
if (option === 'c') {
|
|
14
19
|
process.stdout.write(checksum)
|