Interface NumericIdentificationKeyCreator

Numeric identification key creator. Creates one or many numeric identification keys.

interface NumericIdentificationKeyCreator {
    get capacity(): number;
    create: <TTransformerInput extends TransformerInput<number | bigint>>(
        valueOrValues: TTransformerInput,
        sparse?: boolean,
    ) => TransformerOutput<TTransformerInput, string>;
    createAll: () => Iterable<string>;
    get leaderType(): LeaderType;
    get identificationKeyType(): IdentificationKeyType;
    get prefixType(): PrefixType;
    get length(): number;
    get referenceCharacterSet(): ContentCharacterSet;
    get referenceCreator(): CharacterSetCreator;
    validate: (
        identificationKey: string,
        validation?: IdentificationKeyValidation,
    ) => void;
    get prefixManager(): PrefixManager;
    get prefix(): string;
    get referenceLength(): number;
}

Hierarchy (View Summary)

Properties

create: <TTransformerInput extends TransformerInput<number | bigint>>(
    valueOrValues: TTransformerInput,
    sparse?: boolean,
) => TransformerOutput<TTransformerInput, string>

Create identification key(s) with reference(s) based on numeric value(s). The value(s) is/are converted to references of the appropriate length using NUMERIC_CREATOR.

Type declaration

createAll: () => Iterable<string>

Create all identification keys 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.

Type declaration

    • (): Iterable<string>
    • Returns Iterable<string>

      All identification keys for the prefix.

validate: (
    identificationKey: string,
    validation?: IdentificationKeyValidation,
) => void

Validate an identification key and throw an error if validation fails.

Type declaration

Accessors

  • get capacity(): number
  • Get the capacity (10**referenceLength).

    Returns number

  • get identificationKeyType(): IdentificationKeyType
  • Get the identification key type. Per the GS1 General Specifications, the identification key type determines the remaining properties.

    Returns IdentificationKeyType

  • get prefixType(): PrefixType
  • Get the prefix type supported by the identification key type. For all identification key types except the GTIN, this is PrefixType.GS1CompanyPrefix. For the GTIN, the prefix type determines the length.

    Returns PrefixType

  • get length(): number
  • Get the length. For numeric identification key types, the length is fixed; for alphanumeric identification key types, the length is the maximum.

    Returns number

  • get prefixManager(): PrefixManager
  • Get the prefix manager to which this identification key creator is bound.

    Returns PrefixManager

  • get referenceLength(): number
  • Get the reference length.

    Returns number