Utils

Using Nexus utils inside the script

File Utils

  1. Converts file data to JSON

    return (FileUtils.convertFileToJSON(getMeta('files.fileNameHere')).then(json => {
      setCtx('jsonData', json['sheetNameHere']);
    }));

XML Utils

  1. convertJSONtoXML: Converts JSON to XML.

     const empXml = XMLUtils.convertJSONtoXML({
         name: 'abc',
         age:25
     });
  2. convertXMLtoJSON: Converts XML to JSON.

     const empObj = XMLUtils.convertXMLtoJSON('<name>abc</name><age>25</age>');

Date Utils

  1. format: Converts date to the required format.

    Accepts 2 parameters.

    1. Date

    2. Format

      const date = DateUtils.format(new Date('12-28-2019'), 'YYYY-DD-MM')
  2. add: Adds the given date by the amount & unit of datetime specified.

    Accepts 3 parameters.

    1. Date

    2. Amount

    3. Unit of Datetime (year/years/y, month/months/M, week/weeks/w, day/days/d, hour/hours/h, minute/minutes/m, second/seconds/s, millisecond/milliseconds/ms, quarter/quarters/Q)

      const date = DateUtils.add(new Date(), 1, 'day')
  3. subtract: Substracts the given date by the amount & unit of datetime specified.

    Accepts 3 parameters.

    1. Date

    2. Amount

    3. Unit of Datetime (year/years/y, month/months/M, week/weeks/w, day/days/d, hour/hours/h, minute/minutes/m, second/seconds/s, millisecond/milliseconds/ms, quarter/quarters/Q)

      const date = DateUtils.subtract(new Date(), 1, 'day')
  4. isValidDate: Returns true if the date provided is valid.

     const date = DateUtils.isValidDate(new Date())
  5. convertDateToISO: Converts date object to ISO.

     const date = DateUtils.convertDateToISO(new Date() as any)
  6. convertISOToDate: Converts ISO to a date object.

     const date = DateUtils.convertISOToDate('10/09/2020' as any)
  7. parse: Converts given string date to a date object.

    Accepts 2 parameters.

    1. Date in string

    2. format - optional.If provided converts the date string to the provided format.

      const date = DateUtils.parse('10/09/2020' as any)

Compression Utils

1. decompress: Decodes the given data.

Accepts 2 parameters.

  1. input

  2. inputEncoding/decompressoptions (ByteArray/Buffer/Base64/BinaryString/StorageBinaryString) - Default is Base64.

2. compress: Encodes the given data.

Accepts 2 parameters.

  1. input

  2. outputEncoding/compressoptions (ByteArray/Buffer/Base64/BinaryString/StorageBinaryString) - Default is Base64.

Last updated

Was this helpful?