iwf
    Preparing search index...

    Class QuantitySnak

    Class for the QuantitySnak.

    Most used property of this type is P1215 (apparent magnitude).

    Hierarchy (View Summary)

    Index
    • Parameters

      • snak: {
            datatype?: "quantity";
            datavalue?: {
                type: "quantity";
                value: {
                    amount: string;
                    lowerBound?: string;
                    unit: string;
                    upperBound?: string;
                };
            };
            hash?: string;
            property: string;
            snaktype: "value"
            | "somevalue"
            | "novalue";
        }

        The snak for this class in JSON format.

      Returns QuantitySnak

      If the upperBound is smaller than the amount or the lowerBound is bigger than the amount.

      const snak = new QuantitySnak(json);
      
    datatype: string = dataType
    hash: string | undefined
    property: `P${number}`
    snaktype: "value" | "somevalue" | "novalue"
    unit: string

    The unit as a Wikidata entity URI, or '1' when the quantity has no unit. Snaks without a value (novalue/somevalue) default to '1'.

    • get amount(): number | undefined

      Returns number | undefined

      The amount of the quantity.

    • set amount(number: number | undefined): void

      Parameters

      • number: number | undefined

        The number that the amount will be set to.

      Returns void

    • get hasValue(): boolean

      Checks if the snak has a value.

      Returns boolean

      True if the snak has a value.

    • get internalID(): string

      Creates a unique ID for the Snak.

      Returns string

      The ID.

    • get lowerBound(): number | undefined

      Returns number | undefined

      The lowerBound of the quantity.

    • set lowerBound(number: number | undefined): void

      Parameters

      • number: number | undefined

        The number that the lowerBound will be set to.

      Returns void

    • get upperBound(): number | undefined

      Returns number | undefined

      The upperBound of the quantity.

    • set upperBound(number: number | undefined): void

      Parameters

      • number: number | undefined

        The number that the upperBound will be set to.

      Returns void

    • Returns the snak as JSON.

      Returns {
          datatype?: "quantity";
          datavalue?: {
              type: "quantity";
              value: {
                  amount: string;
                  lowerBound?: string;
                  unit: string;
                  upperBound?: string;
              };
          };
          hash?: string;
          property: string;
          snaktype: "value"
          | "somevalue"
          | "novalue";
      }

      The snak as JSON.

      const json = quantitySnak.toJSON();
      
    • Create a snak from some basic data.

      Parameters

      • property: `P${number}`

        The property of the snak in 'P-form'.

      • quantity: number

        Amount of the quantity.

      • OptionallowerBound: number | null

        LowerBound of the quantity.

      • OptionalupperBound: number | null

        UpperBound of the quantity.

      • Optionalunit: `Q${number}`

        Unit of the quantity.

      Returns QuantitySnak

      A snak with the given properties.

      const snak = QuantitySnak.fromNumbers('P1215', 1);