Skip to content

AIDC Toolkit / GS1 / GTINCreator

Class: GTINCreator

Defined in: src/gtin-creator.ts:18

GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.

Extends

Constructors

Constructor

new GTINCreator(prefixProvider, gtinType): GTINCreator

Defined in: src/gtin-creator.ts:38

Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix provider type.

Parameters

prefixProvider

PrefixProvider

Prefix provider.

gtinType

GTINType

GTIN type.

Returns

GTINCreator

Overrides

Mixin(GTINValidator, AbstractNumericIdentifierCreator).constructor

Accessors

prefix

Get Signature

get prefix(): string

Defined in: src/gtin-creator.ts:47

Inherit Doc
Returns

string

Overrides

Mixin(GTINValidator, AbstractNumericIdentifierCreator).prefix


gtinType

Get Signature

get gtinType(): GTINType

Defined in: src/gtin-validator.ts:134

Inherit Doc
Returns

GTINType

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).gtinType


leaderType

Get Signature

get leaderType(): string

Defined in: src/numeric-identifier-validator.ts:100

Inherit Doc
Returns

string

Inherited from

AbstractNumericIdentifierValidator.leaderType


identifierType

Get Signature

get identifierType(): IdentifierType

Defined in: src/identifier-validator.ts:170

Inherit Doc
Returns

IdentifierType

Inherited from

AbstractIdentifierValidator.identifierType


prefixType

Get Signature

get prefixType(): PrefixType

Defined in: src/identifier-validator.ts:177

Inherit Doc
Returns

PrefixType

Inherited from

AbstractIdentifierValidator.prefixType


length

Get Signature

get length(): number

Defined in: src/identifier-validator.ts:184

Inherit Doc
Returns

number

Inherited from

AbstractIdentifierValidator.length


referenceCharacterSet

Get Signature

get referenceCharacterSet(): ContentCharacterSet

Defined in: src/identifier-validator.ts:191

Inherit Doc
Returns

ContentCharacterSet

Inherited from

AbstractIdentifierValidator.referenceCharacterSet


referenceCreator

Get Signature

get referenceCreator(): CharacterSetCreator

Defined in: src/identifier-validator.ts:198

Inherit Doc
Returns

CharacterSetCreator

Inherited from

AbstractIdentifierValidator.referenceCreator


capacity

Get Signature

get capacity(): number

Defined in: src/numeric-identifier-creator.ts:89

Inherit Doc
Returns

number

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).capacity


tweak

Get Signature

get tweak(): bigint

Defined in: src/numeric-identifier-creator.ts:96

Get the tweak for sparse creation.

Returns

bigint

Set Signature

set tweak(value): void

Defined in: src/numeric-identifier-creator.ts:103

Set the tweak for sparse creation.

Parameters
value

bigint

Returns

void

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).tweak


prefixProvider

Get Signature

get prefixProvider(): PrefixProvider

Defined in: src/identifier-creator.ts:78

Inherit Doc
Returns

PrefixProvider

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).prefixProvider


referenceLength

Get Signature

get referenceLength(): number

Defined in: src/identifier-creator.ts:92

Inherit Doc
Returns

number

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).referenceLength

Methods

createVariableMeasureRCN()

static createVariableMeasureRCN(format, itemReference, priceOrWeight): string

Defined in: src/gtin-creator.ts:96

Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See GTINValidator.parseVariableMeasureRCN for format details.

Parameters

format

string

Format.

itemReference

number

Item reference.

priceOrWeight

number

Price or weight (whole number only).

Returns

string

RCN-12 or RCN-13.


zeroSuppress()

static zeroSuppress(gtin12): string

Defined in: src/gtin-validator.ts:156

Zero suppress a GTIN-12.

Parameters

gtin12

string

GTIN-12.

Returns

string

Zero-suppressed GTIN-12.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).zeroSuppress


zeroExpand()

static zeroExpand(zeroSuppressedGTIN12): string

Defined in: src/gtin-validator.ts:193

Zero expand a zero-suppressed GTIN-12.

Parameters

zeroSuppressedGTIN12

string

Zero-suppressed GTIN-12.

Returns

string

GTIN-12.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).zeroExpand


convertToGTIN14()

static convertToGTIN14(indicatorDigit, gtin): string

Defined in: src/gtin-validator.ts:236

Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.

Parameters

indicatorDigit

string

Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.

gtin

string

GTIN.

Returns

string

GTIN-14.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).convertToGTIN14


normalize()

static normalize(gtin): string

Defined in: src/gtin-validator.ts:267

Normalize a GTIN of any length.

  • A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
  • A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
  • A GTIN-14 that starts with one zero is normalized to GTIN-13.
  • Otherwise, the GTIN is unchanged.

Parameters

gtin

string

GTIN.

Returns

string

Normalized GTIN.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).normalize


validateAny()

static validateAny(gtin, gtinLevel): void

Defined in: src/gtin-validator.ts:340

Validate any GTIN, optionally against a level.

Parameters

gtin

string

GTIN.

gtinLevel

GTINLevel = GTINLevels.Any

Level at which GTIN is to be validated.

Returns

void

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).validateAny


validateGTIN14()

static validateGTIN14(gtin14): void

Defined in: src/gtin-validator.ts:405

Validate a GTIN-14.

Parameters

gtin14

string

GTIN-14.

Returns

void

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).validateGTIN14


parseVariableMeasureRCN()

static parseVariableMeasureRCN(format, rcn): RCNReference

Defined in: src/gtin-validator.ts:444

Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or 13-character string (for RCN-12 or RCN-13 respectively), containing the following:

  • '2' - The first character of the RCN.
  • '0'-'9' - The second character of the RCN (RCN-13 only).
  • 'I' - One or more, in sequence, for the item reference.
  • 'P' - One or more, in sequence, for the price or weight.
  • 'V' - Zero or one, for the price or weight check digit.
  • 'C' - The check digit of the entire RCN.

The 'I', 'P', and 'V' formats may be in any order.

Some examples:

  • 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price or weight.
  • 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price or weight.
  • 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
  • 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.

Parameters

format

string

Format.

rcn

string

RCN.

Returns

RCNReference

RCN reference.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).parseVariableMeasureRCN


creatorFor()

protected static creatorFor(characterSet): CharacterSetCreator

Defined in: src/identifier-validator.ts:140

Get the character set creator for a character set.

Parameters

characterSet

ContentCharacterSet

Character set.

Returns

CharacterSetCreator

Character set creator.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).creatorFor


createGTIN14()

createGTIN14<TTransformerInput>(indicatorDigit, valueOrValues, sparse): TransformerOutput<TTransformerInput, string>

Defined in: src/gtin-creator.ts:70

Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are converted to reference(s) of the appropriate length using NUMERIC_CREATOR.

Type Parameters

TTransformerInput

TTransformerInput extends TransformerInput<number | bigint>

Transformer input type.

Parameters

indicatorDigit

string

Indicator digit.

valueOrValues

TTransformerInput

Numeric value(s).

sparse

boolean = false

If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.

Returns

TransformerOutput<TTransformerInput, string>

GTIN-14(s).


validatePrefix()

protected validatePrefix(partialIdentifier, positionOffset?): void

Defined in: src/gtin-validator.ts:142

Parameters

partialIdentifier

string

positionOffset?

number

Returns

void

Inherit Doc

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).validatePrefix


validate()

validate(identifier, validation?): void

Defined in: src/numeric-identifier-validator.ts:107

Parameters

identifier

string

validation?

IdentifierValidation

Returns

void

Inherit Doc

Inherited from

AbstractNumericIdentifierValidator.validate


padIdentifier()

protected padIdentifier(identifier, validation): string

Defined in: src/identifier-validator.ts:215

Pad an identifier on the left with zero-value character for validation purposes. This is done to align an identifier with a position offset for any error message that may be thrown by the reference validator.

Parameters

identifier

string

Identifier.

validation

Identifier validation parameters.

IdentifierValidation | undefined

Returns

string

Padded identifier.

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).padIdentifier


init()

protected init(prefixProvider, prefix): void

Defined in: src/numeric-identifier-creator.ts:77

Initialize the prefix provider. This method is in lieu of a constructor due to the mixin architecture.

Parameters

prefixProvider

PrefixProvider

Prefix provider.

prefix

string

Prefix within prefix manager to use to calculate reference length.

Returns

void

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).init


create()

create<TTransformerInput>(valueOrValues, sparse): TransformerOutput<TTransformerInput, string>

Defined in: src/numeric-identifier-creator.ts:125

Type Parameters

TTransformerInput

TTransformerInput extends TransformerInput<number | bigint>

Parameters

valueOrValues

TTransformerInput

sparse

boolean = false

Returns

TransformerOutput<TTransformerInput, string>

Inherit Doc

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).create


createAll()

createAll(): Iterable<string>

Defined in: src/numeric-identifier-creator.ts:184

Returns

Iterable<string>

Inherit Doc

Inherited from

Mixin(GTINValidator, AbstractNumericIdentifierCreator).createAll