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

Hierarchy

  • GTINValidator<this> & AbstractNumericIdentificationKeyCreator<this>
    • GTINCreator

Properties

leaderType: LeaderType
identificationKeyType: IdentificationKeyType
prefixType: PrefixType
length: number
referenceCharacterSet: CharacterSet
referenceValidator: CharacterSetValidator

Constructors

Accessors

  • get prefix(): string
  • Returns string

  • get gtinType(): GTINType
  • Returns GTINType

  • get capacity(): number
  • Returns number

  • get tweak(): bigint
  • Get the tweak for sparse creation.

    Returns bigint

  • set tweak(value): void
  • Set the tweak for sparse creation.

    Parameters

    • value: bigint

    Returns void

  • get referenceLength(): number
  • Returns number

Methods

  • Zero suppress a GTIN-12.

    Parameters

    • gtin12: string

      GTIN-12.

    Returns string

    Zero-suppressed GTIN-12.

  • 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.

  • 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.

  • Zero expand a zero-suppressed GTIN-12.

    Parameters

    • zeroSuppressedGTIN12: string

      Zero-suppressed GTIN-12.

    Returns string

    GTIN-12.

  • Validate any GTIN, optionally against a level.

    Parameters

    • gtin: string

      GTIN.

    • gtinLevel: GTINLevel = GTINLevel.Any

      Level at which GTIN is to be validated.

    Returns void

  • Validate a GTIN-14.

    Parameters

    • gtin14: string

      GTIN-14.

    Returns void

  • Pad an identification key on the left with zeroes for validation purposes. This is done to align an identification key with a position offset for any error message that may be thrown by the reference validator.

    Parameters

    • identificationKey: string

      Identification key.

    • validation: undefined | IdentificationKeyValidation

      Identification key validation parameters.

    Returns string

    Padded identification key.

  • Create a GTIN-14 with an indicator digit and a 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 of the reference.

    • Optionalsparse: boolean

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

    Returns string

    GTIN-14.

  • Create multiple 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.

    The implementation uses CharacterSetCreator.create, so the values are created only as needed.

    Parameters

    • indicatorDigit: string

      Indicator digit.

    • values: Iterable<number | bigint, any, any>

      Values.

    • Optionalsparse: boolean

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

    Returns IterableIterator<string, any, any>

    Iterable iterator over created GTIN-14s.

  • Parameters

    • partialIdentificationKey: string
    • OptionalpositionOffset: number

    Returns void

  • Parameters

    Returns void

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

    Parameters

    • prefixManager: PrefixManager

      Prefix manager.

    • prefix: string

      Prefix within prefix manager to use to calculate reference length.

    Returns void

  • Parameters

    • value: number | bigint
    • Optionalsparse: boolean

    Returns string

  • Parameters

    • values: Iterable<number | bigint, any, any>
    • Optionalsparse: boolean

    Returns IterableIterator<string, any, any>

  • Returns IterableIterator<string, any, any>