forked from inventaire/isbn3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisbn.js
More file actions
28 lines (25 loc) · 692 Bytes
/
isbn.js
File metadata and controls
28 lines (25 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const parse = require('./lib/parse')
const audit = require('./lib/audit')
module.exports = {
parse,
audit,
hyphenate: val => {
const data = parse(val)
if (!data) return null
return data.isIsbn13 ? data.isbn13h : data.isbn10h
},
asIsbn13: (val, hyphen) => {
const data = parse(val)
if (!data) return null
return hyphen ? data.isbn13h : data.isbn13
},
asIsbn10: (val, hyphen) => {
const data = parse(val)
if (!data) return null
// Return null for cases where it shouldn't map to an ISBN 10
// ex: 979-10-91146-13-5
if (!data.isbn10) return null
return hyphen ? data.isbn10h : data.isbn10
},
groups: require('./lib/groups')
}