Skip to content

avram/identifiers-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

JavaScript parsing of various useful identifiers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published