Skip to main content

Neosync Javascript Transformer Functions

Learn about Neosync's Javascript transformer and generator functions, which provide a wide range of capabilities for data transformation and generation within the Javascript Transformer and Generator. Explore detailed descriptions and examples to effectively utilize these functions in your jobs.

Transformers

Neosync's transformer functions allow you to manipulate and transform data values with ease. These functions are designed to provide powerful and flexible data transformation capabilities within your jobs. Each transformer function accepts a value and a configuration object as arguments. The source column value is accessible via the value keyword, while additional columns can be referenced using input.{column_name}.


transformCharacterScramble

Transforms an existing string value by scrambling the characters while maintaining the format.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
userProvidedRegexstringfalseA custom regular expression. This regex is used to manipulate input data during the transformation process.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformCharacterScramble(value, {
userProvidedRegex: "",
seed: 1,
});


transformE164PhoneNumber

Transforms an existing E164 formatted phone number.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
preserveLengthbooltrueWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
maxLengthint64falseSpecifies the maximum length for the transformed data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformE164PhoneNumber(value, {
preserveLength: false,
maxLength: 1,
seed: 1,
});


transformEmail

Transforms an existing email address.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
preserveLengthboolfalsefalseSpecifies the maximum length for the transformed data. This field ensures that the output does not exceed a certain number of characters.
preserveDomainboolfalsefalseA boolean indicating whether the domain part of the email should be preserved.
excludedDomainsany[]falseA list of domains that should be excluded from the transformation
maxLengthint6410000falseWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
seedint64falseAn optional seed value used for generating deterministic transformations.
emailTypestring'uuidv4'falseSpecifies the type of email to transform, with options including uuidv4, fullname, or any.
invalidEmailActionstring'reject'falseSpecifies the action to take when an invalid email is encountered, with options including reject, passthrough, null, or generate.

Example


const newValue = neosync.transformEmail(value, {
preserveLength: false,
preserveDomain: false,
excludedDomains: [],
maxLength: 10000,
seed: 1,
emailType: 'uuidv4',
invalidEmailAction: 'reject',
});


transformFirstName

Transforms an existing first name

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the transformed data. This field ensures that the output does not exceed a certain number of characters.
preserveLengthboolfalsefalseWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
seedint64falseAn optional seed value used for generating deterministic transformations.

Example


const newValue = neosync.transformFirstName(value, {
maxLength: 10000,
preserveLength: false,
seed: 1,
});


transformFloat64

Transforms an existing float value.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
randomizationRangeMinfloat64trueSpecifies the minimum value for the range of the float.
randomizationRangeMaxfloat64trueSpecifies the maximum value for the randomization range of the float.
precisionint64falseAn optional parameter that defines the number of significant digits for the float.
scaleint64falseAn optional parameter that defines the number of decimal places for the float.
seedint64falseAn optional seed value used for generating deterministic transformations.

Example


const newValue = neosync.transformFloat64(value, {
randomizationRangeMin: 1.12,
randomizationRangeMax: 1.12,
precision: 1,
scale: 1,
seed: 1,
});


transformFullName

Transforms an existing full name.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000false
preserveLengthboolfalsefalseWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
seedint64falseAn optional seed value used for generating deterministic transformations.

Example


const newValue = neosync.transformFullName(value, {
maxLength: 10000,
preserveLength: false,
seed: 1,
});


transformInt64

Transforms an existing integer value.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
randomizationRangeMinint64trueSpecifies the minimum value for the range of the int.
randomizationRangeMaxint64trueSpecifies the maximum value for the range of the int.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformInt64(value, {
randomizationRangeMin: 1,
randomizationRangeMax: 1,
seed: 1,
});


transformInt64PhoneNumber

Transforms an existing phone number that is typed as an integer

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
preserveLengthbooltrueWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformInt64PhoneNumber(value, {
preserveLength: false,
seed: 1,
});


transformLastName

Transforms an existing last name.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the transformed data. This field ensures that the output does not exceed a certain number of characters.
preserveLengthboolfalsefalseWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
seedint64falseAn optional seed value used for generating deterministic transformations.

Example


const newValue = neosync.transformLastName(value, {
maxLength: 10000,
preserveLength: false,
seed: 1,
});


transformString

Transforms an existing string value.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
preserveLengthboolfalsefalseWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
minLengthint641falseSpecifies the minimum length of the transformed value.
maxLengthint6420falseSpecifies the maximum length of the transformed value.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformString(value, {
preserveLength: false,
minLength: 1,
maxLength: 20,
seed: 1,
});


transformStringPhoneNumber

Transforms an existing phone number that is typed as a string.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
preserveLengthbooltrueWhether the original length of the input data should be preserved during transformation. If set to true, the transformation logic will ensure that the output data has the same length as the input data.
maxLengthint64trueSpecifies the maximum length for the transformed data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.transformStringPhoneNumber(value, {
preserveLength: false,
maxLength: 1,
seed: 1,
});


Generators

Neosync's generator functions enable the creation of various data values, facilitating the generation of realistic and diverse data for testing and development purposes. These functions are designed to provide robust and versatile data generation capabilities within your jobs. Each generator function accepts a configuration object as an argument.


generateBool

Generates a boolean value at random.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateBool({
seed: 1,
});


generateCardNumber

Generates a card number.

Parameters

Config

FieldTypeDefaultRequiredDescription
validLuhnbooltrueA boolean indicating whether the generated value should pass the Luhn algorithm check.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateCardNumber({
validLuhn: false,
seed: 1,
});


generateCategorical

Randomly selects a value from a defined set of categorical values.

Parameters

Config

FieldTypeDefaultRequiredDescription
categoriesstringtrueA list of comma-separated string values to randomly select from.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateCategorical({
categories: "",
seed: 1,
});


generateCity

Randomly selects a city from a list of predefined US cities.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64trueSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateCity({
maxLength: 1,
seed: 1,
});


generateCountry

Randomly selects a Country and either returns the two character country code or the full country name.

Parameters

Config

FieldTypeDefaultRequiredDescription
generateFullNameboolfalsefalseIf true returns the full country name instead of the two character country code.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateCountry({
generateFullName: false,
seed: 1,
});


generateEmail

Generates a new randomized email address.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
emailTypestring'uuidv4'falseSpecifies the type of email type to generate, with options including uuidv4, fullname, or any.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateEmail({
maxLength: 100000,
emailType: 'uuidv4',
seed: 1,
});


generateFirstName

Generates a random first name.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateFirstName({
maxLength: 10000,
seed: 1,
});


generateFloat64

Generates a random float64 value.

Parameters

Config

FieldTypeDefaultRequiredDescription
randomizeSignboolfalsefalseA boolean indicating whether the sign of the float should be randomized.
minfloat64trueSpecifies the minimum value for the generated float.
maxfloat64trueSpecifies the maximum value for the generated float
precisionint64falseAn optional parameter that defines the number of significant digits for the generated float.
scaleint64falseAn optional parameter that defines the number of decimal places for the generated float.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateFloat64({
randomizeSign: false,
min: 1.12,
max: 1.12,
precision: 1,
scale: 1,
seed: 1,
});


generateFullAddress

Randomly generates a street address.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64trueSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateFullAddress({
maxLength: 1,
seed: 1,
});


generateFullName

Generates a new full name consisting of a first and last name.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateFullName({
maxLength: 10000,
seed: 1,
});


generateGender

Randomly generates one of the following genders: female, male, undefined, nonbinary.

Parameters

Config

FieldTypeDefaultRequiredDescription
abbreviateboolfalsefalseShortens length of generated value to 1.
maxLengthint6410000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateGender({
abbreviate: false,
maxLength: 10000,
seed: 1,
});


generateInt64

Generates a random integer value with a default length of 4 unless the Integer Length or Preserve Length parameters are defined.

Parameters

Config

FieldTypeDefaultRequiredDescription
randomizeSignboolfalsefalseA boolean indicating whether the sign of the float should be randomized.
minint64trueSpecifies the minimum value for the generated int.
maxint64trueSpecifies the maximum value for the generated int.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateInt64({
randomizeSign: false,
min: 1,
max: 1,
seed: 1,
});


generateInt64PhoneNumber

Generates a new phone number of type int64 with a default length of 10.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateInt64PhoneNumber({
seed: 1,
});


generateInternationalPhoneNumber

Generates a Generate phone number in e164 format.

Parameters

Config

FieldTypeDefaultRequiredDescription
minint64trueSpecifies the minimum value for the generated phone number.
maxint64trueSpecifies the maximum value for the generated phone number.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateInternationalPhoneNumber({
min: 1,
max: 1,
seed: 1,
});


generateLastName

Generates a random last name.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateLastName({
maxLength: 10000,
seed: 1,
});


generateRandomString

Creates a randomly ordered alphanumeric string with a default length of 10 unless the String Length parameter are defined.

Parameters

Config

FieldTypeDefaultRequiredDescription
minint64trueSpecifies the minimum length for the generated string.
maxint64trueSpecifies the maximum length for the generated string.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateRandomString({
min: 1,
max: 1,
seed: 1,
});


generateSHA256Hash

SHA256 hashes a randomly generated value.

Parameters

Config

FieldTypeDefaultRequiredDescription

Example


const newValue = neosync.generateSHA256Hash({});


generateSSN

Generates a completely random social security numbers including the hyphens in the format xxx-xx-xxxx.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateSSN({
seed: 1,
});


generateState

Randomly selects a US state and either returns the two character state code or the full state name.

Parameters

Config

FieldTypeDefaultRequiredDescription
generateFullNameboolfalsefalseIf true returns the full state name instead of the two character state code.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateState({
generateFullName: false,
seed: 1,
});


generateStreetAddress

Randomly generates a street address.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64trueSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateStreetAddress({
maxLength: 1,
seed: 1,
});


generateStringPhoneNumber

Generates a Generate phone number and returns it as a string.

Parameters

Config

FieldTypeDefaultRequiredDescription
minint64trueSpecifies the minimum length for the generated phone number.
maxint64trueSpecifies the maximum length for the generated phone number.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateStringPhoneNumber({
min: 1,
max: 1,
seed: 1,
});


generateUnixTimestamp

Randomly generates a Unix timestamp.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateUnixTimestamp({
seed: 1,
});


generateUsername

Randomly generates a username

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint6410000falseSpecifies the maximum length for the generated data. This field ensures that the output does not exceed a certain number of characters.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateUsername({
maxLength: 10000,
seed: 1,
});


generateUTCTimestamp

Randomly generates a UTC timestamp.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateUTCTimestamp({
seed: 1,
});


generateUUID

Generates a new UUIDv4 id.

Parameters

Config

FieldTypeDefaultRequiredDescription
includeHyphensbooltruefalseDetermines whether the generated UUID should include hyphens. If set to true, the UUID will be formatted with hyphens (e.g., d853d251-e135-4fe4-a4eb-0aea6bfaf645). If set to false, the hyphens will be omitted (e.g., d853d251e1354fe4a4eb0aea6bfaf645).

Example


const newValue = neosync.generateUUID({
includeHyphens: true,
});


generateZipcode

Randomly selects a zip code from a list of predefined US zipcodes.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


const newValue = neosync.generateZipcode({
seed: 1,
});