Registry / analytics / amazon-dsp-formatter

amazon-dsp-formatter

JSON →
library1.0.2jsnpmunverified

Node.js module for formatting customer data according to Amazon Ads Audience requirements. Version 1.0.2 provides normalization for phone numbers, addresses, country names, email addresses, postal codes, and complete customer records. It handles country-dependent formatting rules (e.g., US phone numbers) and standardizes casing. Lightweight and focused solely on Amazon's DSP audience specs, unlike general data-cleaning libraries.

npm install amazon-dsp-formatter
INSTALL
IMPORT
SIG · AMAZON-DSP-FORMATT
A
amazon-dsp-formatter
analyticsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AmazonAdsFormatter
const AmazonAdsFormatter = require('amazon-dsp-formatter')
import AmazonAdsFormatter from 'amazon-dsp-formatter'
This library does not ship ESM; use CommonJS require.
constructor
new AmazonAdsFormatter()
new AmazonAdsFormatter
Must call as constructor with parentheses.
formatPhone
const formatter = new AmazonAdsFormatter(); formatter.formatPhone(number, countryCode)
formatter.formatPhone(number)
Second argument (country code) is required.

Demonstrates importing the class, instantiating, and formatting phone, address, country, email, postal code, and a full record.

const AmazonAdsFormatter = require('amazon-dsp-formatter'); const formatter = new AmazonAdsFormatter(); const phone = formatter.formatPhone('(123) 456-7890', 'us'); console.log(phone); // '11234567890' const address = formatter.formatAddress('123 Main St. Apt #5', 'us'); console.log(address); // '123 main st apt number 5' const country = formatter.formatCountry('United States'); console.log(country); // 'us' const email = formatter.formatEmail('Test.User@Example.com'); console.log(email); // 'test.user@example.com' const postal = formatter.formatPostal('K1A 0B1'); console.log(postal); // 'k1a0b' const record = { phone: '(123) 456-7890', address: '123 East Main St.', country: 'United States', firstName: 'John', lastName: 'Doe', email: 'John.Doe@example.com', city: 'New York', state: 'NY', postal: '12345-6789', }; const formattedRecord = formatter.formatRecord(record); console.log(formattedRecord);
Debug
Known issues
gotchaformatPhone expects country code as second argument, and only supports US ('us') currently.
fix
Ensure you pass a valid country code like 'us'; otherwise behavior may be undefined.
affects: 1.0.x
deprecatedThe library uses CommonJS (require) only; there is no ESM export.
fix
Use const Formatter = require('amazon-dsp-formatter') or await import('amazon-dsp-formatter') with default export.
affects: >=1.0.0
gotchaformatPostal strips spaces and lowercases; expected results may differ from Amazon's exact specs.
fix
Verify output against your specific Amazon Ads requirements.
affects: 1.0.x
Errors
Common errors & fixes
TypeError: AmazonAdsFormatter is not a constructor
Incorrect import: using destructured import instead of require.
fix
Use const AmazonAdsFormatter = require('amazon-dsp-formatter');
formatter.formatPhone is not a function
Missing parentheses when instantiating (new AmazonAdsFormatter without parentheses).
fix
Use new AmazonAdsFormatter() with parentheses.
TypeError: Cannot read property 'formatPhone' of undefined
The module was not exported correctly due to missing require.
fix
Ensure you require the module before using it.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
44 hits · last 30 days
node
34
Amazon
1
OpenAI (training)
1
Resources
amazon-dsp-formatter — npm install amazon-dsp-formatter · libregistry