Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
excludeRelated Articles

dataforge

The dataforge library can load CSV, JSON, or arbitrary data sets; dataforge lets you analyze data, wrangle, and visualize with ease.
See https://www.npmjs.com/package/data-forge.

Some of the features include:

  • Import and export CSV and JSON data, arbitrary JavaScript data, and text files.

  • Many options for working with your data:

    • Filtering and sorting

    • Transformation

    • Extracting subsets

    • Grouping, aggregation, and summation

  • Great for analyzing tabular data: add, remove, transform, and generate named columns (series) of data.

  • Great for working with time-series data.

  • Your data is indexed so you can merge and aggregate it.

  • Your data is immutable! Transformations and modifications produce a new dataset.

Code Block
const dataForge = require('dataforge');
dataForge.readFile('./input-data-file.csv') // Read CSV file (or JSON!)
    .parseCSV()
    .parseDates(["Column B"]) // Parse date columns.
    .parseInts(["Column B", "Column C"]) // Parse integer columsn.
    .parseFloats(["Column D", "Column E"]) // Parse float columns.
    .dropSeries(["Column F"]) // Drop certain columns.
    .where(row => predicate(row)) // Filter rows.
    .select(row => transform(row)) // Transform the data.
    .asCSV() 
    .writeFile("./output-data-file.csv") // Write to output CSV file (or JSON!)
    .then(() => {
                  console.log("Done!");
                })
    .catch(err => {
                    console.log("An error occurred!");
                  });

handlebars

The handlebars library lets you build semantic templates effectively with no frustration. The handlebars library is compatible with mustache templates. In most cases, you can swap out the mustache with handlebars and continue using your current templates.
See https://www.npmjs.com/package/handlebars .

When you have a template, use the Handlebars.compile method to compile the template into a function. The generated function takes a context argument, which will be used to render the template.

...

Code Block
Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:
Jimmy is 12
Sally is 4

lodash

The lodash library makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, and so on.
See https://lodash.com/docs/4.17.1015.

  • Iterating arrays, objects, and strings

  • Manipulating and testing values

  • Creating composite functions

The following code loops through an array and output outputs the value.

Code Block
var _ = global.get('lodash');
_.forEach([1, 2], function(value) { node.warn(value); });

moment

Themoment library makes it easier to use parse, validate, manipulate, and display dates and times in JavaScript.
See https://momentjs.com/.

  • Format Dates.

  • Calculate relative time.

  • Use calendar time.

  • Format time.

...

Code Block
var moment = global.get('moment');
var newDate = moment().add(#, 'days'); 

momentTimezone

The momentTimezone library makes it easier to parse and display dates in any time zones.
See https://momentjs.com/timezone/ .

  • Format Dates in any time zone.

  • Convert Dates between time zones.

...

Code Block
var momentTz = global.get('momentTimezone');
var moment = global.get('moment');
var newyorkTime = momentTz(moment()).tz('America/New_York').format();

orbitaUtil

The orbitaUtil library contains all reusable codes that are frequently used in the Experience Designer and Experience Manager.

...

Code Block
var orbitaUtil = global.get('orbitaUtil')
var options = {
                text: textResponse
              };
textResponse = orbitaUtil.OESanitizeSimpleHtmlText(options);

cryptoJS

The cryptoJS module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. Using cryptoJS, you can send the encrypted data to the server.
See https://www.npmjs.com/package/crypto-js and https://cryptojs.gitbook.io/docs/.

Use global.get('cryptoJS') to access this module.

...

Code Block
enValue: "270ba1458e8d5307e773e3c17f725d7f1606f37d"

zipcodeToTimezone

The zipcodeToTimezone module converts Zipcode data to the corresponding Timezone.
See https://www.npmjs.com/package/zipcode-to-timezone.

Use global.get('zipcode-to-timezone') to access this module.

...

Code Block
America/Los_Angeles

google-libphonenumber

The google-libphonenumber library can parse, format, store, and validate international phone numbers.
See https://www.npmjs.com/package/google-libphonenumber.

Usage:

Code Block
const libPhoneNumber = global.get('orbitaUtil').libPhoneNumber;
const PNF = libPhoneNumber.PhoneNumberFormat;
const phoneUtil = libPhoneNumber.PhoneNumberUtil.getInstance();
const number = phoneUtil.parseAndKeepRawInput('202-456-1414', 'US');
node.warn(phoneUtil.format(number, PNF.E164));

return msg;

Output:

...

Related Articles

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel = "essential"