This package has been deprecated

Author message:

This package has been moved to @w0s/isbn-verify

@saekitominaga/isbn-verify
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Verify ISBN string format and check digit

npm version test status

Examples

import IsbnVerify from '@saekitominaga/isbn-verify';

const isbnVerify1 = new IsbnVerify('978-4-06-519981-0'); // ISBN with correct format but wrong check digit
isbnVerify1.isValid(); // false
isbnVerify1.isIsbn10(); // false
isbnVerify1.isIsbn10({ check_digit: true }); // false
isbnVerify1.isIsbn13(); // true
isbnVerify1.isIsbn13({ check_digit: true }); // false
isbnVerify1.verify(); // true
isbnVerify1.verify({ check_digit: true }); // false

const isbnVerify2 = new IsbnVerify('9784065199817');
isbnVerify2.isValid(); // true

const isbnVerify3 = new IsbnVerify('9784065199817', { strict: true });
isbnVerify3.isValid(); // false

Constructor

new IsbnVerify(isbn: string, options?: Option)

Parameters

isbn [Required]
ISBN value
options [Optional]
See below for details

Option

interface Option {
	strict?: boolean; // If `true`, syntax without hyphens is an error. If not specified, it defaults to `false`
}

Methods

isValid(): boolean
Verify both format and check digit (Alias of verify({ check_digit: true }))
isIsbn13(options?: VerifyOption): boolean
Whether it is a current standard (13 digit) ISBN or not
isIsbn10(options?: VerifyOption): boolean
Whether it is a old standard (10 digit) ISBN or not
verify(options?: VerifyOption): boolean
Verify format, optionally check digit

Option

interface VerifyOption {
	check_digit?: boolean; // Verify format including check digit
}

Readme

Keywords

Package Sidebar

Install

npm i @saekitominaga/isbn-verify

Weekly Downloads

71

Version

2.0.2

License

MIT

Unpacked Size

46.7 kB

Total Files

7

Last publish

Collaborators

  • saekitominaga