Skip to content

AIDC Toolkit / GS1 / GTINCreator

Class: GTINCreator ​

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

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

Extends ​

Properties ​

create ​

create: {(value, sparse?): string; (values, sparse?): Iterable<string>; }

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

Call Signature ​

(value, sparse?): string

Create an identifier with a reference based on a numeric value. The value is converted to a reference of the appropriate length using NUMERIC_CREATOR.

Parameters ​
value ​

number | bigint

Numeric value.

sparse? ​

boolean

If true, the value is mapped to a sparse sequence resistant to discovery.

Returns ​

string

Identifier.

Call Signature ​

(values, sparse?): Iterable<string>

Create identifiers with references based on numeric values. The values are converted to references of the appropriate length using NUMERIC_CREATOR.

Parameters ​
values ​

Iterable<number | bigint>

Numeric values.

sparse? ​

boolean

If true, the values are mapped to a sparse sequence resistant to discovery.

Returns ​

Iterable<string>

Identifiers.

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).create


createAll ​

createAll: () => Iterable<string>

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

Create all identifiers for the prefix from 0 to capacity - 1.

The implementation creates the strings only as needed using an internal generator function. Although the result is equivalent to calling creator.create(new Sequence(0, creator.capacity)), this method is significantly faster.

Returns ​

Iterable<string>

All identifiers for the prefix.

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).createAll

Constructors ​

Constructor ​

new GTINCreator(prefixProvider, gtinBaseLength): GTINCreator

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

Constructor.

Parameters ​

prefixProvider ​

PrefixProvider

Prefix provider.

gtinBaseLength ​

GTINBaseLength

GTIN base length (all except GTIN-14).

Returns ​

GTINCreator

Overrides ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).constructor

Accessors ​

prefix ​

Get Signature ​

get prefix(): string

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

Inherit Doc ​
Returns ​

string

Overrides ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).prefix


prefixType ​

Get Signature ​

get prefixType(): PrefixType

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

Inherit Doc ​
Returns ​

PrefixType

Inherited from ​

GTINValidator.prefixType


leaderType ​

Get Signature ​

get leaderType(): IdentifierTypeDescriptor<TNumericIdentifierType>["leaderType"]

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

Inherit Doc ​
Returns ​

IdentifierTypeDescriptor<TNumericIdentifierType>["leaderType"]

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).leaderType


identifierType ​

Get Signature ​

get identifierType(): IdentifierTypeDescriptor<TIdentifierType>["identifierType"]

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

Get the identifier type. Per the GS1 General Specifications, the identifier type determines the remaining properties.

Returns ​

IdentifierTypeDescriptor<TIdentifierType>["identifierType"]

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).identifierType


length ​

Get Signature ​

get length(): IdentifierTypeDescriptor<TIdentifierType>["length"]

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

Get the length. For numeric identifier types, the length is fixed; for alphanumeric identifier types, the length is the maximum.

Returns ​

IdentifierTypeDescriptor<TIdentifierType>["length"]

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).length


referenceCharacterSet ​

Get Signature ​

get referenceCharacterSet(): IdentifierTypeDescriptor<TIdentifierType>["referenceCharacterSet"]

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

Get the reference character set.

Returns ​

IdentifierTypeDescriptor<TIdentifierType>["referenceCharacterSet"]

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).referenceCharacterSet


referenceCreator ​

Get Signature ​

get referenceCreator(): CharacterSetCreator

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

Get the reference creator.

Returns ​

CharacterSetCreator

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).referenceCreator


capacity ​

Get Signature ​

get capacity(): number

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

Get the capacity (10**referenceLength).

Returns ​

number

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).capacity


tweak ​

Get Signature ​

get tweak(): bigint

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

Get the tweak for sparse creation.

Returns ​

bigint

Set Signature ​

set tweak(value): void

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

Set the tweak for sparse creation.

Parameters ​
value ​

bigint

Returns ​

void

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).tweak


prefixProvider ​

Get Signature ​

get prefixProvider(): PrefixProvider

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

Get the prefix provider to which this identifier creator is bound.

Returns ​

PrefixProvider

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).prefixProvider


referenceLength ​

Get Signature ​

get referenceLength(): number

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

Get the reference length.

Returns ​

number

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).referenceLength

Methods ​

createGTIN14() ​

Call Signature ​

createGTIN14(indicatorDigit, value, sparse?): string

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

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

Parameters ​
indicatorDigit ​

string

Indicator digit.

value ​

number | bigint

Numeric value.

sparse? ​

boolean

If true, the value is mapped to a sparse sequence resistant to discovery.

Returns ​

string

GTIN-14.

Call Signature ​

createGTIN14(indicatorDigit, values, sparse?): Iterable<string>

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

Create GTIN-14s with an indicator digit and references based on numeric values. The values are converted to references of the appropriate length using NUMERIC_CREATOR.

Parameters ​
indicatorDigit ​

string

Indicator digit.

values ​

Iterable<number | bigint>

Numeric values.

sparse? ​

boolean

If true, the values are mapped to a sparse sequence resistant to discovery.

Returns ​

Iterable<string>

GTIN-14s.


validatePrefix() ​

protected validatePrefix(partialIdentifier): void

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

Parameters ​

partialIdentifier ​

string

Returns ​

void

Inherit Doc ​

Inherited from ​

GTINValidator.validatePrefix


validate() ​

validate(identifier, validation?): void

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

Parameters ​

identifier ​

string

validation? ​

NumericIdentifierValidation

Returns ​

void

Inherit Doc ​

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).validate


padIdentifier() ​

protected padIdentifier(identifier, positionOffset?): string

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

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.

positionOffset? ​

number

Position offset within a larger string.

Returns ​

string

Padded identifier.

Inherited from ​

MixinAbstractNumericIdentifierCreator< GTINType >(GTINValidator).padIdentifier