From e4cea08bb9dabc4fe45dfa92df9aacc3a7483bec Mon Sep 17 00:00:00 2001 From: Nael Shiab Date: Thu, 15 Aug 2024 08:23:46 -0400 Subject: [PATCH] Updating doc --- docs/functions/adjustToInflation.html | 4 ++-- docs/functions/arraysToData.html | 4 ++-- docs/functions/camelCase.html | 4 ++-- docs/functions/capitalize.html | 4 ++-- docs/functions/createDirectory.html | 4 ++-- docs/functions/dataAsCsv.html | 4 ++-- docs/functions/dataToArrays.html | 4 ++-- docs/functions/distance.html | 4 ++-- docs/functions/downloadFile.html | 4 ++-- docs/functions/formatDate.html | 4 ++-- docs/functions/formatNumber.html | 4 ++-- docs/functions/geoTo3D.html | 4 ++-- docs/functions/getClosest.html | 4 ++-- docs/functions/getGeoTiffDetails.html | 4 ++-- docs/functions/getGeoTiffValues.html | 4 ++-- docs/functions/getHtmlTable.html | 4 ++-- docs/functions/getHumidex.html | 4 ++-- docs/functions/getId.html | 4 ++-- docs/functions/getSeason.html | 4 ++-- docs/functions/getSheetData.html | 4 ++-- docs/functions/getStatCanTable.html | 4 ++-- docs/functions/mortgageInsurancePremium.html | 4 ++-- docs/functions/mortgageMaxAmount.html | 4 ++-- docs/functions/mortgagePayments.html | 4 ++-- docs/functions/overwriteSheetData.html | 4 ++-- docs/functions/prettyDuration.html | 4 ++-- docs/functions/publishChartDW.html | 4 ++-- docs/functions/round.html | 4 ++-- docs/functions/savePlotChart.html | 4 ++-- docs/functions/styledLayerDescriptor.html | 4 ++-- docs/functions/unzip.html | 4 ++-- docs/functions/updateAnnotationsDW.html | 4 ++-- docs/functions/updateDataDW.html | 4 ++-- docs/functions/updateNotesDW.html | 4 ++-- docs/functions/zip.html | 4 ++-- docs/index.html | 4 ++-- 36 files changed, 72 insertions(+), 72 deletions(-) diff --git a/docs/functions/adjustToInflation.html b/docs/functions/adjustToInflation.html index 476c5716..6e07eb3b 100644 --- a/docs/functions/adjustToInflation.html +++ b/docs/functions/adjustToInflation.html @@ -1,5 +1,5 @@ -adjustToInflation | Journalism - v1.14.1

Function adjustToInflation

  • Compute the adjusted to inflation amount of money, based on the Consumer Price Index. The options (last parameter) are optional.

    +adjustToInflation | Journalism - v1.14.2

    Function adjustToInflation

    • Compute the adjusted to inflation amount of money, based on the Consumer Price Index. The options (last parameter) are optional.

      // $100 in 1914 (CPI of 6.0) to 2023 value (CPI of 156.4)
      const adjustedAmount = adjustToInflation(100, 6.0, 156.4, { decimals: 0 })
      // returns 2607 dollars
      -

      Parameters

      • amount: number
      • amountCPI: number
      • targetCPI: number
      • options: {
            decimals?: number;
        } = {}
        • Optionaldecimals?: number

      Returns number

    +

    Parameters

    • amount: number
    • amountCPI: number
    • targetCPI: number
    • options: {
          decimals?: number;
      } = {}
      • Optionaldecimals?: number

    Returns number

diff --git a/docs/functions/arraysToData.html b/docs/functions/arraysToData.html index b7cbb164..e2784143 100644 --- a/docs/functions/arraysToData.html +++ b/docs/functions/arraysToData.html @@ -1,4 +1,4 @@ -arraysToData | Journalism - v1.14.1

Function arraysToData

  • Returns an array of objects from an object made of arrays.

    +arraysToData | Journalism - v1.14.2

    Function arraysToData

    • Returns an array of objects from an object made of arrays.

      For example, this data...

      {
      keyA: ["a", "b", "c"],
      keyB: [1, 2, 3],
      }
      @@ -7,4 +7,4 @@
      [
      { keyA: "a", keyB: 1 },
      { keyA: "b", keyB: 2 },
      { keyA: "c", keyB: 3 },
      ]
      -

      Parameters

      • data: {
            [key: string]: unknown[];
        }
        • [key: string]: unknown[]

      Returns {
          [key: string]: unknown;
      }[]

    +

    Parameters

    • data: {
          [key: string]: unknown[];
      }
      • [key: string]: unknown[]

    Returns {
        [key: string]: unknown;
    }[]

diff --git a/docs/functions/camelCase.html b/docs/functions/camelCase.html index 652c4630..d3f2ae09 100644 --- a/docs/functions/camelCase.html +++ b/docs/functions/camelCase.html @@ -1,5 +1,5 @@ -camelCase | Journalism - v1.14.1

Function camelCase

  • Formats a string to camel case.

    +camelCase | Journalism - v1.14.2

    Function camelCase

    • Formats a string to camel case.

      // Returns journalismIsAwesome
      const text = camelCase("Journalism is awesome")
      -

      Parameters

      • input: string

      Returns string

    +

    Parameters

    • input: string

    Returns string

diff --git a/docs/functions/capitalize.html b/docs/functions/capitalize.html index 355afc1b..090fbba4 100644 --- a/docs/functions/capitalize.html +++ b/docs/functions/capitalize.html @@ -1,5 +1,5 @@ -capitalize | Journalism - v1.14.1

Function capitalize

  • Capitalizes the first character of a string.

    +capitalize | Journalism - v1.14.2

    Function capitalize

    • Capitalizes the first character of a string.

      // Returns 'Journalism'.
      const text = capitalize('journalism')
      -

      Parameters

      • string: string

      Returns string

    +

    Parameters

    • string: string

    Returns string

diff --git a/docs/functions/createDirectory.html b/docs/functions/createDirectory.html index 20abcb2d..3423aeca 100644 --- a/docs/functions/createDirectory.html +++ b/docs/functions/createDirectory.html @@ -1,5 +1,5 @@ -createDirectory | Journalism - v1.14.1

Function createDirectory

  • Creates folders recursively if they don't exist.

    +createDirectory | Journalism - v1.14.2

    Function createDirectory

    • Creates folders recursively if they don't exist.

      // Creates folders if they don't exist
      createDirectory("./data/json")

      // This will give the same result. A file with an extension at the end of the path will be ignored.
      createDirectory("./data/json/items.json")
      -

      Parameters

      • path: string

      Returns void

    +

    Parameters

    • path: string

    Returns void

diff --git a/docs/functions/dataAsCsv.html b/docs/functions/dataAsCsv.html index 0ebd3878..1762501f 100644 --- a/docs/functions/dataAsCsv.html +++ b/docs/functions/dataAsCsv.html @@ -1,5 +1,5 @@ -dataAsCsv | Journalism - v1.14.1

Function dataAsCsv

  • Convert an array of objects into CSV format.

    +dataAsCsv | Journalism - v1.14.2

    Function dataAsCsv

    • Convert an array of objects into CSV format.

      const data = [
      { firstName: "Graeme", lastName: "Bruce" },
      { firstName: "Nael", lastName: "Shiab" },
      ]

      const csv = dataAsCsv(data)
      // Returns "firstName,lastName\nGraeme,Bruce\nNael,Shiab"
      -

      Parameters

      • arrayOfObjects: {
            [key: string]: unknown;
        }[]

      Returns string

    +

    Parameters

    • arrayOfObjects: {
          [key: string]: unknown;
      }[]

    Returns string

diff --git a/docs/functions/dataToArrays.html b/docs/functions/dataToArrays.html index 4e8c4ee7..a43c8841 100644 --- a/docs/functions/dataToArrays.html +++ b/docs/functions/dataToArrays.html @@ -1,4 +1,4 @@ -dataToArrays | Journalism - v1.14.1

Function dataToArrays

  • Returns an object made of arrays from an array of objects.

    +dataToArrays | Journalism - v1.14.2

    Function dataToArrays

    • Returns an object made of arrays from an array of objects.

      For example, this data...

      [
      { keyA: "a", keyB: 1 },
      { keyA: "b", keyB: 2 },
      { keyA: "c", keyB: 3 },
      ]
      @@ -7,4 +7,4 @@
      {
      keyA: ["a", "b", "c"],
      keyB: [1, 2, 3],
      }
      -

      Parameters

      • data: {
            [key: string]: unknown;
        }[]

      Returns {
          [key: string]: unknown[];
      }

      • [key: string]: unknown[]
    +

    Parameters

    • data: {
          [key: string]: unknown;
      }[]

    Returns {
        [key: string]: unknown[];
    }

    • [key: string]: unknown[]
diff --git a/docs/functions/distance.html b/docs/functions/distance.html index dc3d2aae..75a80fd4 100644 --- a/docs/functions/distance.html +++ b/docs/functions/distance.html @@ -1,5 +1,5 @@ -distance | Journalism - v1.14.1

Function distance

  • Compute the distance in kilometres based on longitude and latitude. The options (last parameter) are optional.

    +distance | Journalism - v1.14.2

    Function distance

    • Compute the distance in kilometres based on longitude and latitude. The options (last parameter) are optional.

      const distance = distance(-73.66, 45.51, -79.43, 43.66, { decimals: 0 })
      // returns 501
      -

      Parameters

      • lon1: number
      • lat1: number
      • lon2: number
      • lat2: number
      • options: {
            decimals?: number;
        } = {}
        • Optionaldecimals?: number

      Returns number

    +

    Parameters

    • lon1: number
    • lat1: number
    • lon2: number
    • lat2: number
    • options: {
          decimals?: number;
      } = {}
      • Optionaldecimals?: number

    Returns number

diff --git a/docs/functions/downloadFile.html b/docs/functions/downloadFile.html index 8bee029d..56cf59fa 100644 --- a/docs/functions/downloadFile.html +++ b/docs/functions/downloadFile.html @@ -1,5 +1,5 @@ -downloadFile | Journalism - v1.14.1

Function downloadFile

  • Downloads a file.

    +downloadFile | Journalism - v1.14.2

    Function downloadFile

    • Downloads a file.

      await dowloadFile("http://some-website.com/data.csv", "./downloads/data.csv" )
       
      -

      Parameters

      • url: string
      • filePath: string

      Returns Promise<void>

    +

    Parameters

    • url: string
    • filePath: string

    Returns Promise<void>

diff --git a/docs/functions/formatDate.html b/docs/functions/formatDate.html index c20ee714..24af23cc 100644 --- a/docs/functions/formatDate.html +++ b/docs/functions/formatDate.html @@ -1,6 +1,6 @@ -formatDate | Journalism - v1.14.1

Function formatDate

  • Format a Date as a string with a specific format and a specific style. To format as UTC Date, set the utc option to true.

    +formatDate | Journalism - v1.14.2

    Function formatDate

    • Format a Date as a string with a specific format and a specific style. To format as UTC Date, set the utc option to true.

      const date = new Date("2023-01-01T01:35:00.000Z")
      const string = formatDate(date, "Month DD, YYYY, at HH:MM period", { utc: true, abbreviations: true })
      // returns "Jan. 1, 2023, at 1:35 p.m."

      Options can be passed as the last parameter. Pass {style: "rc"} to parse dates in French.

      -

      Parameters

      • date: Date
      • format:
            | "YYYY-MM-DD"
            | "YYYY-MM-DD HH:MM:SS TZ"
            | "DayOfWeek, Month Day"
            | "Month DD"
            | "Month DD, HH:MM period"
            | "Month DD, HH:MM period TZ"
            | "DayOfWeek, HH:MM period"
            | "DayOfWeek, HH:MM period TZ"
            | "Month DD, YYYY"
            | "Month DD, YYYY, at HH:MM period"
            | "Month DD, YYYY, at HH:MM period TZ"
            | "DayOfWeek"
            | "Month"
            | "YYYY"
            | "MM"
            | "DD"
            | "HH:MM period"
            | "HH:MM period TZ"
      • options: {
            abbreviations?: boolean;
            noZeroPadding?: boolean;
            style?: "cbc" | "rc";
            timeZone?:
                | "Canada/Atlantic"
                | "Canada/Central"
                | "Canada/Eastern"
                | "Canada/Mountain"
                | "Canada/Newfoundland"
                | "Canada/Pacific"
                | "Canada/Saskatchewan"
                | "Canada/Yukon";
            utc?: boolean;
        } = {}
        • Optionalabbreviations?: boolean
        • OptionalnoZeroPadding?: boolean
        • Optionalstyle?: "cbc" | "rc"
        • OptionaltimeZone?:
              | "Canada/Atlantic"
              | "Canada/Central"
              | "Canada/Eastern"
              | "Canada/Mountain"
              | "Canada/Newfoundland"
              | "Canada/Pacific"
              | "Canada/Saskatchewan"
              | "Canada/Yukon"
        • Optionalutc?: boolean

      Returns string

    +

    Parameters

    • date: Date
    • format:
          | "YYYY-MM-DD"
          | "YYYY-MM-DD HH:MM:SS TZ"
          | "DayOfWeek, Month Day"
          | "Month DD"
          | "Month DD, HH:MM period"
          | "Month DD, HH:MM period TZ"
          | "DayOfWeek, HH:MM period"
          | "DayOfWeek, HH:MM period TZ"
          | "Month DD, YYYY"
          | "Month DD, YYYY, at HH:MM period"
          | "Month DD, YYYY, at HH:MM period TZ"
          | "DayOfWeek"
          | "Month"
          | "YYYY"
          | "MM"
          | "DD"
          | "HH:MM period"
          | "HH:MM period TZ"
    • options: {
          abbreviations?: boolean;
          noZeroPadding?: boolean;
          style?: "cbc" | "rc";
          timeZone?:
              | "Canada/Atlantic"
              | "Canada/Central"
              | "Canada/Eastern"
              | "Canada/Mountain"
              | "Canada/Newfoundland"
              | "Canada/Pacific"
              | "Canada/Saskatchewan"
              | "Canada/Yukon";
          utc?: boolean;
      } = {}
      • Optionalabbreviations?: boolean
      • OptionalnoZeroPadding?: boolean
      • Optionalstyle?: "cbc" | "rc"
      • OptionaltimeZone?:
            | "Canada/Atlantic"
            | "Canada/Central"
            | "Canada/Eastern"
            | "Canada/Mountain"
            | "Canada/Newfoundland"
            | "Canada/Pacific"
            | "Canada/Saskatchewan"
            | "Canada/Yukon"
      • Optionalutc?: boolean

    Returns string

diff --git a/docs/functions/formatNumber.html b/docs/functions/formatNumber.html index ecd5790e..d1428f13 100644 --- a/docs/functions/formatNumber.html +++ b/docs/functions/formatNumber.html @@ -1,4 +1,4 @@ -formatNumber | Journalism - v1.14.1

Function formatNumber

  • Format a number with a specific style.

    +formatNumber | Journalism - v1.14.2

    Function formatNumber

    • Format a number with a specific style.

      const string = formatNumber(1234.567, { sign: true, round: true })
      // returns "+1,235"
      @@ -14,4 +14,4 @@
    • prefix: a string to add before the number, "$" for example
    • suffix: a string to add after the number, "%" for example
    -

    Parameters

    • number: number
    • options: {
          decimals?: number;
          fixed?: boolean;
          nearestInteger?: number;
          prefix?: string;
          round?: boolean;
          sign?: boolean;
          significantDigits?: number;
          style?: "cbc" | "rc";
          suffix?: string;
      } = {}
      • Optionaldecimals?: number
      • Optionalfixed?: boolean
      • OptionalnearestInteger?: number
      • Optionalprefix?: string
      • Optionalround?: boolean
      • Optionalsign?: boolean
      • OptionalsignificantDigits?: number
      • Optionalstyle?: "cbc" | "rc"
      • Optionalsuffix?: string

    Returns string

+

Parameters

Returns string

diff --git a/docs/functions/geoTo3D.html b/docs/functions/geoTo3D.html index f4ea7b9a..ef6b8d33 100644 --- a/docs/functions/geoTo3D.html +++ b/docs/functions/geoTo3D.html @@ -1,6 +1,6 @@ -geoTo3D | Journalism - v1.14.1

Function geoTo3D

  • Convert longitude and latitude to x,y,z coordinates based on a given radius. The options (last parameter) are optional.

    +geoTo3D | Journalism - v1.14.2

    Function geoTo3D

    • Convert longitude and latitude to x,y,z coordinates based on a given radius. The options (last parameter) are optional.

      const coords = geoTo3D(-73.5674, 45.5019, 1, { decimals: 2})
      // returns { x: -0.67, y: 0.71, z: 0.2 }

      You can pass { toArray: true } to return an array instead of an object.

      -

      Parameters

      • lon: number
      • lat: number
      • radius: number
      • options: {
            decimals?: number;
            toArray?: boolean;
        } = {}
        • Optionaldecimals?: number
        • OptionaltoArray?: boolean

      Returns {
          x: number;
          y: number;
          z: number;
      } | [number, number, number]

    +

    Parameters

    • lon: number
    • lat: number
    • radius: number
    • options: {
          decimals?: number;
          toArray?: boolean;
      } = {}
      • Optionaldecimals?: number
      • OptionaltoArray?: boolean

    Returns {
        x: number;
        y: number;
        z: number;
    } | [number, number, number]

diff --git a/docs/functions/getClosest.html b/docs/functions/getClosest.html index f54e3db2..8ad66beb 100644 --- a/docs/functions/getClosest.html +++ b/docs/functions/getClosest.html @@ -1,5 +1,5 @@ -getClosest | Journalism - v1.14.1

Function getClosest

  • Return the closest item of a list based on longitude and latitude. The options (last parameter) are optional. If addDistance is true and geoItems have a properties key, the distance will be added to the properties.

    +getClosest | Journalism - v1.14.2

    Function getClosest

    • Return the closest item of a list based on longitude and latitude. The options (last parameter) are optional. If addDistance is true and geoItems have a properties key, the distance will be added to the properties.

      const geoItems = [
      {name: "Montreal", lon: -73.66, lat: 45.51 },
      {name: "Toronto", lon: -79.43, lat: 43.66 },
      ]
      const ottawa = {lat: 45.37, lon: -75.71}
      const closest = getClosest(
      ottawa.lon,
      ottawa.lat,
      geoItems,
      d => d.lon,
      d => d.lat,
      { addDistance: true, decimals: 3 }
      )
      // return { name: "Montreal", lon: -73.66, lat: 45.51, distance: 160.694 }
      -

      Parameters

      • lon: number
      • lat: number
      • geoItems: unknown[]
      • getItemLon: ((d: unknown) => number)
          • (d): number
          • Parameters

            • d: unknown

            Returns number

      • getItemLat: ((d: unknown) => number)
          • (d): number
          • Parameters

            • d: unknown

            Returns number

      • options: {
            addDistance?: boolean;
            decimals?: number;
        } = {}
        • OptionaladdDistance?: boolean
        • Optionaldecimals?: number

      Returns {
          distance?: number;
          properties?: {
              distance?: number;
          };
      }

      • Optionaldistance?: number
      • Optionalproperties?: {
            distance?: number;
        }
        • Optionaldistance?: number
    +

    Parameters

    • lon: number
    • lat: number
    • geoItems: unknown[]
    • getItemLon: ((d: unknown) => number)
        • (d): number
        • Parameters

          • d: unknown

          Returns number

    • getItemLat: ((d: unknown) => number)
        • (d): number
        • Parameters

          • d: unknown

          Returns number

    • options: {
          addDistance?: boolean;
          decimals?: number;
      } = {}
      • OptionaladdDistance?: boolean
      • Optionaldecimals?: number

    Returns {
        distance?: number;
        properties?: {
            distance?: number;
        };
    }

    • Optionaldistance?: number
    • Optionalproperties?: {
          distance?: number;
      }
      • Optionaldistance?: number
diff --git a/docs/functions/getGeoTiffDetails.html b/docs/functions/getGeoTiffDetails.html index 7436abc8..cc211b33 100644 --- a/docs/functions/getGeoTiffDetails.html +++ b/docs/functions/getGeoTiffDetails.html @@ -1,5 +1,5 @@ -getGeoTiffDetails | Journalism - v1.14.1

Function getGeoTiffDetails

  • Extracts detailed informations from a geoTIFF that can be used with the getGeoTiffValues function. Just for NodeJS and similar runtimes.

    +getGeoTiffDetails | Journalism - v1.14.2

    Function getGeoTiffDetails

    • Extracts detailed informations from a geoTIFF that can be used with the getGeoTiffValues function. Just for NodeJS and similar runtimes.

      const geoTiffDetails = await getGeoTiffDetails("./some-file.tif")
      const value = await getGeoTiffValues(45.50, -73.57, geoTiffDetails)
      -

      Parameters

      • path: string

      Returns Promise<{
          bbox: number[];
          bboxHeight: number;
          bboxWidth: number;
          image: GeoTIFFImage;
          pixelHeight: number;
          pixelWidth: number;
      }>

    +

    Parameters

    • path: string

    Returns Promise<{
        bbox: number[];
        bboxHeight: number;
        bboxWidth: number;
        image: GeoTIFFImage;
        pixelHeight: number;
        pixelWidth: number;
    }>

diff --git a/docs/functions/getGeoTiffValues.html b/docs/functions/getGeoTiffValues.html index d7857edc..87b92e06 100644 --- a/docs/functions/getGeoTiffValues.html +++ b/docs/functions/getGeoTiffValues.html @@ -1,5 +1,5 @@ -getGeoTiffValues | Journalism - v1.14.1

Function getGeoTiffValues

  • Extracts values at specific lat/lon coordinates from a geotiff. Works with the values returned by the getGeoTiffDetails function.

    +getGeoTiffValues | Journalism - v1.14.2

    Function getGeoTiffValues

    • Extracts values at specific lat/lon coordinates from a geotiff. Works with the values returned by the getGeoTiffDetails function.

      const geoTiffDetails = await getGeoTiffDetails("./some-file.tif")
      const value = await getGeoTiffValues(45.50, -73.57, geoTiffDetails)
      -

      Parameters

      • lat: number
      • lon: number
      • __namedParameters: {
            bbox: number[];
            bboxHeight: number;
            bboxWidth: number;
            image: GeoTIFFImage;
            pixelHeight: number;
            pixelWidth: number;
        }
        • bbox: number[]
        • bboxHeight: number
        • bboxWidth: number
        • image: GeoTIFFImage
        • pixelHeight: number
        • pixelWidth: number

      Returns Promise<TypedArray>

    +

    Parameters

    • lat: number
    • lon: number
    • __namedParameters: {
          bbox: number[];
          bboxHeight: number;
          bboxWidth: number;
          image: GeoTIFFImage;
          pixelHeight: number;
          pixelWidth: number;
      }
      • bbox: number[]
      • bboxHeight: number
      • bboxWidth: number
      • image: GeoTIFFImage
      • pixelHeight: number
      • pixelWidth: number

    Returns Promise<TypedArray>

diff --git a/docs/functions/getHtmlTable.html b/docs/functions/getHtmlTable.html index d4238549..76c12951 100644 --- a/docs/functions/getHtmlTable.html +++ b/docs/functions/getHtmlTable.html @@ -1,5 +1,5 @@ -getHtmlTable | Journalism - v1.14.1

Function getHtmlTable

  • Returns the data from an HTML table as an array of objects. The first parameter is an url. The second parameter is an optional object specifying a css selector and/or an index.

    +getHtmlTable | Journalism - v1.14.2

    Function getHtmlTable

    • Returns the data from an HTML table as an array of objects. The first parameter is an url. The second parameter is an optional object specifying a css selector and/or an index.

      // This would parse the data from the fourth
      // table with the class name data-table.
      const data = await getHtmlTable("your-url-here", {
      selector: ".data-table",
      index: 3
      })
      -

      Parameters

      • url: string
      • options: {
            index?: number;
            selector?: string;
        } = {}
        • Optionalindex?: number
        • Optionalselector?: string

      Returns Promise<DSVRowArray<string>>

    +

    Parameters

    • url: string
    • options: {
          index?: number;
          selector?: string;
      } = {}
      • Optionalindex?: number
      • Optionalselector?: string

    Returns Promise<DSVRowArray<string>>

diff --git a/docs/functions/getHumidex.html b/docs/functions/getHumidex.html index 26c26b4b..81460fc3 100644 --- a/docs/functions/getHumidex.html +++ b/docs/functions/getHumidex.html @@ -1,7 +1,7 @@ -getHumidex | Journalism - v1.14.1

Function getHumidex

  • Calculate Humidex Factor in Celsius given the temperature in Celsius and humidity percentage. +getHumidex | Journalism - v1.14.2

    Function getHumidex

    • Calculate Humidex Factor in Celsius given the temperature in Celsius and humidity percentage. In case the calculated humidex is less than the given temperature, it returns temperature itself.

      const humidex = getHumidex(30, 70); // returns 41
       

      This is using the formula from the Canadian Centre for Climate Services.

      -

      Parameters

      • temperature: number
      • humidity: number

      Returns number

    +

    Parameters

    • temperature: number
    • humidity: number

    Returns number

diff --git a/docs/functions/getId.html b/docs/functions/getId.html index b462411c..4b46c3df 100644 --- a/docs/functions/getId.html +++ b/docs/functions/getId.html @@ -1,2 +1,2 @@ -getId | Journalism - v1.14.1

Function getId

  • Creates a unique id with letters, numbers, but no spaces or special characters. By default, the length is 6 characters. Works in the browser and NodeJS (and other runtimes). Handy, but not cryptographically secure.

    -

    Parameters

    • length: number = 6

    Returns string

+getId | Journalism - v1.14.2

Function getId

  • Creates a unique id with letters, numbers, but no spaces or special characters. By default, the length is 6 characters. Works in the browser and NodeJS (and other runtimes). Handy, but not cryptographically secure.

    +

    Parameters

    • length: number = 6

    Returns string

diff --git a/docs/functions/getSeason.html b/docs/functions/getSeason.html index aa0b099d..42de5d24 100644 --- a/docs/functions/getSeason.html +++ b/docs/functions/getSeason.html @@ -1,2 +1,2 @@ -getSeason | Journalism - v1.14.1

Function getSeason

  • Determines the current season based on a date (current date by default). Options include hemisphere (northern by default) and type (astronomical by default).

    -

    Parameters

    • options: {
          date?: Date;
          hemisphere?: "northern" | "southern";
          type?: "meteorological" | "astronomical";
      } = {}
      • Optionaldate?: Date
      • Optionalhemisphere?: "northern" | "southern"
      • Optionaltype?: "meteorological" | "astronomical"

    Returns
        | "winter"
        | "spring"
        | "summer"
        | "fall"

+getSeason | Journalism - v1.14.2

Function getSeason

  • Determines the current season based on a date (current date by default). Options include hemisphere (northern by default) and type (astronomical by default).

    +

    Parameters

    • options: {
          date?: Date;
          hemisphere?: "northern" | "southern";
          type?: "meteorological" | "astronomical";
      } = {}
      • Optionaldate?: Date
      • Optionalhemisphere?: "northern" | "southern"
      • Optionaltype?: "meteorological" | "astronomical"

    Returns
        | "winter"
        | "spring"
        | "summer"
        | "fall"

diff --git a/docs/functions/getSheetData.html b/docs/functions/getSheetData.html index 69eacf51..434264d1 100644 --- a/docs/functions/getSheetData.html +++ b/docs/functions/getSheetData.html @@ -1,4 +1,4 @@ -getSheetData | Journalism - v1.14.1

Function getSheetData

  • Returns the data of a Google Sheet.

    +getSheetData | Journalism - v1.14.2

    Function getSheetData

    • Returns the data of a Google Sheet.

      By default, this function looks for the API key in process.env.GOOGLE_PRIVATE_KEY and the service account email in process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL. If you don't have credentials, check this.

      // Fake url used as an example.
      const sheetUrl = "https://docs.google.com/spreadsheets/d/nrqo3oP4KMWYbELScQa8W1nHZPfIrA7LIz9UmcRE4GyJN/edit#gid=0";

      // Returning the data as an array of objects.
      const data = await getSheetData(data, sheetUrl);

      // Same but skipping first row.
      const data = await getSheetData(data, sheetUrl, { skip: 1});

      // You have an option to return the data as a CSV string. Useful if you just want to write the data somewhere.
      const csv = await getSheetData(data, sheetUrl, { csv: true });

      // If your API email and key are stored under different names in process.env, use the options.
      const csv = await getSheetData(data, sheetUrl, { apiEmail: "GG_EMAIL", apiKey: "GG_KEY" });
      @@ -9,4 +9,4 @@
    • OptionalapiKey?: string

      If your API key is stored under different names in process.env, use this option.

    • Optionalcsv?: boolean

      If true, the function will return a CSV string instead of an array of objects.

    • Optionalskip?: number

      The number of rows to skip before parsing the data. Defaults to 0.

      -

Returns Promise<string | DSVRowArray<string>>

+

Returns Promise<string | DSVRowArray<string>>

diff --git a/docs/functions/getStatCanTable.html b/docs/functions/getStatCanTable.html index 54a43207..3ff2add3 100644 --- a/docs/functions/getStatCanTable.html +++ b/docs/functions/getStatCanTable.html @@ -1,4 +1,4 @@ -getStatCanTable | Journalism - v1.14.1

Function getStatCanTable

  • Returns the data from a Statistics Canada table as an array of objects. The first parameter is the pid value that can be found in the table url. The second parameter is an optional object specifying:

    +getStatCanTable | Journalism - v1.14.2

    Function getStatCanTable

    • Returns the data from a Statistics Canada table as an array of objects. The first parameter is the pid value that can be found in the table url. The second parameter is an optional object specifying:

      • the language
      • if the first character of the file should be skipped (sometimes the files are weirdly formatted)
      • @@ -7,4 +7,4 @@
        const data = await getStatCanTable('98100001')
         
        -

      Parameters

      • pid: string
      • options: {
            debug?: boolean;
            lang?: "en" | "fr";
            returnRawCSV?: boolean;
            skipFirstCharacter?: boolean;
        } = {}
        • Optionaldebug?: boolean
        • Optionallang?: "en" | "fr"
        • OptionalreturnRawCSV?: boolean
        • OptionalskipFirstCharacter?: boolean

      Returns Promise<string | DSVRowArray<string>>

    +

    Parameters

    • pid: string
    • options: {
          debug?: boolean;
          lang?: "en" | "fr";
          returnRawCSV?: boolean;
          skipFirstCharacter?: boolean;
      } = {}
      • Optionaldebug?: boolean
      • Optionallang?: "en" | "fr"
      • OptionalreturnRawCSV?: boolean
      • OptionalskipFirstCharacter?: boolean

    Returns Promise<string | DSVRowArray<string>>

diff --git a/docs/functions/mortgageInsurancePremium.html b/docs/functions/mortgageInsurancePremium.html index 4a60f21a..68ce733c 100644 --- a/docs/functions/mortgageInsurancePremium.html +++ b/docs/functions/mortgageInsurancePremium.html @@ -1,7 +1,7 @@ -mortgageInsurancePremium | Journalism - v1.14.1

Function mortgageInsurancePremium

  • Calculates the mortgage insurance premium based on the property value and down payment. The returned value is rounded to the nearest integer. Based on the Financial Consumer Agency of Canada calculator.

    +mortgageInsurancePremium | Journalism - v1.14.2

    Function mortgageInsurancePremium

    • Calculates the mortgage insurance premium based on the property value and down payment. The returned value is rounded to the nearest integer. Based on the Financial Consumer Agency of Canada calculator.

      // Returns 19_000
      const insurancePremium = mortgageInsurancePremium(500_000, 25_000)

      Parameters

      • purchasePrice: number

        The price of the purchased property.

      • downPayment: number

        The amount of money paid upfront.

        -

      Returns number

    +

Returns number

diff --git a/docs/functions/mortgageMaxAmount.html b/docs/functions/mortgageMaxAmount.html index fa15e3ca..4fccea5b 100644 --- a/docs/functions/mortgageMaxAmount.html +++ b/docs/functions/mortgageMaxAmount.html @@ -1,4 +1,4 @@ -mortgageMaxAmount | Journalism - v1.14.1

Function mortgageMaxAmount

  • Calculates the maximum purchase price (and other variables) for a property a person can afford and the related mortgage it would qualify for based on annual income, down payment, mortgage interest rate, and additional options.

    +mortgageMaxAmount | Journalism - v1.14.2

    Function mortgageMaxAmount

    • Calculates the maximum purchase price (and other variables) for a property a person can afford and the related mortgage it would qualify for based on annual income, down payment, mortgage interest rate, and additional options.

      // With an annual income of $100,000, a down payment of $25,000, and a rate of 5.25%.
      const results = maxMortgageAmount(100_000, 25_000, 5.25)
      // results = {
      // annualIncome: 100000,
      // downPayment: 25000,
      // rate: 5.25,
      // rateTested: 7.25,
      // purchasePrice: 307000,
      // mortgageAmount: 293280,
      // insurancePremium: 11280,
      // monthlyMortgagePayment: 2099.65,
      // grossDebtServiceRatio: 0.32,
      // totalDebtServiceRatio: 0.32,
      // reason: "debt limit",
      // monthlyDebtPayment: 0,
      // monthlyHeating: 175,
      // isHeatingEstimate: true,
      // monthlyTax: 385,
      // isTaxEstimate: true,
      // monthlyCondoFees: 0,
      // }
      @@ -10,4 +10,4 @@
    • OptionalmonthlyDebtPayment?: number

      The monthly debt payment of the borrower. Defaults to 0.

    • OptionalmonthlyHeating?: number

      The monthly heating cost. Defaults to $175.

    • OptionalmonthlyTax?: number

      The monthly property tax. Default to 1.5% of the purchase price.

      -

Returns {
    annualIncome: number;
    downPayment: number;
    grossDebtServiceRatio: number;
    insurancePremium: number;
    isHeatingEstimate: boolean;
    isTaxEstimate: boolean;
    monthlyCondoFees: number;
    monthlyDebtPayment: number;
    monthlyHeating: number;
    monthlyMortgagePayment: number;
    monthlyTax: number;
    mortgageAmount: number;
    purchasePrice: number;
    rate: number;
    rateTested: number;
    reason: string;
    totalDebtServiceRatio: number;
}

+

Returns {
    annualIncome: number;
    downPayment: number;
    grossDebtServiceRatio: number;
    insurancePremium: number;
    isHeatingEstimate: boolean;
    isTaxEstimate: boolean;
    monthlyCondoFees: number;
    monthlyDebtPayment: number;
    monthlyHeating: number;
    monthlyMortgagePayment: number;
    monthlyTax: number;
    mortgageAmount: number;
    purchasePrice: number;
    rate: number;
    rateTested: number;
    reason: string;
    totalDebtServiceRatio: number;
}

diff --git a/docs/functions/mortgagePayments.html b/docs/functions/mortgagePayments.html index 44d3e17c..fc708f13 100644 --- a/docs/functions/mortgagePayments.html +++ b/docs/functions/mortgagePayments.html @@ -1,4 +1,4 @@ -mortgagePayments | Journalism - v1.14.1

Function mortgagePayments

  • Returns fixed rate mortgage payments in an array. Each payment is an object with the paymentId, the payment amount, the interest and capital portions of the payment, the remaining mortgage balance, and the total amount paid, total interest paid, and total capital reimbursed so far. The calculations have been tested for Canada, which requires fixed rate mortgages to be compounded semi-annually by law. But you can change the annualCompounding in the options.

    +mortgagePayments | Journalism - v1.14.2

    Function mortgagePayments

    • Returns fixed rate mortgage payments in an array. Each payment is an object with the paymentId, the payment amount, the interest and capital portions of the payment, the remaining mortgage balance, and the total amount paid, total interest paid, and total capital reimbursed so far. The calculations have been tested for Canada, which requires fixed rate mortgages to be compounded semi-annually by law. But you can change the annualCompounding in the options.

      If the amortizationPeriod is smaller than the term, an error is thrown.

      These options can be passed in an object as the last parameter:

        @@ -8,4 +8,4 @@
      • debug: Will log extra information if true.

      Calculations are based on https://www.yorku.ca/amarshal/mortgage.htm and https://www.mikesukmanowsky.com/blog/a-guide-to-canadian-mortgage-calculations

      -

      Parameters

      • mortageAmount: number
      • rate: number
      • paymentFrequency:
            | "weekly"
            | "biWeekly"
            | "monthly"
            | "semiMonthly"
            | "acceleratedWeekly"
            | "acceleratedBiWeekly"
      • term: number
      • amortizationPeriod: number
      • options: {
            annualCompounding?: number;
            debug?: boolean;
            decimals?: number;
            id?: string;
        } = {}
        • OptionalannualCompounding?: number
        • Optionaldebug?: boolean
        • Optionaldecimals?: number
        • Optionalid?: string

      Returns {
          amountPaid: number;
          balance: number;
          capital: number;
          capitalPaid: number;
          id?: string;
          interest: number;
          interestPaid: number;
          payment: number;
          paymentId: number;
      }[]

    +

    Parameters

    • mortageAmount: number
    • rate: number
    • paymentFrequency:
          | "weekly"
          | "biWeekly"
          | "monthly"
          | "semiMonthly"
          | "acceleratedWeekly"
          | "acceleratedBiWeekly"
    • term: number
    • amortizationPeriod: number
    • options: {
          annualCompounding?: number;
          debug?: boolean;
          decimals?: number;
          id?: string;
      } = {}
      • OptionalannualCompounding?: number
      • Optionaldebug?: boolean
      • Optionaldecimals?: number
      • Optionalid?: string

    Returns {
        amountPaid: number;
        balance: number;
        capital: number;
        capitalPaid: number;
        id?: string;
        interest: number;
        interestPaid: number;
        payment: number;
        paymentId: number;
    }[]

diff --git a/docs/functions/overwriteSheetData.html b/docs/functions/overwriteSheetData.html index c8c10c4b..525c522d 100644 --- a/docs/functions/overwriteSheetData.html +++ b/docs/functions/overwriteSheetData.html @@ -1,4 +1,4 @@ -overwriteSheetData | Journalism - v1.14.1

Function overwriteSheetData

  • Clears a Google Sheet and populates it with new data.

    +overwriteSheetData | Journalism - v1.14.2

    Function overwriteSheetData

    • Clears a Google Sheet and populates it with new data.

      By default, this function looks for the API key in process.env.GOOGLE_PRIVATE_KEY and the service account email in process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL. If you don't have credentials, check this.

      // The data needs to be an array of objects. The keys of the first object will be used to create the header row.
      const data = [
      { first: "Nael", last: "Shiab" },
      { first: "Andrew", last: "Ryan" },
      ];
      // Fake url used as an example.
      const sheetUrl = "https://docs.google.com/spreadsheets/d/nrqo3oP4KMWYbELScQa8W1nHZPfIrA7LIz9UmcRE4GyJN/edit#gid=0";

      // Clearing the sheet and then populating it.
      await overwriteSheetData(data, sheetUrl);

      // Same thing but with raw values. Google Sheet won't try to guess the data types and won't format or parse the values.
      await overwriteSheetData(data, sheetUrl, { raw: true });

      // Adding the UTC date of the update before the data.
      await overwriteSheetData(data, sheetUrl, { lastUpdate: true });

      // You can also format the date to a specific time zone.
      await overwriteSheetData(data, sheetUrl, { lastUpdate: true, timeZone: "Canada/Eastern" });

      // The prepend option allows you to add extra text on the first row.
      await overwriteSheetData(data, sheetUrl, { prepend: "Contact xxxx.xxxx@gmail.com for more information", lastUpdate: true, timeZone: "Canada/Eastern" });

      // If your API email and key are stored under different names in process.env, use the options.
      await overwriteSheetData(data, sheetUrl, { apiEmail: "GG_EMAIL", apiKey: "GG_KEY" });
      @@ -12,4 +12,4 @@
    • Optionalprepend?: string

      Text to be added before the data.

    • Optionalraw?: boolean

      If true, Google Sheet won't try to guess the data type and won't format or parse the values.

    • OptionaltimeZone?:
          | "Canada/Atlantic"
          | "Canada/Central"
          | "Canada/Eastern"
          | "Canada/Mountain"
          | "Canada/Newfoundland"
          | "Canada/Pacific"
          | "Canada/Saskatchewan"
          | "Canada/Yukon"

      If lastUpdate is true, you can use this option to format the date to a specific time zone.

      -

Returns Promise<void>

+

Returns Promise<void>

diff --git a/docs/functions/prettyDuration.html b/docs/functions/prettyDuration.html index 5254d10c..f8737610 100644 --- a/docs/functions/prettyDuration.html +++ b/docs/functions/prettyDuration.html @@ -1,5 +1,5 @@ -prettyDuration | Journalism - v1.14.1

Function prettyDuration

  • Returns the duration as a string in terms of milliseconds, seconds, minutes, hours, and days.

    +prettyDuration | Journalism - v1.14.2

    Function prettyDuration

    • Returns the duration as a string in terms of milliseconds, seconds, minutes, hours, and days.

      // A starting Date somewhere in your code
      const startDate = new Date() // or Date.now()

      // When you want to know the elapsed duration, pass the start date
      const duration = prettyDuration(startDate)
      // Returns something like "22 days, 6 h, 3 min, 15 sec, 3 ms"

      // If you want to console.log it, set the option log to true
      prettyDuration(startDate, {log: true})

      // You can also use a prefix and/or suffix
      prettyDuration(startDate, {log: true, prefix: "Total duration: ", suffix: " (Main function)"})
      // Returns and logs something like "Total duration: 3 min, 15 sec, 3 ms (Main function)"

      // If you want to format the duration between two specific dates, use the end option.
      prettyDuration(new Date("2024-01-01T17:00:00"), { end: new Date("2024-01-23T23:03:15") })
      // Returns "22 days, 6 h, 3 min, 15 sec, 0 ms"
      -

      Parameters

      • start: number | Date
      • options: {
            end?: number | Date;
            log?: boolean;
            prefix?: string;
            suffix?: string;
        } = {}
        • Optionalend?: number | Date
        • Optionallog?: boolean
        • Optionalprefix?: string
        • Optionalsuffix?: string

      Returns string

    +

    Parameters

    • start: number | Date
    • options: {
          end?: number | Date;
          log?: boolean;
          prefix?: string;
          suffix?: string;
      } = {}
      • Optionalend?: number | Date
      • Optionallog?: boolean
      • Optionalprefix?: string
      • Optionalsuffix?: string

    Returns string

diff --git a/docs/functions/publishChartDW.html b/docs/functions/publishChartDW.html index 0f44eea4..28da5983 100644 --- a/docs/functions/publishChartDW.html +++ b/docs/functions/publishChartDW.html @@ -1,5 +1,5 @@ -publishChartDW | Journalism - v1.14.1

Function publishChartDW

  • Publishes the specified Datawrapper chart, table, or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

    +publishChartDW | Journalism - v1.14.2

    Function publishChartDW

    • Publishes the specified Datawrapper chart, table, or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

      const chartID = "myChartId"
      await publishChartDW(chartID)

      // If your API key is stored under a different name in process.env, use the options.
      await publishChartDW(chartID, { apiKey: "DW_KEY" })
      -

      Parameters

      • chartId: string
      • options: {
            apiKey?: string;
            returnResponse?: boolean;
        } = {}
        • OptionalapiKey?: string
        • OptionalreturnResponse?: boolean

      Returns Promise<void | Response>

    +

    Parameters

    • chartId: string
    • options: {
          apiKey?: string;
          returnResponse?: boolean;
      } = {}
      • OptionalapiKey?: string
      • OptionalreturnResponse?: boolean

    Returns Promise<void | Response>

diff --git a/docs/functions/round.html b/docs/functions/round.html index 19c6ab3a..59066f86 100644 --- a/docs/functions/round.html +++ b/docs/functions/round.html @@ -1,4 +1,4 @@ -round | Journalism - v1.14.1

Function round

  • Round a number. By default, round to the nearest integer.

    +round | Journalism - v1.14.2

    Function round

    • Round a number. By default, round to the nearest integer.

      const string = round(1234.567, { decimals: 1 })
      // returns 1,235.6
      @@ -9,4 +9,4 @@
    • significantDigits: The number of digits to keep. Significant digits start being counted at the first non-zero digit. For example, 0.004622 with 1 significant digit will the rounded to 0.005.
    • try: by default, the function throws an error if the passed value is not a number. With try set to true, no error is thrown but the returned value is NaN.
    -

    Parameters

    • number: number
    • options: {
          decimals?: number;
          nearestInteger?: number;
          significantDigits?: number;
          try?: boolean;
      } = {}
      • Optionaldecimals?: number
      • OptionalnearestInteger?: number
      • OptionalsignificantDigits?: number
      • Optionaltry?: boolean

    Returns number

+

Parameters

Returns number

diff --git a/docs/functions/savePlotChart.html b/docs/functions/savePlotChart.html index 9fc5abf9..dc082c16 100644 --- a/docs/functions/savePlotChart.html +++ b/docs/functions/savePlotChart.html @@ -1,5 +1,5 @@ -savePlotChart | Journalism - v1.14.1

Function savePlotChart

  • Saves an Observable Plot chart as an image. You must use the Plot.dot syntax and install puppeteer (npm i puppeteer).

    +savePlotChart | Journalism - v1.14.2

    Function savePlotChart

    • Saves an Observable Plot chart as an image. You must use the Plot.dot syntax and install puppeteer (npm i puppeteer).

      import * as Plot from "@observablehq/plot"

      // The data must be an array of objects.
      const data = [{ salary: 75000, hireDate: new Date("2023-12-22") }, ...]

      // The Plot options must be wrapped into a function and use the Plot. syntax.
      const chart = () => Plot.plot({
      marks: [
      Plot.dot(data, {x: "hireDate", y: "salary"})
      ]
      })

      // Change the extension to .jpeg to get a JPEG file.
      const path = "./my-chart.png"

      await savePlotChart(data, chart, path)
      -

      Parameters

      • data: {
            [key: string]: unknown;
        }[]
      • makeChart: ((data: {
            [key: string]: unknown;
        }[]) => SVGSVGElement | HTMLElement)
          • (data): SVGSVGElement | HTMLElement
          • Parameters

            • data: {
                  [key: string]: unknown;
              }[]

            Returns SVGSVGElement | HTMLElement

      • path: string

      Returns Promise<void>

    +

    Parameters

    • data: {
          [key: string]: unknown;
      }[]
    • makeChart: ((data: {
          [key: string]: unknown;
      }[]) => SVGSVGElement | HTMLElement)
        • (data): SVGSVGElement | HTMLElement
        • Parameters

          • data: {
                [key: string]: unknown;
            }[]

          Returns SVGSVGElement | HTMLElement

    • path: string

    Returns Promise<void>

diff --git a/docs/functions/styledLayerDescriptor.html b/docs/functions/styledLayerDescriptor.html index b0c64c61..5387e7ca 100644 --- a/docs/functions/styledLayerDescriptor.html +++ b/docs/functions/styledLayerDescriptor.html @@ -1,5 +1,5 @@ -styledLayerDescriptor | Journalism - v1.14.1

Function styledLayerDescriptor

  • Returns the OpenGIS Styled Layer Descriptor encoded for an URL. The required parameters are the layer and the color scale.

    +styledLayerDescriptor | Journalism - v1.14.2

    Function styledLayerDescriptor

    • Returns the OpenGIS Styled Layer Descriptor encoded for an URL. The required parameters are the layer and the color scale.

      // Returns the SLD for the GDPS.ETA_TT layer with a color scale going from blue to red.
      const sdl = styledLayerDescriptor("GDPS.ETA_TT", [
      { color: "#550c24", value: 100 },
      { color: "#7f2e34", value: 30 },
      { color: "#c26847", value: 20 },
      { color: "#bdbb7a", value: 10 },
      { color: "#e0e9f0", value: 0 },
      { color: "#97b4cd", value: -10 },
      { color: "#5881a1", value: -20 },
      { color: "#334f60", value: -30 },
      { color: "#21353f", value: -100 },
      ])

      // The sdl can now be used in a WMS request as SLD_BODY
      const url = `https://geo.weather.gc.ca/geomet?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-90,-180,90,180&CRS=EPSG:4326&WIDTH=2400&HEIGHT=1200&LAYERS=GDPS.ETA_TT&FORMAT=image/jpeg&SLD_BODY=${sld}`
      -

      Parameters

      • layer: string
      • colorScale: {
            color: string;
            value: number;
        }[]

      Returns string

    +

    Parameters

    • layer: string
    • colorScale: {
          color: string;
          value: number;
      }[]

    Returns string

diff --git a/docs/functions/unzip.html b/docs/functions/unzip.html index 01401d06..aa91dfd4 100644 --- a/docs/functions/unzip.html +++ b/docs/functions/unzip.html @@ -1,4 +1,4 @@ -unzip | Journalism - v1.14.1

Function unzip

  • Unzips a file and outputs the result in a folder.

    +unzip | Journalism - v1.14.2

    Function unzip

    • Unzips a file and outputs the result in a folder.

      unzip("files.zip", "./output/")
       
      @@ -6,4 +6,4 @@
      unzip("files.zip", "./output/", { deleteZippedFile: true })
       
      -

      Parameters

      • zippedFile: string
      • output: string
      • options: {
            deleteZippedFile?: boolean;
        } = {}
        • OptionaldeleteZippedFile?: boolean

      Returns void

    +

    Parameters

    • zippedFile: string
    • output: string
    • options: {
          deleteZippedFile?: boolean;
      } = {}
      • OptionaldeleteZippedFile?: boolean

    Returns void

diff --git a/docs/functions/updateAnnotationsDW.html b/docs/functions/updateAnnotationsDW.html index 021ca510..f7537236 100644 --- a/docs/functions/updateAnnotationsDW.html +++ b/docs/functions/updateAnnotationsDW.html @@ -1,5 +1,5 @@ -updateAnnotationsDW | Journalism - v1.14.1

Function updateAnnotationsDW

  • Updates annotations in on a chart. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

    +updateAnnotationsDW | Journalism - v1.14.2

    Function updateAnnotationsDW

    • Updates annotations in on a chart. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

      import { updateAnnotationsDW } from "journalism"

      const chartID = "myChartId"
      const myAnnotations = [
      {
      "x": "2024/08/30 01:52",
      "y": "14496235",
      "text": "This is an annotation!",
      },
      {
      "x": "2024/06/29",
      "y": "15035128",
      "dy": 50,
      "text": "This is also some text, but with an arrow!",
      "connectorLine": {
      "enabled": true,
      "type": "straight",
      "arrowHead": "lines"
      },
      "mobileFallback": false
      }
      ]

      await updateAnnotationsDW(chartID, myAnnotations)

      // If your API key is stored under a different name in process.env, use the options.
      await updateAnnotationsDW(chartID, myAnnotations, { apiKey: "DW_KEY" })
      -

      Parameters

      • chartId: string
      • annotations: {
            align?:
                | "tr"
                | "tl"
                | "tc"
                | "ml"
                | "mc"
                | "mr"
                | "bl"
                | "bc"
                | "br";
            bg?: boolean;
            bold?: boolean;
            color?: string;
            connectorLine?: {
                arrowHead?: false | "lines" | "triangle";
                circle?: boolean;
                circleRadius?: number;
                circleStyle?: string;
                enabled?: boolean;
                inheritColor?: boolean;
                stroke?: 1 | 3 | 2;
                targetPadding?: number;
                type?: "straight" | "curveRight" | "curveLeft";
            };
            dx?: number;
            dy?: number;
            italic?: boolean;
            mobileFallback?: boolean;
            showDesktop?: boolean;
            showMobile?: boolean;
            size?: number;
            text: string;
            underline?: boolean;
            width?: number;
            x: string;
            y: string;
        }[]
      • options: {
            apiKey?: string;
            returnResponse?: boolean;
        } = {}
        • OptionalapiKey?: string
        • OptionalreturnResponse?: boolean

      Returns Promise<void | Response>

    +

    Parameters

    • chartId: string
    • annotations: {
          align?:
              | "tr"
              | "tl"
              | "tc"
              | "ml"
              | "mc"
              | "mr"
              | "bl"
              | "bc"
              | "br";
          bg?: boolean;
          bold?: boolean;
          color?: string;
          connectorLine?: {
              arrowHead?: false | "lines" | "triangle";
              circle?: boolean;
              circleRadius?: number;
              circleStyle?: string;
              enabled?: boolean;
              inheritColor?: boolean;
              stroke?: 1 | 3 | 2;
              targetPadding?: number;
              type?: "straight" | "curveRight" | "curveLeft";
          };
          dx?: number;
          dy?: number;
          italic?: boolean;
          mobileFallback?: boolean;
          showDesktop?: boolean;
          showMobile?: boolean;
          size?: number;
          text: string;
          underline?: boolean;
          width?: number;
          x: string;
          y: string;
      }[]
    • options: {
          apiKey?: string;
          returnResponse?: boolean;
      } = {}
      • OptionalapiKey?: string
      • OptionalreturnResponse?: boolean

    Returns Promise<void | Response>

diff --git a/docs/functions/updateDataDW.html b/docs/functions/updateDataDW.html index 5b1f7daa..48ce72d8 100644 --- a/docs/functions/updateDataDW.html +++ b/docs/functions/updateDataDW.html @@ -1,4 +1,4 @@ -updateDataDW | Journalism - v1.14.1

Function updateDataDW

  • Updates the data of a specified Datawrapper chart, table or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

    +updateDataDW | Journalism - v1.14.2

    Function updateDataDW

    • Updates the data of a specified Datawrapper chart, table or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

      Example for a chart.

      import { updateDataDW, dataAsCsv } from "journalism"

      const chartID = "myChartId"

      const data = [
      { salary: 75000, hireDate: new Date("2022-12-15") },
      ...
      ]
      const dataForChart = dataAsCsv(data)

      await updateDataDW(chartID, dataForChart)

      // If your API key is stored under a different name in process.env, use the options.
      await updateDataDW(chartID, dataForChart, { apiKey: "DW_KEY" })
      @@ -7,4 +7,4 @@
      import { updateDataDW } from "journalism"

      const mapID = "myMapId"

      const geojson = {
      "type": "FeatureCollection",
      "features": [
      {
      "type": "Feature",
      "properties": {},
      "geometry": {
      "coordinates": [
      [
      [
      11.127454320325711,
      20.34856592751224
      ],
      [
      11.127454320325711,
      -13.781306861158996
      ],
      [
      55.68071875381875,
      -13.781306861158996
      ],
      [
      55.68071875381875,
      20.34856592751224
      ],
      [
      11.127454320325711,
      20.34856592751224
      ]
      ]
      ],
      "type": "Polygon"
      }
      }
      ]
      }

      const dataForMap = {
      "markers": [
      {
      "id": "m1",
      "type": "area",
      "visible": true,
      "exactShape": true,
      "fill": true,
      "stroke": true,
      "properties": {
      "fill": "#15607a",
      "fill-opacity": 0.2,
      "stroke": "#15607a",
      "stroke-width": 1,
      "stroke-opacity": 1,
      "stroke-dasharray": "100000",
      "pattern": "solid",
      "pattern-line-width": 2,
      "pattern-line-gap": 2
      },
      "feature": geojson
      }
      ]
      }

      await updateDataDW(mapID, JSON.stringify(dataForMap))

      // If your API key is stored under a different name in process.env, use the options.
      await updateDataDW(mapID, JSON.stringify(dataForMap), { apiKey: "DW_KEY" })
      -

      Parameters

      • chartId: string
      • data: string
      • options: {
            apiKey?: string;
            returnResponse?: boolean;
        } = {}
        • OptionalapiKey?: string
        • OptionalreturnResponse?: boolean

      Returns Promise<void | Response>

    +

    Parameters

    • chartId: string
    • data: string
    • options: {
          apiKey?: string;
          returnResponse?: boolean;
      } = {}
      • OptionalapiKey?: string
      • OptionalreturnResponse?: boolean

    Returns Promise<void | Response>

diff --git a/docs/functions/updateNotesDW.html b/docs/functions/updateNotesDW.html index 2ae2a301..75e88647 100644 --- a/docs/functions/updateNotesDW.html +++ b/docs/functions/updateNotesDW.html @@ -1,5 +1,5 @@ -updateNotesDW | Journalism - v1.14.1

Function updateNotesDW

  • Updates notes field for a specified Datawrapper chart, table or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

    +updateNotesDW | Journalism - v1.14.2

    Function updateNotesDW

    • Updates notes field for a specified Datawrapper chart, table or map. By default, this function looks for the API key in process.env.DATAWRAPPER_KEY.

      import { updateNotesDW, formatDate } from "journalism"

      const chartID = "myChartId"
      const dateString = formatDate(new Date(), "Month DD, YYYY, at HH:MM period", { abbreviations: true })
      const note = `This chart was last updated on ${dateString}`

      await updateNotesDW(chartID, note)

      // If your API key is stored under a different name in process.env, use the options.
      await updateNotesDW(chartID, note, { apiKey: "DW_KEY" })
      -

      Parameters

      • chartId: string
      • note: string
      • options: {
            apiKey?: string;
            returnResponse?: boolean;
        } = {}
        • OptionalapiKey?: string
        • OptionalreturnResponse?: boolean

      Returns Promise<void | Response>

    +

    Parameters

    • chartId: string
    • note: string
    • options: {
          apiKey?: string;
          returnResponse?: boolean;
      } = {}
      • OptionalapiKey?: string
      • OptionalreturnResponse?: boolean

    Returns Promise<void | Response>

diff --git a/docs/functions/zip.html b/docs/functions/zip.html index 96a5a3df..77d40262 100644 --- a/docs/functions/zip.html +++ b/docs/functions/zip.html @@ -1,5 +1,5 @@ -zip | Journalism - v1.14.1

Function zip

  • Zips multiple files together. To zip an entire folder, pass the folder path as the first parameter. To zip specific files, pass their path as an array of strings. The function will create the path of the zipped file if it doesn't exist.

    +zip | Journalism - v1.14.2

    Function zip

    • Zips multiple files together. To zip an entire folder, pass the folder path as the first parameter. To zip specific files, pass their path as an array of strings. The function will create the path of the zipped file if it doesn't exist.

      // Entire folder
      zip("./data", "./data.zip")

      // Specific files
      zip(["./file1.json", "./file2.txt", "./file3.jpg"], "./files.zip")
      -

      Parameters

      • files: string | string[]
      • zipFile: string

      Returns void

    +

    Parameters

    • files: string | string[]
    • zipFile: string

    Returns void

diff --git a/docs/index.html b/docs/index.html index 4c72252a..b4036898 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,4 @@ -Journalism - v1.14.1

Journalism - v1.14.1

Index

Dataviz

publishChartDW +Journalism - v1.14.2

Journalism - v1.14.2

Index

Dataviz

Web scraping

+