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

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
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.
maxLengthint6415falseSpecifies 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: 15,
seed: 1,
});


transformEmail

Anonymizes and 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
maxLengthint64100falseWhether 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: 100,
seed: 1,
emailType: 'uuidv4',
invalidEmailAction: 'reject',
});


transformFirstName

Transforms an existing first name

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
preserveLength: false,
seed: 1,
});


transformFloat64

Anonymizes and transforms an existing float value.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
randomizationRangeMinfloat641falseSpecifies the minimum value for the range of the float.
randomizationRangeMaxfloat6410000falseSpecifies 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,
randomizationRangeMax: 10000,
precision: 1,
scale: 1,
seed: 1,
});


transformFullName

Transforms an existing full name.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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.transformFullName(value, {
maxLength: 100,
preserveLength: false,
seed: 1,
});


transformInt64

Anonymizes and transforms an existing int64 value.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
randomizationRangeMinint641falseSpecifies the minimum value for the range of the int.
randomizationRangeMaxint6410000falseSpecifies 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: 10000,
seed: 1,
});


transformInt64PhoneNumber

Anonymizes and transforms an existing int64 phone number.

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.
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


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


transformLastName

Anonymizes and transforms an existing last name.

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
preserveLength: false,
seed: 1,
});


transformString

Anonymizes and 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.
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


transformStringPhoneNumber

Anonymizes and transforms an existing phone number that is typed as a string.

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.
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


transformUuid

Transforms an existing UUID to a UUID v5

Parameters

Value
Type: Any
Description: Value that will be transformed

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used for generating deterministic transformations.

Example


const newValue = neosync.transformUuid(value, {
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 random boolean value.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


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


generateBusinessName

Generates a random business name between 2 and 35 characters long.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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.generateBusinessName({
maxLength: 100,
seed: 1,
});


generateCardNumber

Generates a 16 digit card number that is valid by Luhn valid by default.

Parameters

Config

FieldTypeDefaultRequiredDescription
validLuhnboolfalsefalseA 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
categoriesstring"ultimo,proximo,semper"falseA 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: "ultimo,proximo,semper",
seed: 1,
});


generateCity

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

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateCountry

Randomly selects a country and by default, returns it as a 2-letter country code.

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 between 2 and 12 characters long.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateFloat64

Generates a random floating point number with a max precision of 17. Go float64 adheres to the IEEE 754 standard for double-precision floating-point numbers.

Parameters

Config

FieldTypeDefaultRequiredDescription
randomizeSignboolfalsefalseA boolean indicating whether the sign of the float should be randomized.
minfloat641falseSpecifies the minimum value for the generated float.
maxfloat6410000falseSpecifies 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,
max: 10000,
precision: 1,
scale: 1,
seed: 1,
});


generateFullAddress

Generates a randomly selected real full address that exists in the United States.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateFullName

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

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateGender

Randomly generates one of the following genders: female (f), male (m), undefined (u), nonbinary (n).

Parameters

Config

FieldTypeDefaultRequiredDescription
abbreviateboolfalsefalseShortens length of generated value to 1.
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateInt64

Generates a random int64 value with a default length of 4.

Parameters

Config

FieldTypeDefaultRequiredDescription
randomizeSignboolfalsefalseA boolean indicating whether the sign of the float should be randomized.
minint641falseSpecifies the minimum value for the generated int.
maxint6410000falseSpecifies 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: 10000,
seed: 1,
});


generateInt64PhoneNumber

Generates a new int64 phone number 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 new random international phone number including the + sign and no hyphens.

Parameters

Config

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

Example


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


generateIpAddress

Generates IPv4 or IPv6 addresses with support for different network classes.

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.
ipTypestringstring(IpV4_Public)falseIP type to generate.
seedint64falseOptional seed for deterministic generation

Example


const newValue = neosync.generateIpAddress({
maxLength: 100000,
ipType: string(IpV4_Public),
seed: 1,
});


generateLastName

Generates a random last name.

Parameters

Config

FieldTypeDefaultRequiredDescription
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateRandomString

Generates a random string of alphanumeric characters..

Parameters

Config

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

Example


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


generateSHA256Hash

Generates a random SHA256 hash and returns it as a string.

Parameters

Config

FieldTypeDefaultRequiredDescription

Example


const newValue = neosync.generateSHA256Hash({});


generateSSN

Generates a 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 by default, returns it as a 2-letter state code.

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
maxLengthint64100falseSpecifies 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: 100,
seed: 1,
});


generateStringPhoneNumber

Generates a random 10 digit phone number and returns it as a string with no hyphens.

Parameters

Config

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

Example


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


generateUnixTimestamp

Randomly generates a Unix timestamp that is in the past.

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
maxLengthint64100falseSpecifies 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: 100,
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

Generates a randomly selected US zipcode.

Parameters

Config

FieldTypeDefaultRequiredDescription
seedint64falseAn optional seed value used to generate deterministic outputs.

Example


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