-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
44 lines (34 loc) · 1.83 KB
/
README
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
JavaScript parsing of various identifiers
Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm)
and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number)
and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number)
and the Wikipedia treatment of SICI (http://en.wikipedia.org/wiki/Serial_Item_and_Contribution_Identifier)
This will also check ISMN validity, although it does not distinguish from their
neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs;
see http://en.wikipedia.org/wiki/International_Standard_Music_Number
This does not validate multiple identifiers in one field,
but it will gracefully ignore all non-number detritus,
such as extraneous hyphens, spaces, and comments.
It currently maintains hyphens in non-initial and non-final position,
discarding consecutive ones beyond the first as well.
It also adds the customary hyphen to valid ISSNs.
Takes the first 8 valid digits and tries to read an ISSN,
takes the first 10 valid digits and tries to read an ISBN 10 or a UPC,
and takes the first 13 valid digits to try to read an ISBN 13 or an EAN.
It also tries to parse the input as an SICI; if found, it will populate the
SICI attribute with the proper SICI and the ISSN with the constituent ISSN.
A later version will return the other metadata encoded by SICI as well.
Returns an object with six attributes:
"issn"
"isbn10"
"isbn13"
"upc"
"ean"
"sici"
Each will be set to a valid identifier if found, and otherwise be a
boolean false.
The UPC logic is for a 10-digit UPC-A; the newer EAN system is equivalent
to the isbn13 algorithm.
There could conceivably be a valid ISBN-13 with an ISBN-10
substring; this should probably be interpreted as the latter, but it is a
client UI issue.